Components · Navigation
Tree View
A keyboard-friendly hierarchy (ARIA tree) with lazy children and tri-state checkboxes.
import { TreeView } from '@nexub/react';Playground
Props
- Engineering
- Web
- Ada Lovelace
- Alan Turing
- Mobile
- Design
Selected: ada
<TreeView aria-label="Teams" nodes={nodes} defaultExpanded={['eng', 'web']} selected={selected} onSelectedChange={setSelected} onLoadChildren={load} />Examples
Lazy loading and selection
Checkboxes
Actions, meta, links and scrollToNode
States
- Engineering
- Web
- Ada Lovelace
- Alan Turing
- Mobile
- Design
Selected: ada
defaultSelected: ada
loading
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| nodesrequired | TreeNode[] | — | { id, label, textValue?, icon?, children?, hasChildren?, disabled?, trailing?, href? }. trailing (11.5) is meta at the row end, e.g. a count or a date. href (11.5) makes the row a link: click and Enter follow it, Cmd/Ctrl-click and middle-click open a new tab. |
| aria-label | string | — | Names the tree. |
| aria-labelledby | string | — | Names the tree. |
| expanded | string[] | — | Open node ids. |
| defaultExpanded | string[] | — | Open node ids. |
| onExpandedChange | ((ids: string[]) => void) | — | Open node ids. |
| selected | string | — | Single selection, set by click, Enter or Space. |
| defaultSelected | string | — | Single selection, set by click, Enter or Space. |
| onSelectedChange | ((id: string) => void) | — | Single selection, set by click, Enter or Space. |
| onActivate | ((node: TreeNode) => void) | — | 11.5. Opens a node: Enter or double-click. Separate from selection, which click and Space set (Enter selects too). Disabled nodes never activate. |
| renderActions | ((node: TreeNode) => React.ReactNode) | — | 11.5. Row actions, shown on hover and focus and always on touch screens. Their space is always reserved, so rows never shift. Tab from the focused row reaches them; the item is named by its label and trailing only. |
| ref | React.Ref<TreeViewHandle> | — | 11.5. scrollToNode(id, { focus? }) opens the node's ancestors, then scrolls its row into view (and focuses it). |
| checkable | boolean | false | Checkboxes instead of selection. A parent is checked when all its children are and mixed when some are. |
| checked | string[] | — | Every checked id, parents included. |
| defaultChecked | string[] | — | Every checked id, parents included. |
| onCheckedChange | ((ids: string[]) => void) | — | Every checked id, parents included. |
| onLoadChildren | ((node: TreeNode) => Promise<unknown>) | — | Called when a hasChildren node without children opens. Load them and pass the new nodes; the item is aria-busy meanwhile. |
| className | string | — | |
| emptyState | React.ReactNode | — | Shown when there is no data. Defaults to the "no data" message. |
| errorState | React.ReactNode | — | Shown in place of the data when a load failed, for example an ErrorState with a retry action. Wins over loading and empty. |
| loading | boolean | — | Shows a skeleton in place of the data and sets aria-busy. |
Accessibility
ARIA roles
Keyboard
- ArrowDown / ArrowUp
Next or previous visible item.
- ArrowRight
Opens a closed item, or moves to its first child. Mirrored in RTL.
- ArrowLeft
Closes an open item, or moves to its parent. Mirrored in RTL.
- Home / End
First or last visible item.
- Enter
Selects the item (or toggles its checkbox), calls `onActivate` and follows a link node.
- Space
Selects the item, or toggles its checkbox.
- Tab
From the focused item to its row actions (`renderActions`), then out of the tree.
- Type a letter
Moves to the next item starting with the typed text.
Focus
The tree is one tab stop (roving tabindex); it returns to the last focused or the selected item.
On iOS & Android: TreeList
import { TreeList } from '@nexub/react-native';
<TreeList rootTitle="Teams" nodes={teams} selected={picked} onSelect={setPicked} />Web vs mobile
Same tokens and prop names. Where the platforms differ:
| Web | iOS & Android | |
|---|---|---|
| Layout | An indented tree; Arrow keys open and close. | Drill-down lists with a back row: one level at a time. |
Interactive preview of @nexub/react-native rendered for the web. Native chrome (switches, pickers, Liquid Glass) looks like the platform on a device.
On device

iPhone (iOS simulator)

Pixel (Android emulator)
Screenshots from the latest CI run of the showcase app; the live frame renders the same code for the web.
TreeList props
| Prop | Type | Default | Description |
|---|---|---|---|
| nodesrequired | TreeListNode[] | — | — |
| rootTitlerequired | string | — | Title of the top level, shown on the back row from the first level down. |
| selected | string | null | — | The picked leaf (controlled). Ignored when checkable. |
| defaultSelected | string | null | — | The leaf picked at first, when selected is not controlled. |
| onSelectedChange | (id: string | null) => void | — | Called with the picked leaf's id. |
| onSelect | (id: string) => void | — | Called with the picked leaf's id (the same moment as onSelectedChange). |
| expanded | string[] | — | The open levels (controlled): ids of the nodes drilled into, from the top. On web these are the expanded nodes; on a phone one branch is open at a time. |
| defaultExpanded | string[] | — | The levels open at first, when expanded is not controlled, e.g. to start inside a branch. |
| onExpandedChange | (ids: string[]) => void | — | Called with the open levels when someone drills in or goes back. |
| checkable | boolean | false | Checkboxes instead of single selection. A parent is checked when all its children are, mixed when some are. |
| checked | string[] | — | Every checked id, parents included (controlled). |
| defaultChecked | string[] | — | The ids checked at first, when checked is not controlled. |
| onCheckedChange | (ids: string[]) => void | — | Called with every checked id, parents included, after each change. |
| onLoadChildren | (node: TreeListNode) => Promise<unknown> | — | Loads a hasChildren node's children when it is opened; pass them in through nodes.
A loading row shows until the promise settles. |
| onActivate | (node: TreeListNode) => void | — | Called when a leaf is tapped, after it is selected (or checked). On web, Enter or a double-click opens a node; on a touch screen the tap is the open. |
| renderActions | (node: TreeListNode) => React.ReactNode | — | Actions at the end of each row, e.g. an IconButton. They are their own screen-reader elements. |
| loading | boolean | — | Shows skeleton rows in place of the tree and marks it busy for screen readers. |
| emptyState | React.ReactNode | — | Shown when nodes is empty. Defaults to the "no data" message. |
| errorState | React.ReactNode | — | Shown in place of the tree when a load failed, e.g. an ErrorState with a retry. Wins over loading and empty. |
| style | StyleProp<ViewStyle> | — | — |