Tree
Recursive expandable tree with roving-tabindex keyboard navigation, for file browsers and nested navigation. Each node takes an id, label, optional icon, and optional children.
Basic
Nodes with children render an expand/collapse toggle; leaf nodes don't.
- Arrow Right expands a node (or moves to its first child if already expanded); Arrow Left collapses it (or moves to its parent)
- Only one node is a Tab stop at a time - a roving tabindex, the same pattern Sidebar and Rating use
Default expanded
defaultExpandedIds pre-opens specific branches on first render, without making the tree controlled.
Controlled selection
selectedId plus onSelect drives the selected node from your own state - onSelect fires on click or Enter/Space while a node is focused.
When to use
- A file/folder browser or any genuinely nested, collapsible hierarchy the user navigates by drilling down.
- Nested navigation where parent/child relationships matter and the full structure benefits from being collapsible.
When not to use
- Flat navigation with no real hierarchy - use Sidebar, which is lighter and has no expand/collapse state to manage.
- A single level of grouped links - Sidebar.Section already groups without needing recursive nodes.
Keyboard
Mobile behavior
- Each node keeps a touch-friendly row height, and the expand/collapse toggle is part of the same tappable row rather than a separate small hit target.
Accessibility notes
- Follows the ARIA treeview pattern with a roving tabindex - only the focused node is a Tab stop.
- Expand/collapse state is exposed via aria-expanded on parent nodes.
Common mistakes
- Passing a new data array with different node identities on every render - keep the tree data stable (e.g. in state or a constant) so expanded/selected state doesn't reset unexpectedly.
- Using Tree for a flat list with no real parent/child relationship - Sidebar or List is simpler.
Known limitations
- No built-in drag-to-reorder, lazy/async node loading, or multi-select - selection is single-node via selectedId.
Related components
API reference
The roots of the tree.
`id`s expanded on first render. Expansion is uncontrolled from then on.
Whether selecting a parent node also toggles it. Default `true`. `false` (WAI-ARIA tree): select only; the chevron or ArrowRight/Left toggles. Use when a folder is itself selectable.
Fires when a tree node is activated (click, or Enter/Space while focused) - unrelated to the native `onSelect` text-selection event.
`id` of the selected node. Controlled - the tree does not track selection itself.
Also accepts everything from Omit<React.HTMLAttributes<HTMLDivElement>, "onSelect">.
Coding agents read this reference, with its examples, from the version your project has installed, through the Fuji UI MCP server. Set up your agent
