Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Tree View

ProNew

A hierarchy you can open, close and select from, with one Tab stop and full arrow-key navigation.

Installation

pnpm dlx shadcn@latest add @viewport/tree-view

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
nodes*TreeNode[]—
label*string

Accessible name for the tree, e.g. "Folders".

—
selectedstring

The id of the selected node.

—
defaultSelectedstring—
onSelect(id: string) => void—
defaultExpandedstring[]

Ids of the nodes that start open.

[]
classNamestring—

Accessibility

  • The tree pattern: Up and Down move, Right opens or steps in, Left closes or steps out.
  • Home, End and typing a letter jump between rows.
  • Each row states its level, position and whether it is open.
  • Respects prefers-reduced-motion.