Skip to content
Nana UI

Tree Item

View .md Download

A single node in a nana-tree. Branch nodes nest further nana-tree-item elements in the default slot; leaf nodes have none. The label comes from the label attribute (or the label slot for rich content).

Terminal window
npm install @nana-tec/ui-components
import "@nana-tec/ui-components/tree-item";
<nana-tree style="width:100%">
<nana-tree-item label="Parent" icon="folder" expanded>
<nana-tree-item label="Child" icon="code"></nana-tree-item>
</nana-tree-item>
</nana-tree>

Properties

PropertyAttributeTypeDefaultDescription
badgestring | undefinedTrailing badge text.
disabledbooleanfalseDisabled — blocks selection, expansion, and keyboard interaction.
expandedbooleanfalseExpanded state of a branch node.
iconstring | undefinedLeading icon name (a `nana-icon` name).
labelstring''Plain-text label. Ignored when the `label` slot is used.
lazybooleanfalseTreat as a branch whose children load on first expand.
loadingbooleanfalseShow a loading spinner in place of the chevron.
selectedbooleanfalseSelected state (the tree controls this).

Events

EventDescription
nana-tree-item-toggleInternal: expanded state changed (handled by the tree).
nana-tree-item-activateInternal: row activated (handled by the tree).

Slots

SlotDescription
(default)Child `nana-tree-item` nodes.
labelRich label content (overrides the `label` attribute).

CSS parts

PartDescription
::part(item)The node row.
::part(chevron)The expand/collapse chevron.
::part(icon)The leading icon.
::part(label)The label.
::part(badge)The trailing badge.
::part(children)The nested children container.
EventTypeDescription
nana-tree-item-toggleCustomEventInternal: expanded state changed (handled by the tree).
nana-tree-item-activateCustomEventInternal: row activated (handled by the tree).
SlotDescription
(default)Child nana-tree-item nodes.
labelRich label content (overrides the label attribute).
PartDescription
itemThe node row (icon, label, and badge)
chevronThe expand/collapse chevron
iconThe leading icon
labelThe label
badgeThe trailing badge
childrenThe nested children container
Explore Tree Item interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook