Tree
A hierarchical list with keyboard navigation, expansion, and optional checkbox selection.
Usage
Use Tree for hierarchies such as folders, workloads, and nested navigation. Give each node a stable, tree-wide unique ID and a localized label. Use TreeItem when you need the visual row on its own.
import { Tree } from '@acronis-platform/ui-react';
<Tree
aria-label="Workloads"
defaultExpandedIds={['cloud']}
nodes={[
{ id: 'cloud', label: 'Cloud', children: [{ id: 'mail', label: 'Mail' }] },
{ id: 'local', label: 'Local' },
]}
/>;Expansion and activation
Use defaultExpandedIds and defaultActiveId for initial state. For controlled state, pass expandedIds with onExpandedIdsChange and activeId with onActivate. A branch row click activates the node and toggles expansion. Enter activates the focused node and can activate it again if it is already active. The active row scrolls into view when it changes or becomes visible after mount.
To load children on demand, set hasChildren: true on the branch and load the data in response to onExpandedIdsChange when its expanded flag becomes true. Supply the children through nodes when the request completes. If only some siblings are rendered, supply positionInSet and setSize for their positions in the full set.
Pass aria-busy while the tree's data is loading. With an empty nodes array, the root is a named group outside the tab order. It can temporarily hold focus after the focused row disappears and return focus to a row when data arrives.
Checkbox selection
Set selectionMode="multiple" and give each checkable node a checkState of true, false, or 'mixed'. Update your data in onCheckedChange. Checking a node is independent of activation and expansion. The active node is exposed as the current item to assistive technology. Derive parent check states and apply any rules for checking descendants in your application.
Keyboard navigation
Give the tree a localized aria-label or reference its visible heading with aria-labelledby. Tab moves into the tree once, then leaves it. Focus and selection are independent. Use display-only content for icon and extras to keep each row a single keyboard target.
| Key | Action |
|---|---|
| Up / Down | Move to the previous / next visible node. |
| Home / End | Move to the first / last visible node. |
| Right | Expand a closed branch or move to the first child of an expanded branch. |
| Left | Collapse an expanded branch or move to the parent. |
| Enter | Activate the focused node. |
| Space | Activate in single selection or toggle a checkbox in multiple selection. |
API reference
Prop
Type
Prop
Type