Registry / Client component

Tree View

Hierarchical navigation with expansion, disabled nodes, selection and Arrow, Home, End, Enter and Space keyboard controls.

Installation

Preview

Preview style
  • src
    • components
      • button.tsx
      • input.tsx
      • archived.tsx
  • 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

PropTypeDefaultDescription
nodesTreeNode[]—Nested nodes with unique IDs, names, children and optional disabled state.
valuestring—Controlled selected node ID; selection is internal when omitted.
onValueChange(id: string) => void—Called on selection.
defaultExpandedstring[][]Initially expanded node IDs.