Calm motion: animations on this site only fade, with no movement
File tree
Files and folders from a flat list of paths
Shows the files of a project as folders that open and close, for example the files of an episode. You give a plain list of paths, and the component makes the folders. For a tree of any data, use the tree, which this component uses.
Basic
ep41
art
audio
video
Selected: ep41/audio/final.mp3
pathsis a list of paths such asaudio/ep41/raw.wav. Each part before a/is a folder. A path that ends in/is an empty folder.- Folders come first, then files, each in order of name. Each file has an icon for its type: image, audio, video, text, settings, archive, or other.
v-model:selectedis the path of the selected file or folder. The folders on the way to it start open.expandedopens every folder.- A click on a name emits
selectwith the path, and withtruefor a folder. - The keys are the keys of the tree: the up and down arrows move, the right arrow opens a folder, the left arrow closes it, and Enter selects.
labelnames the tree for screen readers.
Usage
ts
import { BlessFileTree } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
paths* | string[] | — | the files, each as a path such as `audio/ep41/raw.wav`; a path that ends in `/` is an empty folder |
expanded | boolean | — | open every folder, not only the folders of the selected file |
label | string | "Files" | |
selected | string | — | the path of the selected file or folder |
Events
| Name | Payload | Description |
|---|---|---|
select | [path: string, folder: boolean] | |
update:selected | [value: string | undefined] |