Tree
An unstyled hierarchical tree view with single selection, branch expansion, RTL keyboard navigation, and scoped ARIA relations.
An unstyled tree view for explicit hierarchical data, supporting single selection, branch expansion and collapse, direction-aware keyboard navigation, and automatically cleaned up ARIA relationships.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases.
Compose Root, Item, Group, and Toggle:
- Keys and branch hierarchy: Each node declares a tree-unique
nodeKeyand optionalparentKey(duplicate keys, missing parents, and cycles are ignored without corrupting valid state). Give eachTreeGroupthe samenodeKeyas its owning branchItemand place child items inside it withparentKeypointing to that branch. - Keyboard navigation and RTL:
ArrowUp/ArrowDown,Home/End, and typeahead move focus in logical visible order. In LTR mode,ArrowRightexpands or enters a child andArrowLeftcollapses or returns to the parent; settingdirection="rtl"swaps horizontal keys automatically (and styled group indentation follows writing direction). - Collapse and focus safety: Scoped
aria-controlsandaria-labelledbylinks betweenItemandGroupare maintained and cleaned up automatically. Collapsing a branch hides itsGroupwhile preserving the hierarchy; if focus was inside the collapsed branch, focus moves to the nearest visible ancestor without disturbing focus outside the tree. - Controlled and read-only: Pass
valueorexpandedKeysfor controlled mode.readOnlyblocks selection changes while keeping navigation and expansion enabled. Adding, moving, or removing items updates the hierarchy without emitting synthetic user selection events.
| Prop | Type | Default |
|---|---|---|
defaultValue | string | '' |
defaultExpandedKeys | readonly string[] | [] |
direction | 'ltr' 'rtl' | ltr |
disabled | boolean | false |
readOnly | boolean | false |
a11yLabel | string | Tree |
Pass value or expandedKeys to control selection or expanded branches.
Part Props
Section titled “Part Props”- Item:
nodeKey(default''),parentKey(default''),textValue(default''),disabled(defaultfalse). - Group:
nodeKey. - Toggle: Also accepts
Buttonprops.