Ballmac UI home

Tree View

A keyboard-operable hierarchical tree with selection, expansion, and optional node icons.

Workspace
Overview
Analytics
Audience
Revenue
Settings
Help center

Installation

$ pnpm dlx shadcn@latest add @ballmac/tree-view

Usage

import { TreeView } from "@/components/ballmac/tree-view"

The full example is in the Code tab above.

Examples

States and variants

Guide
Getting started
API reference
Archived

API reference

PropTypeDefault
nodes*

Hierarchical nodes to display.

TreeNode[]—
label*

Accessible name for the tree.

string—
selectedId

Controlled selected node ID.

string—
defaultSelectedId

Initial selected node ID.

string—
onSelectedIdChange

Called when selection changes.

(id: string) => void—
expandedIds

Controlled expanded IDs.

string[]—
defaultExpandedIds

Initially expanded IDs.

string[][]
onExpandedIdsChange

Called when expansion changes.

(ids: string[]) => void—
renderIcon

Optional icon for each node.

(node: TreeNode, expanded: boolean) => React.ReactNode—

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
Arrow keys / Home / End / Enter / SpaceNavigates, expands, and selects nodes

Use with AI

A keyboard-operable hierarchical tree with selection, expansion, and optional node icons. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Tree View (@ballmac/tree-view) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Browse nested navigation or structured data

Not for

  • Use File Tree for folders and files

Registry JSON: https://ui.ballmac.com/r/tree-view.json

Credits

Free to use in personal and commercial projects.