Tree View

Hand-composed hierarchy for sidebars, pickers, and file lists where you control every row.

Wrap rows in nested TreeItem components with TreeItemLayout slots. Bind TreeExpansion and TreeSelection with Leptos signals for open and selected ids. When items come from an API, lazy loading, or virtualization, use RichTree instead — same selection and expansion APIs, data adapters instead of nested components.

  • Hand-authored hierarchies with custom slots (icons, aside actions, motion)
  • Sidebars and pickers where item count is modest
  • Full control over row layout via TreeItemLayout
  • Wrap rows in Tree + nested TreeItem components.
  • Bind TreeExpansion::open_items for controlled expand/collapse.
  • Choose TreeSelection mode (single, multi, checkbox, or none).
Default nested tree

Branch pre-expanded via open_items; nested leaf under Documents.

Documents
readme.md
Small size

Compact row height for dense sidebars.

Item
Deep nesting

Three-level branch chain demonstrates nested subtrees.

Level 1
Level 2
Level 3
Click to expand

Starts collapsed; clicking the branch toggles open_items.

Flat leaf list

All leaves — no chevrons.

One
Two
Single selection

Click rows to select one item at a time.

Alpha
Beta
Theme surfaces

Items use theme background tokens.

Themed row
Icons and aside actions

Leading icon, trailing badge, and hover-revealed aside actions.

📁
Documents
3
readme.md
Multi selection (ctrl + shift)

Ctrl/Meta toggles; Shift selects a visible range.

Alpha
Beta
Gamma
Checkbox selection with cascade

Parent checkbox selects descendants when cascade is enabled.

Root
Child
Disabled items (focusable)

Disabled rows remain focusable for screen-reader access.

Enabled
Disabled
Icon-container expansion

Only the chevron toggles expansion; row click selects.

Expand / collapse all

External button uses TreeApiRef to toggle every branch.

Connector borders

Indentation guide lines between levels.

Root
Leaf
Focus via button

Imperative focus through TreeApiRef::focus_item.

Target row
Keyboard navigation

Arrow keys move focus; typeahead jumps to matching labels.

Alpha
Beta
Inline editing

Double-click or Enter on a focused row edits the label.

Rename me
Drag reorder

Pointer drag reorders siblings when reorderable is enabled.

One
Two
Custom collapse motion

Override the CSS transition name via TreeItemCollapse.