Composables
ComposableOriginal

Tree

A hierarchical tree view component with support for selection, expansion, checkboxes, and keyboard navigation.

The tree displays nested data as an expandable hierarchy with selection, checkboxes, and keyboard navigation. Use it for file explorers, nav menus, category pickers, or any parent-child structure. It renders each node through a child function, so you control the markup of every row.

Preview

Resume.pdf
Cover Letter.pdf
Music.mp3

Installation

Usage

Composition

Tree takes a data array and a child function that returns a TreeItem for each node. Compose the row from TreeItemIcon, TreeItemLabel, and TreeItemBadge.

Examples

Variants

Use variant to set the tree's surface treatment.

Default

Filled

Outline

ValueDescription
defaultMinimal styling, no container.
filledCard-like with a background.
outlineBordered card with a shadow.

With Icons

Set icon on a node and iconOpen for a different icon while it is expanded.

With Lines

Use showLines to draw connecting lines between parent and child nodes.

Button.tsx
Input.tsx

With Badges

Set badge on a node and render it with TreeItemBadge.

Report.pdfDraft
Proposal.pdfFinal
ArchiveOld

With Checkboxes

Use mode="multiple" to add checkboxes; parent state reflects child selection automatically.

DocumentsNew
Work2
Report.pdf
Proposal.pdf
Families.jpg

Controlled State

Use expanded/onExpandedChange and selectedNode/onNodeSelect to drive state externally.

Expanded: features
Selected: None

Disabled & Loading States

Set disabled or loading on individual nodes, or mode="none" for a read-only tree.

Document.pdf
Image.jpg
Secret.pdf
Confidential.pdf
File.pdf
Disabled File.pdf
Loading File.pdf

Async Loading

Use onLoadChildren on a node to fetch children on first expand; the tree shows a spinner and caches the result.

Readme.txt

Accessibility

The tree is operable from the keyboard: arrow keys move between and expand/collapse nodes, and Enter or Space selects. Selection and expansion state are reflected via aria attributes on each node, and disabled nodes are skipped during navigation.

API Reference

The Tree component is built with Base UI's Collapsible internally for expand/collapse functionality. All Collapsible props are supported on tree nodes. The documentation below only covers custom props specific to our Tree implementation.

For the complete Base UI Collapsible API, see the Base UI Collapsible documentation.

Props

Tree

Hierarchical view for displaying nested data with selection and expansion. Uses Base UI's Collapsible internally.

Prop

TreeNode Interface

TypeScript interface defining the shape of each tree node:

Prop