TreeView pattern presents hierarchical data in a tree-like structure, where parent nodes can expand to reveal child nodes.
sm, md, lg and responsive and can be changed by passing the size prop.lg.responsive, the component will be responsive to the viewport.Screen prefix | Screen width | Component size |
|---|---|---|
|
| sm |
|
| md |
|
| lg |
TreeView can be disabled by setting disabled prop to true in component TreeView.TreeItem can be disabled by setting disabled prop to true in component TreeItem.TreeItem is disabled, all its children will be disabled.default and branch-line and can be changed by passing the variant prop.default.TreeItem supports prefix and suffix props to add content before and after the label.open stateTreeItem supports defaultOpen prop to set the initial open state of the branch.true.TreeItem supports open and onOpenChange props to control the open state of the branch.Selectable TreeViewTreeView can turn to selectable tree by using the selectable prop.false.Ctrl (or ⌘ Command on macOS) and click the items.Shift key while clicking on the last item of the range.onSelectedItemsChange prop can be used to handle the selected items change.const TreeItems data we using for these examples:TreeItem can have a selected prop to indicate the selected state of the item.TreeItem supports the item prop with type TreeOption.TreeOption can have multiple properties and can be used to pass additional data.TreeItemCheckType, TreeOption, TreeItemWithSelection we using for these examples:TreeView supports onItemClick prop to handle the click event on the TreeItem.TreeView can be used to display a list of items in a tree structure with checkboxes.TreeView is a regular ul[role="tree"] follow WAI-ARIA recommendations.
TreeView has role="tree".TreeItem has role="treeitem".TreeItem has div[role="group"] element that contains all it children TreeItem.TreeItem has aria-expanded="true" when it is open and aria-expanded="false" when it is closed.TreeItem elements in TreeView are focusable, but only one is included in the tab sequence and has tabindex="0".Key | Function | Condition |
|---|---|---|
| Moves focus to the next node that is focusable without opening or closing a node. | When the any |
| Moves focus to the previous node that is focusable without opening or closing a node. | When the any |
| - When focus is on a closed node, opens the node; focus does not move. | When the any |
| - When focus is on an open node, closes the node. | When the any |
| Moves focus to the first node in the tree without opening or closing a node. | When the any |
| Moves focus to the last node in the tree that is focusable without opening a node. | When the any |