Tree View

Keyboard-first WAI-ARIA tree with spring-rotating chevrons, height-morphing nested groups, indent guide lines, a selection pill that glides between rows via shared layout, typeahead, and controlled or uncontrolled selection and expansion.

Preview

Tree View preview width

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @karaui/tree-view
@karaui not found? Add it to components.json
{
  "registries": {
    "@karaui": "https://karaui.kamisama-v0.my.id/r/{name}.json"
  }
}

@karaui is in shadcn's public registry directory, so the latest CLI needs no setup. On an older CLI, merge this into the existing file once and every @karaui/… install resolves.

API Reference

nodes
TreeNode[]
—
value?
string | null

Selected node id (controlled).

—
defaultValue?
string | null
null
onValueChange?
((id: string | null, node: TreeNode | null) => void)
—
expanded?
string[]

Expanded node ids (controlled).

—
defaultExpanded?
string[]
[]
onExpandedChange?
((expanded: string[]) => void)
—
indent?
number

Horizontal indent per level, px.

16
guides?
boolean

Show vertical guide lines for nested groups.

true
aria-label?
string
—
aria-labelledby?
string
—
className?
string
—

Updated