j3w1 / TreeVue · HTML · React · Astro

J3W1 / DESIGN SYSTEM

Tree

Hierarchical navigation with explicit expansion and one roving tab stop.

stable · LIGHT DOM · 1.1.0

Light DOM retains static content, native semantics, label relationships and host composition without duplicating controls.

Live variants

default

  • Source
    • App.vue
    • styles.css
  • README.md

<j3w1-tree id="example-tree-default"><ul class="tree" role="tree" aria-label="Workspace files"><li role="treeitem" id="example-tree-default-tree-source" aria-expanded="true" tabindex="0" data-demo-focus-target=""><span data-tree-label="">Source<button type="button" tabindex="-1" data-tree-toggle="" aria-label="Toggle children">▸</button></span><ul role="group"><li role="treeitem" id="example-tree-default-tree-app" tabindex="-1" aria-selected="true"><span data-tree-label="">App.vue</span></li><li role="treeitem" id="example-tree-default-tree-styles" tabindex="-1" aria-selected="false"><span data-tree-label="">styles.css</span></li></ul></li><li role="treeitem" id="example-tree-default-tree-readme" tabindex="-1" aria-selected="false"><span data-tree-label="">README.md</span></li></ul></j3w1-tree>

Install and register

Use the exact version. If npm publication is pending, install the release tarball from the installation guide.

npm install --save-exact @j3w1/ui@1.1.0
import '@j3w1/ui/tokens.css';
import '@j3w1/ui/styles/tree.css';
import '@j3w1/ui/register/tree';

Insert the maintained markup above after loading these imports. Its native children provide accessible names and form behavior; the empty custom tag alone does not create a control.

Vue SFC, React, Astro and plain HTML integration →

Copy the complete implementation

npx --package=@j3w1/ui@1.1.0 j3w1-ui copy tree --out ./vendor/j3w1/tree

The CLI verifies every file before writing and refuses overwrites. Serve the output over HTTP and open index.html. Keep its modules, CSS, tokens and licence notices together.

Public API

attributes

NameType / signatureMeaning
disabledCustomEventDisable the native controls owned by this instance.
loadingCustomEventMark the primary control busy and prevent duplicate activation.

properties

NameType / signatureMeaning
disabledbooleanDelegates disabled state to native children.
namestringNative control name; application form keys remain explicit.
selectedIdstringSelected treeitem ID.

methods

NameType / signatureMeaning
refresh(): voidReconnect behavior after replacing native child structure.
focus(options?: FocusOptions): voidFocus the first usable native control.
expand(id: string, expanded?: boolean): voidExpand or collapse a parent by ID.

events

NameType / signatureMeaning
j3w1-selectCustomEventThe user selected a visible enabled item.
j3w1-toggleCustomEventA parent expanded or collapsed.

Dependencies and verification

Registered components: none. Style dependencies: none.

Package presence establishes an available implementation. Actual passes depend on the tested artifact and environment. Read specification execution evidence; read packed-consumer evidence; inspect the complete state matrix.

Full implementation manifest, API and token dependency closure

Canonical specification

Purpose

Navigate hierarchical items with explicit expansion and a single roving tab stop. Selection differs from expansion. Caller-supplied nodes represent identities; activation emits an event and never invents file access.

Anatomy

  • tree: Labelled tree with nested groups.
  • item: Named treeitems expose selection; parents also expose expansion.
  • children: A nested group hidden when the parent collapses.

States

StatePresentationNon-colour channel
defaultVisible named tree items.Tree and group hierarchy.
selectedSelected fill, text and start indicator.aria-selected.
expandedDownward marker and visible children.aria-expanded=true.
collapsedSide marker and hidden children.aria-expanded=false; children leave focus order.
focus-visibleDashed ring on the item’s own label.Roving native focus.
disabledDisabled text at full opacity.aria-disabled blocks selection.

Keyboard

  • Up / Down / Home / End: Move through visible items in source order.
  • Right / Left: Expand or enter a parent, collapse it or return to its parent. Mirror these keys in RTL.
  • Enter / Space: Select the focused enabled item.
  • Typing: Move to the next visible label starting with the character.

Accessibility

Implement the linked tree pattern. Only one visible item has tabindex=0. Labels exclude descendant text. Collapsing a parent of the focused item moves focus to that parent. Selection has a programmatic state and border indicator; disabled items do not activate.

Portability

Wrap labels and actions without changing source order. Use logical spacing in RTL. Preserve native target sizes at both densities; only bounded data regions may scroll horizontally. Use equivalent native semantics and approved roles; record any unsupported behavior as a mapping deviation. The host owns application data, persistence, permissions and services.

Non-examples

Unlabelled controls, color-only status, drag-only operations, hidden required instructions, stolen focus or an invented service success.

j3w1 / command

  • SPEC Overview
  • SPEC Foundations
  • SPEC Components
  • SPEC Patterns
  • SPEC Tokens
  • SPEC Tools
  • SPEC Implement
  • SPEC For agents
  • SPEC Ports
  • SPEC Releases
  • DEMO Vue application demo
  • SPEC Complete UI theme specification