Skip to content
Nana UI

Tree

View .md Download

A hierarchical list for file systems, navigation, and any parent-child data. Compose nana-tree-item nodes inside it. Implements the ARIA tree pattern: roving tabindex, arrow-key navigation, type-ahead, and Home/End/* support.

Parent Child one Child two
Terminal window
npm install @nana-tec/ui-components
import "@nana-tec/ui-components/tree";
<nana-tree style="width:100%">
<nana-tree-item>
Parent
<nana-tree-item>Child one</nana-tree-item>
<nana-tree-item>Child two</nana-tree-item>
</nana-tree-item>
</nana-tree>

Properties

PropertyAttributeTypeDefaultDescription
labelstring''Accessible name for the tree.
selectionTreeSelection'single'Selection behaviour.
sizeTreeSize'default'Density scale.

Events

EventDescription
nana-selection-changeSelection changed (`detail.selection`).
nana-expandA branch expanded (`detail.item`).
nana-collapseA branch collapsed (`detail.item`).

Slots

SlotDescription
(default)The top-level `nana-tree-item` nodes.

CSS parts

PartDescription
::part(base)The tree container.

CSS custom properties

PropertyDescription
--nana-tree-indentIndent step per depth level.
--nana-tree-row-heightNode row height.
--nana-tree-connectorConnector line colour.
EventTypeDescription
nana-selection-changeCustomEventSelection changed (detail.selection).
nana-expandCustomEventA branch expanded (detail.item).
nana-collapseCustomEventA branch collapsed (detail.item).
SlotDescription
(default)The top-level nana-tree-item nodes.
VariableDefaultDescription
--nana-tree-indentIndent step per depth level.
--nana-tree-row-heightNode row height.
--nana-tree-connectorConnector line colour.
PartDescription
baseThe tree container
  • Keyboard accessible
  • Screen-reader labels
  • Focus-visible states
  • ARIA roles and states
  • WCAG 2.2 AA contrast
Explore Tree interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook