OOratiq

Tree View

Ready

Nested, keyboard-navigable hierarchy.

  • app
  • layout.tsx
  • page.tsx
  • components
  • package.json

Installation

$ npx @oratiq-js/ui add tree-view

Copies the component and everything it depends on into your project, then lists the npm packages to install. The code is yours after this.

Usage

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

Keyboard

  • role=tree with aria-level/aria-expanded/aria-selected — announced as a real tree.
  • One tab stop (roving tabindex): Up/Down move; the arrow toward the reading direction expands or steps into children; the opposite one collapses or climbs to the parent — inverted automatically under RTL.
  • Enter/Space selects (and toggles branches); Home/End jump to the ends.
  • Indentation uses padding-inline-start and the chevron mirrors — the tree grows from the reading edge.

Props

PropTypeDefaultDescription
data*{ id, label, icon?, children? }[]The tree.
expanded / defaultExpandedstring[]Expanded branch ids (controlled / initial).
selected / onSelectedChangestringSelection (controlled).
showDefaultIconsbooleantrueFolder/file fallbacks when a node has no icon.

View source on GitHub → components/ui/tree-view.tsx