Skip to main content

Tree

Hierarchical tree view with expandable nodes.

Usage

<w-tree label="File browser">
<w-slot item name="folder1" expandable>
<div>
<span>Documents</span>
<w-slot item name="file1"><div>Report.pdf</div></w-slot>
<w-slot item name="file2"><div>Notes.txt</div></w-slot>
</div>
</w-slot>
<w-slot item name="folder2" expandable>
<div>
<span>Images</span>
<w-slot item name="img1"><div>Photo.jpg</div></w-slot>
</div>
</w-slot>
</w-tree>

Props

PropTypeDefaultDescription
valuestring""Selected item name
expandedstring""Comma-separated expanded item names
labelstring""Accessible label

Slots

SlotElementDescription
itemContainerTree item (use name, optionally expandable)

Events

EventDetailDescription
change{ value }Selection changed
expand{ item, expanded }Item expanded/collapsed

Keyboard

KeyAction
ArrowDownNext visible item
ArrowUpPrevious visible item
ArrowRightExpand or move to first child
ArrowLeftCollapse or move to parent
HomeFirst item
EndLast visible item
Enter / SpaceSelect item

Accessibility

  • Container has role="tree"
  • Items have role="treeitem" with aria-level
  • Expandable items have aria-expanded
  • aria-selected for selection state