Skip to content

Tree

Shows nested items that you can expand, collapse, and select.

Design
Wireframes.fig
Palette.pdf
Notes.md
tree-basic-demo.tsx

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

  • Tree

    Owns selection, expanded rows, and drag and drop.

    • TreeSectionOptionalRepeats
      • TreeHeader
    • TreeItemRepeats

      Put child TreeItem elements inside it to make it expandable.

    • TreeLoadMoreItemOptional

TreeDropIndicator Return it from renderDropIndicator in useDragAndDrop.

Custom row content

Typeahead still uses title.

Design
Wireframes.fig
Palette.pdf
README.md12 KB
tree-demo.tsx

Checkbox selection

selectionMode="multiple" adds a checkbox to each row. A disabled row cannot be selected. Also install Checkbox.

Foundations
Tokens.json
Type scale.md
Components
Buttons.tsx
Fields.tsx
Legacy grid.tsx
2 selected
tree-selection-demo.tsx

Sections

Favorites
Roadmap
Weekly metrics
Projects
Marketing site
Home page.md
Pricing.md
tree-sections-demo.tsx

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.

Drafts
Introduction.md
Setup.md
Published
FAQ.md
Changelog.md
tree-drag-demo.tsx

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.