Skip to content
aq-ui
Back to ComponentsComponent

Tree View

Keyboard-navigable hierarchical view with selection, expansion, typeahead, and controlled state.

Preview

This is a live example. Interact with the available controls and use the keyboard to inspect the component's states and behavior.

Loading interactive preview…

Installation

pnpm dlx aq-ui@alpha add tree-view

API reference

Client module

Import the parts you need, then jump to an export for its contract.

View full source

Quick start

"use client"

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

<TreeView />

TreeView

constSource L49

Keyboard-navigable hierarchical view with selection, expansion, typeahead, and controlled state.

const TreeView = React.forwardRef<HTMLDivElement, TreeViewProps>(…)
Props type
TreeViewProps
<TreeView />

TreeViewNode

interfaceSource L14

Type contract for TreeViewNode.

interface TreeViewNode

Members

NameType
idstring
labelstring
children?TreeViewNode[]
disabled?boolean
icon?React.ReactNode

TreeViewProps

interfaceSource L30

Type contract for TreeViewProps.

interface TreeViewProps extends Omit<React.ComponentProps<"div">, "onSelect">

Members

NameTypeDefault
itemsTreeViewNode[]—
selectedIds?string[]—
defaultSelectedIds?string[][]
onSelectedIdsChange?(ids: string[]) => void—
expandedIds?string[]—
defaultExpandedIds?string[][]
onExpandedIdsChange?(ids: string[]) => void—
multiple?booleanfalse
draggable?booleanfalse
onMove?(event: { sourceId: string targetId: string position: "inside" }) => void—
renderLabel?(node: TreeViewNode) => React.ReactNode(node) => node.label
emptyMessage?React.ReactNode"No items."

Registry dependencies

use-merged-refs, utils

Package dependencies

lucide-react@^1.31.0

Files

  • components/ui/tree-view.tsx

Source