Skip to content

Tree / file tree

In review
Live · web

File tree: arrow-key nav · click a file to select (one cyan indicator)

src
components
demos
TreeDemo.tsx
ButtonDemo.tsx
Example.astro
package.json
logo.png

Task subtree: multi-select · checking a parent propagates (tri-state)

· Native Android app
· File tree screen
· Tasks sheet
· Epic / child rows
· Subtask badge
· SSE streaming

Selected file: TreeDemo.tsx · checked subtasks: 2. The island is live.

// Web: React, consuming @dizyx/nockerl-tokens. NockerlTree ships from
// @dizyx/nockerl-react: the recursive rows, depth indent + guide-line rails,
// disclosure chevrons, single-select cyan wash OR multi-select tri-state
// checkboxes (parent↔child propagation), and the full WAI-ARIA tree keyboard
// pattern are all in the package.
import { useState } from 'react';
import { NockerlTree, type NockerlTreeNode } from '@dizyx/nockerl-react';
const files: NockerlTreeNode[] = [
{
id: 'src', name: 'src', kind: 'folder', children: [
{ id: 'src/components', name: 'components', kind: 'folder', children: [
{ id: 'src/components/Tree.tsx', name: 'Tree.tsx', kind: 'file', fileType: 'typescript' },
] },
{ id: 'src/styles', name: 'styles', kind: 'folder', count: 3, children: [/* … */] },
],
},
{ id: 'package.json', name: 'package.json', kind: 'file', fileType: 'json' },
];
export function FileTree() {
const [expanded, setExpanded] = useState(new Set(['src', 'src/components']));
const [selected, setSelected] = useState<string | null>(null);
return (
<NockerlTree
nodes={files}
selectable="single" // or "multi" for tri-state checkboxes
ariaLabel="Project files"
expandedIds={expanded}
onToggleExpand={setExpanded}
selectedId={selected}
onSelect={setSelected}
/>
);
}

NockerlTree takes the recursive nodes forest + controlled expand/select state. Auto-expand root folders on first load to match the canonical behaviour. A NockerlTreeNode is { id, name, kind: 'folder' | 'file', fileType?, children?, count?, loading?, disabled? }.

PropTypeDefaultDescription
nodes *NockerlTreeNode[]The recursive forest. Auto-expand root folders on first load to match the canonical behaviour.
selectableNockerlTreeSelectable'single'single: one selected node (soft cyan wash). multi: tri-state checkboxes that propagate parent↔child.
ariaLabel *stringREQUIRED accessible name for the role="tree" container.
expandedIds *Set<string>Controlled set of expanded folder ids.
onToggleExpand(next: Set<string>) => voidFired with the next expanded set when a chevron (or a folder row) toggles.
selectedIdstring | nullSelected node id (single-select).
onSelect(id: string) => voidFired when a leaf is activated (single-select).
checkedIdsSet<string>Checked leaf ids (multi-select). A folder reads on / off / mixed from its descendants.
onCheckedChange(next: Set<string>) => voidFired when a node toggles its whole leaf-subtree (multi-select).