Registry / Client component
Tree View
Hierarchical navigation with expansion, disabled nodes, selection and Arrow, Home, End, Enter and Space keyboard controls.
Installation
Preview
- src
- components
- button.tsx
- input.tsx
- archived.tsx
- app
- README.md
Selected: button
Usage
tsx
import { TreeView } from "@/components/ui/tree-view"
<TreeView defaultExpanded={["src"]} nodes={[
{ id: "src", name: "src", children: [
{ id: "page", name: "page.tsx" },
] },
]} />API reference
| Prop | Type | Default | Description |
|---|---|---|---|
nodes | TreeNode[] | — | Nested nodes with unique IDs, names, children and optional disabled state. |
value | string | — | Controlled selected node ID; selection is internal when omitted. |
onValueChange | (id: string) => void | — | Called on selection. |
defaultExpanded | string[] | [] | Initially expanded node IDs. |