navigation — wyrd.component.tree-view

TreeView

Single-select hierarchical tree derived from flat ordered item data.

Install @wyrd-company/react or the Flutter package and use it directly — your DESIGN.md does the styling.

01

Examples

Generated from the contract's examples block. Previews are the published @wyrd-company/react component, themed by the brand's role tokens — flip the site's light/dark toggle and they follow.

Code target Applies to every example on component pages.
file-explorer state: expanded
Usage
import { WyrdTreeView } from "@wyrd-company/react";

<WyrdTreeView label="Project files" defaultExpandedValues={["src","components"]} defaultSelectedValue="button" items={[{"label":"src","value":"src"},{"label":"components","value":"components","parent-value":"src"},{"label":"Button.tsx","value":"button","parent-value":"components","href":"/docs/components/button"},{"label":"Dialog.tsx","value":"dialog","parent-value":"components"},{"label":"package.json","value":"package"}]} />

// events: onExpandedChange, onSelectionChange, onNavigationRequest
disabled-item state: disabled
  • src
  • generated
  • index.ts
Usage
import { WyrdTreeView } from "@wyrd-company/react";

<WyrdTreeView label="Project files" defaultExpandedValues={["src"]} items={[{"label":"src","value":"src"},{"label":"generated","value":"generated","parent-value":"src","disabled":true},{"label":"index.ts","value":"index","parent-value":"src"}]} />

// events: onExpandedChange, onSelectionChange, onNavigationRequest
02

Properties

NameTypeDefaultSummary
label string undefined Accessible name for the tree.
items array Flat ordered tree item data. Items without parent-value are roots; parent records must appear before child records.
expanded-values array undefined Controlled expanded parent values.
default-expanded-values array Initial uncontrolled expanded parent values.
selected-value string undefined Controlled selected item value.
default-selected-value string undefined Initial uncontrolled selected item value.
03

Slots & events

EventPayloadSummary
expanded-change expanded-values Emitted with the full new expanded value set after expansion state changes.
selection-change value Emitted when the user selects an enabled tree item.
navigation-request value, href Emitted when the user activates a tree item with a navigation destination.
04

Tokens

The contract's token bindings. Open the shared contextual sidebar from any example; primary swatches reflect the color you pick there. Error swatches show the active preset's values; editing any knob switches to custom and resets error to TWW · Ink.

BindingToken
item.foreground color.on-surface
item.background color.surface
item.selected-background color.primary
item.selected-foreground color.on-primary
item.hover-background color.secondary
item.indent spacing.lg
chevron.color color.on-surface
05

States

StateSourceSummary
default platform Tree collection is visible.
expanded property One or more parent items are expanded.
selected property One tree item is selected.
focus-visible platform Keyboard-visible focus state on a tree item.
disabled property Disabled item state.
06

Accessibility

From the contract's accessibility obligations. Role tree; Label property provides the required accessible name.

  • ArrowDown moves focus to the next visible enabled item.
  • ArrowUp moves focus to the previous visible enabled item.
  • ArrowRight expands a focused collapsed parent, or moves to its first visible child when already expanded.
  • ArrowLeft collapses a focused expanded parent, or moves focus to its parent.
  • Home and End move focus to the first and last visible enabled item.
  • Enter and Space select the focused enabled item.
  • Web projections use ul/li tree structure with role=tree, role=treeitem, group containers, aria-level, aria-setsize, aria-posinset, aria-selected, and aria-expanded only on parent items.
  • Disabled items render but are skipped by roving tabindex and cannot be selected.
  • Navigable web items expose native anchors so standard link actions remain available.
  • Selection does not auto-expand ancestors in v1.
  • Flutter exposes expanded and selected flags through Semantics and renders visible rows as an indented flattened list.
  • Verified under: rtl, reduced-motion, cvd-deuteranopia, density-compact, text-expansion.
07

SDUI

Status: serializable. TreeView serializes a flat ordered item array. Hosts derive the hierarchy at runtime, preserve sibling order, and treat dangling parent references as root items.

SerializableMembers
Propertieslabel, items, expanded-values, default-expanded-values, selected-value, default-selected-value
Slots
Eventsexpanded-change, selection-change, navigation-request
The Wyrding Way — a contract-first design system. © Wyrd Company