<FileTree> component. You can open or close a sub-directory by clicking on it.
Additionally, you can add notes to files and directories.
Import
Usage
To display the file tree with file icons and collapsible sub-directories using the<FileTree> component, specify the structure of your files and directories inside the items property as a JavaScript list of objects and strings.
Specify files and placeholders
Add notes and comments
Specify folders and their state
<FileTree> props
Implementation: filetree.jsx
The <FileTree> component accepts the following props:
items (required)
type: FileTreeItem[]
Hierarchy of files and folders to display.
The FileTreeItem can be one of the following kinds:
...or…— both display a placeholder icon…indicating that a directory is expected to contain more items without specifying them all explicitly- any
string— name of the file inside the currently described directory { kind: "file", ...fields... }— an extended syntax for files, with the following fields:name: string— the filenamenote?: string— optional comment, which is displayed next to the filename
{ kind: "folder", ...fields... }— syntax for folders and directories, with the following fields:name: string— the directory namenote?: string— optional comment, which is displayed next to the directory nameopen?: boolean— whether to open the directory, defaults totrueitems: FileTreeItem[]— nested files and folders
open property is true unless specified otherwise.
defaultOpen
type: boolean default:
true
Whether to open all folders upon the page load. Can be overridden by the open property of the FileTreeItem entry.