CarsXE

Search docs

Search pages, components, and skills.

Tree view

A hierarchical list with keyboard navigation. It selects one node, several nodes, or cascades checkboxes with a derived mixed state; filters with a debounced search field in either lenient or strict mode; loads children on demand; templates each row; and reorders by dragging.

Installation

Import from the package. Do not run shadcn add in your app.

tsx
import { TreeView } from "@carsxe/design-system/components/tree-view"

Usage

tsx
import { TreeView } from "@carsxe/design-system/components/tree-view"

<TreeView
  aria-label="API catalog"
  items={catalog}
  defaultExpanded={["vehicle"]}
  defaultValue={["specs"]}
/>

Cascading checkboxes

1 checked. A branch shows a dash while only some of its children are checked.

Filtering

Strict filtering

Lazy children

Row template

Expand and collapse all

Drag and drop

Drag a row onto the top or bottom edge of another to reorder it, or onto its middle to nest it.

API Reference

PropTypeDefault
itemsTreeViewItem[]—
valuestring[]—
defaultValuestring[][]
onValueChange(value: string[]) => void—
expandedstring[]—
defaultExpandedstring[][]
onExpandedChange(value: string[]) => void—
selectionMode"single" | "multiple" | "checkbox""single"
multiplebooleanfalse
filterstring—
defaultFilterstring""
onFilterChange(filter: string) => void—
showFilterbooleanfalse
filterDelaynumber300
filterMode"lenient" | "strict""lenient"
emptyMessageReactNode—
onExpand(item: TreeViewItem) => void | Promise<void>—
renderItem(item: TreeViewItem, state: TreeViewItemState) => ReactNode—
dragAndDropbooleanfalse
onItemsMove(details: TreeViewMoveDetails) => void—
disabledbooleanfalse