Get StartedComponentsStylingThemingMath & Science
MCP

Data

Tree View

A hierarchical list that can be expanded and collapsed. It ships unstyled on purpose: you decide what a folder and a file look like inside TreeView.Node render.

Want folder and file icons without writing the render function? Use File Tree, a ready-made layer on top of this component.

Markdown

Import

tsx
import { TreeView, createTreeCollection } from "@indoku/ui"

Anatomy

TreeView.Root (collection)├─ TreeView.Label└─ TreeView.Tree   └─ TreeView.Node (render)      ├─ TreeView.BranchControl      folders      │  ├─ TreeView.BranchIndicator  chevron, rotates when open      │  └─ TreeView.BranchText      └─ TreeView.Item               files         └─ TreeView.ItemText

Examples

Without icons

The minimal version: text only. Folders show no indicator at all unless you add one.

Files

src
index.ts
package.json
README.md

With icons

nodeState.expanded tells you whether a folder is open, so you can swap the closed and open folder icons. The chevron goes inside TreeView.BranchIndicator, which rotates it for you.

src
index.ts
package.json
README.md

Controlled

Drive expansion and selection from your own state, for example to add expand-all and collapse-all buttons. tree.getBranchValues() returns every folder id.

src
index.ts
package.json
README.md

Selected: none

Accessibility

  • Follows the WAI-ARIA tree view pattern: role="tree" and treeitem, with aria-expanded on folders.
  • Arrow keys move between nodes and expand or collapse folders, Home and End jump to the first and last node, Enter or Space selects.
  • Icons are decorative. Keep the text in BranchText and ItemText so screen readers can announce each node.

Notes

  • Every node needs a unique id. It is the value used by expandedValue and selectedValue.
  • Icons you add are plain children, so they are not part of the theme: size them yourself (the Icon component or the boxSize prop on SVGs).

Created by @indokudev