Component
A hierarchical data display component. Nest Tree.Item elements to represent folder structures, file trees, or any recursive data.
View component changelogModel large trees as collapsed branches and keep each node's label stable.
Tree only mounts a branch group while its parent item is expanded, so deep file trees can defer most child nodes until users open that branch.
| Shortcut | Description |
|---|---|
Tab | Moves focus into the tree and onto the current roving tree item. |
ArrowDown | Moves focus to the next visible tree item. With loop enabled, focus wraps from the last visible item to the first. |
ArrowUp | Moves focus to the previous visible tree item. With loop enabled, focus wraps from the first visible item to the last. |
ArrowRight | Expands a collapsed parent item. When the parent is already expanded, moves focus to its first child. |
ArrowLeft | Collapses an expanded parent item. From a collapsed child or leaf item, moves focus back to the parent item. |
Home | Moves focus to the first visible tree item. |
End | Moves focus to the last visible tree item. |
Enter | Runs onToggleSelect for the focused item when selection is controlled by the consumer. |
| Reference | What Rad UI follows |
|---|---|
Tree.Root renders role="tree"; each Tree.Item renders role="treeitem", parent branches render role="group", expandable parents expose aria-expanded, and consumer-managed selection is reflected with aria-selected. |
Import all parts of the component and piece them together
A single tree node rendered from an item object.
| Prop | Type | Default |
|---|---|---|
item* | { label: string; expanded?: boolean; items?: object[] } | -- |
level | number | 0 |
isSelected | boolean | false |
getIsSelected | (item) => boolean | -- |
onToggleSelect | (id, item) => void | -- |
className | string | "" |