Tree
Shows nested items that you can expand, collapse, and select.
Installation
The CLI adds the files, packages, theme variables, and Tailwind plugin that this component uses. Before you run it, set up your project.
Composition
TreeOwns selection, expanded rows, and drag and drop.
TreeSectionOptionalRepeatsTreeHeader
TreeItemRepeatsPut child TreeItem elements inside it to make it expandable.
TreeLoadMoreItemOptional
TreeDropIndicator Return it from renderDropIndicator in useDragAndDrop.
Custom row content
Typeahead still uses title.
Checkbox selection
selectionMode="multiple" adds a checkbox to each row. A disabled row cannot be selected. Also install Checkbox.
Sections
Drag and drop
Drop a row on a folder to move it into the folder. To move a row with the keyboard, press Right Arrow to go to the handle, press Enter, then use the arrow keys.
API reference
vip/ui adds or changes the props below. For all other props, see React Aria Tree (opens in a new tab).
TreeItem
- title: stringRequired
- The row label. Typeahead uses it unless you set textValue.
- content: ReactNode
- Replaces the visible label. Without it, the row shows title. Use it to add details, such as a file size.
- icon: ReactNode
- Replaces the default icon. A row with child items shows a folder. Other rows show a file.
- children: ReactNode
- Nested TreeItem elements. A row with children shows an expand button.
- textValue: string
- Text for typeahead when it must be different from title.