Tree view

Navigates a hierarchy with expansion, single selection, and roving focus.

  • Studies
    • Drive
    • Orbit
  • Archive
  • Studies
    • Drive
    • Orbit
  • Archive

Use it for

  • File trees, nested assets, and hierarchical selection.

Not for

  • A flat list of destination links; use Sidebar.

Three ways in. They share one source, so the pixels match whichever you pick.

1. Import the package

npm install @noorddev/vlak-react

// once, next to your app's root
import "@noorddev/vlak-react/css";

import { TreeView } from "@noorddev/vlak-react";

Precompiled React and one stylesheet. No compiler to configure. Per-component imports work too: @noorddev/vlak-react/components/tree-view.

2. Vendor the source

npx @noorddev/vlak-cli add tree-view

The StyleX leaf lands in components/vlak/ with its dependencies, for your own compiler to own. See StyleX.

3. Through shadcn

npx shadcn add https://vlak.dev/r/tree-view.json

The same registry item, installed by shadcn's CLI.

CSS only

<link rel="stylesheet" href="node_modules/@noorddev/vlak/css/vlak.css" />

No React. Link vlak.css and use the markup and classes below.

import { TreeView } from "@noorddev/vlak-react";

<TreeView label="Studies" defaultExpanded={["studies"]} defaultValue="drive" nodes={[{ id: "studies", label: "Studies", children: [{ id: "drive", label: "Drive" }, { id: "orbit", label: "Orbit" }] }, { id: "archive", label: "Archive" }]} />

TreeView

Single selection and APG-style roving focus through a hierarchical collection.

PropTypeDefaultDescription
nodesrequiredTreeNode[]
labelrequiredstring
valuestring
defaultValuestring
onValueChange(value: string) => void
expandedstring[]
defaultExpandedstring[][]
onExpandedChange(ids: string[]) => void

Also accepts Omit<HTMLAttributes<HTMLUListElement>, "defaultValue" | "onSelect">.

KeysDoes
Arrows, Home, End, Enter, Space, lettersArrows navigate and expand/collapse; Enter or Space selects; typing finds a visible label.
<ul class="rs-tree-view" role="tree" aria-label="Studies"><li role="none"><div class="rs-tree-view-item rs-tree-view-selected" role="treeitem" aria-selected="true" aria-level="1" tabindex="0">Drive</div></li></ul>
.rs-tree-view.rs-tree-view-group.rs-tree-view-item.rs-tree-view-selected.rs-tree-view-disabled.rs-tree-view-spacer.rs-tree-view-disclosure.rs-tree-view-label