Skip to content

Tree View

NavigationSince 0.13.0

Shows hierarchical data following the WAI-ARIA APG tree pattern: expand and collapse, single or multiple selection, checkboxes with tri-state (mixed) parents, lazy children loaded through an async hook with loading and error states, type-ahead, Home/End, * to expand siblings, drag-and-drop reordering and reparenting with a keyboard alternative (Ctrl+X / Ctrl+V and Alt+Up / Alt+Down), inline rename in a text input, icons per node, and a filter that keeps the paths to matches visible. The visible nodes are rendered as a flat, virtualized list on the shared windowing engine (the same one as Virtual List), so trees with 10,000+ visible nodes stay fast.

  • APG tree, every keyArrows, Home, End, type-ahead, and * to expand siblings, with one tab stop and RTL-aware arrows.
  • Lazy childrenAn async hook loads children on first expansion, with a busy state, an error message, and retry.
  • Tri-state checkboxesChecking a parent checks its descendants; partly checked parents show the mixed state.
  • Move by drag or keyboardDrag to reorder or reparent, or cut and paste with Ctrl+X and Ctrl+V; every move is cancelable.
  • Rename and filterF2 renames in a text input; a filter keeps the paths to matches visible and highlights them.
  • 10,000+ visible nodesRows are virtualized on the shared windowing engine; the focused node always stays rendered.

Use it for

  • Folders and documents, organization units, categories, or any data with parent-child relationships.
  • Navigation through a deep hierarchy where users expand only what they need.
  • Picking several items of a hierarchy with tri-state checkboxes (permissions, locations).

Use something else for

  • Flat lists: use Virtual List, Select, or Multi Select.
  • Site navigation with a few levels: use Sidebar or Menu Bar.
  • Picking one value of a hierarchy in a form: use Tree Select.
  • Hierarchical data with columns: use Data Grid tree data.
Anatomy
<div class="aui-tree-view aui-tree-view--checkboxes">
<div class="aui-tree-view__viewport" role="tree" aria-label="Documents"> (scroll container)
<div class="aui-tree-view__canvas" role="none"> (full height of all visible nodes)
<div class="aui-tree-view__item aui-tree-view__item--open" role="treeitem" aria-level="1" aria-posinset="1" aria-setsize="3" aria-expanded="true" aria-checked="mixed" tabindex="0">
<span class="aui-tree-view__twisty" aria-hidden="true">chevron</span>
<span class="aui-tree-view__check" aria-hidden="true"></span>
<span class="aui-tree-view__icon" aria-hidden="true">icon</span>
<span class="aui-tree-view__label">Pol<mark class="aui-tree-view__match">ic</mark>ies</span>
</div>
<div class="aui-tree-view__item" role="treeitem" aria-level="2" aria-busy="true" tabindex="-1">...</div>
<div class="aui-tree-view__drop" aria-hidden="true"></div> (drop line while dragging)
</div>
</div>
<div class="aui-tree-view__empty" role="status" hidden>No items</div>
</div>

Use the bar above each frame to switch theme, density, direction, and locale.

Tree View in the Navigation and commands showcase

Section titled “Tree View in the Navigation and commands showcase”

The part of the Navigation and commands showcase that uses Tree View. Change its options, use it with the keyboard, and watch the event log; the link in the frame opens the full showcase. The bar above the frame switches theme, density, direction, and locale.

Showcase source
// Navigation and commands showcase: a document tree with lazy folders, drag-and-drop,
// rename, checkboxes, and a filter; a Tree Select for a department; and a command palette
// opened with Ctrl+K (Cmd+K) or a button, with nested pages and a simulated people search.
import { Button } from '@absoluteui/components/button';
import { CommandPalette, type Command, type CommandPaletteSelectDetail } from '@absoluteui/components/command-palette';
import { TextInput } from '@absoluteui/components/text-input';
import { TreeSelect, type TreeSelectChangeDetail } from '@absoluteui/components/tree-select';
import { TreeView, type TreeNode, type TreeViewSelectDetail } from '@absoluteui/components/tree-view';
import { action, choice, createShowcase, section, status, toggle, wait } from './kit.js';
const sc = createShowcase({
title: 'Navigation and commands',
description: 'Browse the company documents (folders load when opened), drag or cut and paste to reorganize, press F2 to rename, pick a department, and press Ctrl+K (Cmd+K) for the command palette.',
simulated: true,
});
const DOCUMENTS: TreeNode[] = [
{ id: 'policies', label: 'Policies', icon: 'list-bulleted', children: [
{ id: 'leave', label: 'Leave policy', icon: 'file' },
{ id: 'travel', label: 'Travel policy', icon: 'file' },
{ id: 'expenses', label: 'Expenses policy', icon: 'file' },
{ id: 'remote', label: 'Remote work policy', icon: 'file' },
] },
{ id: 'handbook', label: 'Employee handbook', icon: 'list-bulleted', children: [
{ id: 'welcome', label: 'Welcome', icon: 'file' },
{ id: 'benefits', label: 'Benefits', icon: 'list-bulleted', children: [{ id: 'health', label: 'Health insurance', icon: 'file' }, { id: 'pension', label: 'Pension plan', icon: 'file' }] },
{ id: 'conduct', label: 'Code of conduct', icon: 'file' },
] },
{ id: 'payroll', label: 'Payroll (loads on open)', icon: 'list-bulleted', hasChildren: true },
{ id: 'archive', label: 'Archive (loads on open)', icon: 'list-bulleted', hasChildren: true },
{ id: 'legal', label: 'Legal hold (fails to load)', icon: 'list-bulleted', hasChildren: true },
{ id: 'board', label: 'Board minutes (restricted)', icon: 'file', disabled: true },
];
let failNext = true;
const docsArea = section(sc, 'Company documents', ['tree-view']);
const docsStatus = status(docsArea);
docsStatus.textContent = 'Nothing selected.';
const filterHost = document.createElement('div');
const treeHost = document.createElement('div');
docsArea.append(filterHost, treeHost);
const tree = TreeView.create(treeHost, {
label: 'Company documents',
nodes: DOCUMENTS,
selection: 'single',
expanded: ['policies'],
draggable: true,
renamable: true,
height: '20rem',
// Folders other than Policies and Handbook are leaves, so documents cannot be dropped into files.
canDrop: (_source, target, position) => position !== 'inside' || target === null || target.icon === 'list-bulleted',
loadChildren: async (node, { signal }) => {
await wait(700, signal);
if (node.id === 'legal' && failNext) {
failNext = false;
throw new Error('Simulated server error');
}
return Array.from({ length: node.id === 'archive' ? 60 : 6 }, (_, i) => ({ id: `${node.id}-${String(i + 1)}`, label: `${node.id === 'payroll' ? 'Payslip run' : 'Record'} ${String(2025 - Math.floor(i / 12))}-${String((i % 12) + 1).padStart(2, '0')}`, icon: 'file' }));
},
});
sc.listen(treeHost, ['aui-select', 'aui-change', 'aui-expand', 'aui-move', 'aui-rename', 'aui-activate', 'aui-load-error'], 'tree');
treeHost.addEventListener('aui-select', (e) => {
const id = (e as CustomEvent<TreeViewSelectDetail>).detail.selected[0];
docsStatus.textContent = id === undefined ? 'Nothing selected.' : `Selected: ${tree.getNode(id)?.label ?? id}.`;
});
const filter = TextInput.create(filterHost, { label: 'Filter documents', type: 'search', description: 'Matches stay visible with the folders that contain them.' });
filterHost.addEventListener('aui-input', () => {
tree.update({ filter: filter.value });
});
toggle(sc, 'Checkboxes', false, (checkboxes) => {
tree.update({ checkboxes, selection: checkboxes ? 'none' : 'single' });
}, ['tree-view']);
toggle(sc, 'Multiple selection', false, (multiple) => {
tree.update({ selection: multiple ? 'multiple' : 'single', selected: [] });
}, ['tree-view']);
toggle(sc, 'Drag and drop', true, (draggable) => {
tree.update({ draggable });
}, ['tree-view']);
action(sc, 'Expand all', () => {
tree.expandAll();
}, ['tree-view']);
action(sc, 'Collapse all', () => {
tree.collapseAll();
}, ['tree-view']);
action(sc, 'Rename the selected document', () => {
const id = tree.selected[0] ?? tree.activeId;
if (id !== null) tree.rename(id);
}, ['tree-view']);
const pickArea = section(sc, 'Department', ['tree-select']);
const pickStatus = status(pickArea);
const DEPARTMENTS: TreeNode[] = [
{ id: 'eng', label: 'Engineering', children: [{ id: 'eng-web', label: 'Web' }, { id: 'eng-platform', label: 'Platform' }, { id: 'eng-data', label: 'Data and AI' }] },
{ id: 'ops', label: 'Operations', children: [{ id: 'ops-facilities', label: 'Facilities' }, { id: 'ops-it', label: 'IT support' }, { id: 'ops-security', label: 'Security' }] },
{ id: 'people', label: 'People and Culture', children: [{ id: 'people-recruiting', label: 'Recruiting' }, { id: 'people-learning', label: 'Learning' }] },
{ id: 'finance', label: 'Finance', children: [{ id: 'finance-payroll', label: 'Payroll' }, { id: 'finance-tax', label: 'Tax' }] },
];
const selectHost = document.createElement('div');
pickArea.append(selectHost);
const department = TreeSelect.create(selectHost, { label: 'Department', name: 'department', required: true, placeholder: 'Choose a department', description: 'Type to filter; Down Arrow moves into the tree.', nodes: DEPARTMENTS });
sc.listen(selectHost, ['aui-change'], 'tree-select');
selectHost.addEventListener('aui-change', (e) => {
const { value } = (e as CustomEvent<TreeSelectChangeDetail>).detail;
pickStatus.textContent = value.length === 0 ? 'No department chosen.' : `Chosen: ${value.join(', ')}.`;
});
choice(sc, 'Department mode', [{ value: 'single', label: 'One department' }, { value: 'multiple', label: 'Several (checkboxes)' }], 'single', (mode) => {
department.update({ mode, value: [] });
}, ['tree-select']);
toggle(sc, 'Teams only (parents open)', false, (teamsOnly) => {
department.update({ selectableParents: !teamsOnly });
}, ['tree-select']);
const cmdArea = section(sc, 'Command palette', ['command-palette']);
const cmdStatus = status(cmdArea);
cmdStatus.textContent = 'Press Ctrl+K (Cmd+K) or the button.';
const PEOPLE = ['Ada Lovelace', 'Alan Turing', 'Barbara Liskov', 'Donald Knuth', 'Edsger Dijkstra', 'Grace Hopper', 'Katherine Johnson', 'Margaret Hamilton', 'Radia Perlman', 'Tim Berners-Lee'];
const commands: Command[] = [
{ id: 'go-dashboard', label: 'Go to dashboard', group: 'Navigation', icon: 'menu' },
{ id: 'go-directory', label: 'Go to directory', group: 'Navigation', keywords: ['people', 'employees'], icon: 'menu' },
{ id: 'go-documents', label: 'Go to documents', group: 'Navigation', icon: 'menu', run: () => { tree.focusNode('policies'); } },
{ id: 'request-leave', label: 'Request leave', group: 'Actions', shortcut: 'Mod+Shift+L', icon: 'calendar', keywords: ['vacation', 'holiday'] },
{ id: 'new-document', label: 'New document', group: 'Actions', shortcut: 'Mod+N', icon: 'plus' },
{ id: 'export', label: 'Export report (no permission)', group: 'Actions', icon: 'download', disabled: true },
{ id: 'theme', label: 'Change theme', group: 'Preferences', icon: 'eye', children: [
{ id: 'theme-light', label: 'Light' },
{ id: 'theme-dark', label: 'Dark' },
{ id: 'theme-contrast', label: 'High contrast' },
] },
{ id: 'density', label: 'Change density', group: 'Preferences', icon: 'align-justify', children: [
{ id: 'density-compact', label: 'Compact' },
{ id: 'density-comfortable', label: 'Comfortable' },
{ id: 'density-spacious', label: 'Spacious' },
] },
];
const paletteHost = document.createElement('div');
cmdArea.append(paletteHost);
const palette = CommandPalette.create(paletteHost, {
commands,
recent: ['go-directory'],
placeholder: 'Search pages, actions, and people',
providers: [{
id: 'people',
label: 'People',
minQueryLength: 2,
search: async (query, { signal }) => {
await wait(350, signal);
const q = query.toLowerCase();
return PEOPLE.filter((p) => p.toLowerCase().includes(q)).map((p) => ({ id: `person-${p}`, label: p, description: 'Employee', icon: 'search' }));
},
}],
});
sc.listen(paletteHost, ['aui-select', 'aui-open', 'aui-close'], 'palette');
paletteHost.addEventListener('aui-select', (e) => {
const d = (e as CustomEvent<CommandPaletteSelectDetail>).detail;
cmdStatus.textContent = `Chose ${d.command.label}${d.path.length > 0 ? ` (in ${d.path.join(' / ')})` : ''}.`;
});
const openButton = Button.create({ text: 'Open command palette', icon: 'search', variant: 'secondary' });
openButton.element.addEventListener('click', () => {
palette.open();
});
cmdArea.append(openButton.element);
choice(sc, 'Palette shortcut', [{ value: 'Mod+K', label: 'Ctrl+K / Cmd+K' }, { value: 'Mod+Shift+P', label: 'Ctrl+Shift+P / Cmd+Shift+P' }], 'Mod+K', (shortcut) => {
palette.update({ shortcut });
}, ['command-palette']);
action(sc, 'Open on the theme page', () => {
palette.open({ page: 'theme' });
}, ['command-palette']);

Documents with lazy folders, drag-and-drop, and rename

Section titled “Documents with lazy folders, drag-and-drop, and rename”
import { TreeView, type TreeNode, type TreeViewMoveDetail } from '@absoluteui/components/tree-view';
const nodes: TreeNode[] = [
{ id: 'policies', label: 'Policies', children: [
{ id: 'leave', label: 'Leave policy.pdf', icon: 'file' },
{ id: 'travel', label: 'Travel policy.pdf', icon: 'file' },
] },
{ id: 'archive', label: 'Archive', hasChildren: true },
];
const host = document.createElement('div');
document.body.append(host);
const tree = TreeView.create(host, {
label: 'Documents',
nodes,
selection: 'single',
expanded: ['policies'],
draggable: true,
renamable: true,
// Files (nodes with the file icon) cannot contain other nodes.
canDrop: (_source, target, position) => position !== 'inside' || target?.icon !== 'file',
loadChildren: async (node, { signal }) => {
const res = await fetch(`/api/folders/${encodeURIComponent(node.id)}`, { signal });
return (await res.json()) as TreeNode[];
},
});
host.addEventListener('aui-move', (event) => {
const { id, parentId, index } = (event as CustomEvent<TreeViewMoveDetail>).detail;
host.dataset.lastMove = `${id} -> ${parentId ?? 'root'} at ${String(index)}`;
});
void tree.expand('archive');
import { TreeView, type TreeViewChangeDetail } from '@absoluteui/components/tree-view';
const host = document.createElement('div');
document.body.append(host);
const tree = TreeView.create(host, {
label: 'Locations',
checkboxes: true,
checked: ['berlin'],
expanded: ['emea'],
nodes: [
{ id: 'emea', label: 'Europe', children: [
{ id: 'berlin', label: 'Berlin' },
{ id: 'paris', label: 'Paris' },
] },
{ id: 'apac', label: 'Asia Pacific', children: [{ id: 'sydney', label: 'Sydney' }] },
],
});
host.addEventListener('aui-change', (event) => {
const { checked, indeterminate } = (event as CustomEvent<TreeViewChangeDetail>).detail;
host.dataset.checked = `${String(checked.length)} checked, ${String(indeterminate.length)} mixed`;
});
tree.update({ filter: 'par' });
Terminal window
npm install @absoluteui/components @absoluteui/core @absoluteui/theme

Registry setup, the theme stylesheet, and the Content Security Policy are covered in Installation.

import { TreeView } from '@absoluteui/components/tree-view';
import '@absoluteui/components/tree-view/style.css';
import { TreeView } from '@absoluteui/components/tree-view';
import '@absoluteui/components/tree-view/style.css';
const host = document.querySelector<HTMLElement>('#tree');
if (host) TreeView.create(host, { label: 'Files', nodes: [{ id: 'src', label: 'src', children: [{ id: 'main', label: 'main.ts' }] }], expanded: ['src'] });
More usage
import { TreeView, type TreeViewActivateDetail } from '@absoluteui/components/tree-view';
const host = document.querySelector<HTMLElement>('#org');
if (host) {
TreeView.create(host, {
label: 'Organization',
selection: 'single',
expanded: ['company'],
nodes: [{ id: 'company', label: 'Acme', children: [{ id: 'eng', label: 'Engineering' }, { id: 'ops', label: 'Operations' }] }],
});
host.addEventListener('aui-activate', (event) => {
host.dataset.open = (event as CustomEvent<TreeViewActivateDetail>).detail.id;
});
}

Using Angular? See Tree View for Angular.

TreeView.create(host: HTMLElement, options: TreeViewOptions): TreeView

Global configuration key: treeView (see Configuration).

Option Type Default Description
label string Accessible name of the tree. Required.
nodes readonly TreeNode[] The nodes ({ id, label, icon?, expandedIcon?, children?, hasChildren?, disabled? }); ids must be unique. Required.
selection 'none' | 'single' | 'multiple' "none" Selection mode.
selected readonly string[] "[]" Ids of the selected nodes.
checkboxes boolean "false" Show a checkbox per node; Space toggles it.
checked readonly string[] "[]" Ids of the checked nodes.
cascade boolean "true" Checking a parent checks its descendants; parents show the mixed state.
expanded readonly string[] "[]" Ids of the expanded nodes.
loadChildren ((node: TreeNode, context: TreeViewLoadContext) => Promise<readonly TreeNode[]>) | null Loads the children of a node with hasChildren on first expansion; receives an AbortSignal.
draggable boolean "false" Nodes can be moved by dragging and with Ctrl+X / Ctrl+V and Alt+Up / Alt+Down.
canDrag (node: TreeNode) => boolean Which nodes may be moved.
canDrop (source: TreeNode, target: TreeNode | null, position: TreeViewDropPosition) => boolean Whether a node may be dropped before, inside, or after a target.
renamable boolean | ((node: TreeNode) => boolean) "false" Nodes can be renamed with F2 or a double click on the label.
filter string "''" Show matching nodes and the paths to them (case and accent insensitive); matches are highlighted.
filterBy (node: TreeNode, query: string) => boolean Custom filter match instead of the label match.
itemHeight number Row height in pixels (24 to 200). Default by density: 32, 40, or 48.
height string | null "20rem" Block size of the scroll area as a CSS length, or null to fill the host.
empty string "No items" Text shown when there are no nodes.
direction 'ltr' | 'rtl' Writing direction for the arrow keys. Default: the computed direction of the host.
icons Partial<TreeViewIcons> Twisty, loading, and error icons.
overscan number "8" Rows rendered beyond each edge of the visible area (0 to 100). Globally configurable.
locale string "en-US" Locale of messages, filtering, and type-ahead. Globally configurable. Inherited from common configuration.
density 'compact' | 'comfortable' | 'spacious' "comfortable" Default row height when itemHeight is not set. Globally configurable. Inherited from common configuration.
Property Type Description
host HTMLElement The host element.
nodes TreeNode[] The current tree, including loaded children, moves, and renames.
selected string[] Ids of the selected nodes.
checked string[] Ids of the checked nodes.
indeterminate string[] Ids of parents in the mixed state.
expanded string[] Ids of the expanded nodes.
matches string[] Ids of the nodes matching filter, in visible order.
visibleCount number Number of visible nodes.
activeId string | null Id of the focusable node.
range WindowRange The visible rows { start, end } (end exclusive).
options Readonly<TreeViewOptions> Current options.
Method Description
expand(id: string): Promise<void> Expand a node and its ancestors, loading lazy children.
collapse(id: string): void Collapse a node.
expandAll(): void Expand every loaded parent.
collapseAll(): void Collapse every node.
setSelected(ids: readonly string[]): void Select by ids (no event).
setChecked(ids: readonly string[]): void Check by ids (no event).
focusNode(id: string): void Focus a node, expanding its ancestors and scrolling it into view.
scrollToNode(id: string, align?: 'auto' | 'start' | 'center' | 'end'): void Scroll a node into view, expanding its ancestors.
reload(id: string): Promise<void> Load a lazy node’s children again.
rename(id: string): void Start renaming a node.
getNode(id: string): TreeNode | null A node of the current tree.
getParentId(id: string): string | null The id of a node’s parent.
getItemElement(id: string): HTMLElement | null The rendered treeitem of a node, or null.
update(options: Partial<TreeViewOptions>): void Merge and apply options.
destroy(): void Remove rendering, observers, and listeners; abort loads.
Event Detail Bubbles Cancelable Description
aui-select TreeViewSelectDetail Yes No The user changed the selection: { selected, id }.
aui-change TreeViewChangeDetail Yes No The user toggled a checkbox: { checked, indeterminate, id }.
aui-expand TreeViewExpandDetail Yes No The user expanded or collapsed a node: { id, open, expanded }.
aui-move TreeViewMoveDetail Yes Yes A node is about to move (drag or keyboard): { id, parentId, index, previousParentId, previousIndex, source }; preventDefault() keeps it in place.
aui-rename TreeViewRenameDetail Yes Yes A node is about to be renamed: { id, label, previousLabel }; preventDefault() keeps the old label.
aui-activate TreeViewActivateDetail Yes No A node was activated with Enter or a double click: { id, node }.
aui-load-error TreeViewLoadErrorDetail Yes No loadChildren rejected: { id, error }.
aui-range-change { start: number; end: number } No No The visible rows changed.

All rules live in the aui.components cascade layer, so application styles override them without specificity battles.

Class Purpose
aui-tree-view Host.
aui-tree-view--fill | --empty | --checkboxes | --draggable | --dragging Fill the host, no nodes, checkbox mode, movable nodes, a drag in progress.
aui-tree-view__viewport Scroll container (role=tree).
aui-tree-view__canvas Full-height positioning layer (role=none).
aui-tree-view__item A visible node (role=treeitem).
aui-tree-view__item--selected | --checked | --mixed | --open | --active | --error | --cut | --dragging | --drop-inside Node states.
aui-tree-view__twisty | __check | __icon | __label | __match | __error | __input Twisty, checkbox, icon, label, filter match, load error text, and rename input.
aui-tree-view__drop Drop indicator line.
aui-tree-view__empty Empty or no-matches message (role=status).
Slot Default icon
expand chevron-right
loading spinner
error alert-circle

Tokens this stylesheet reads (verified in CI). Override them in a theme or with the Theme Designer.

--aui-border-width | --aui-border-width-strong | --aui-color-border | --aui-color-border-strong | --aui-color-disabled-bg | --aui-color-error-fg | --aui-color-focus-ring | --aui-color-hover | --aui-color-on-primary | --aui-color-primary | --aui-color-selected | --aui-color-selected-indicator | --aui-color-selected-text | --aui-color-surface | --aui-color-text | --aui-color-text-disabled | --aui-color-text-muted | --aui-duration-fast | --aui-easing-standard | --aui-focus-ring-offset | --aui-focus-ring-width | --aui-font-family-sans | --aui-font-size-md | --aui-font-size-sm | --aui-font-weight-semibold | --aui-icon-size-sm | --aui-line-height-normal | --aui-radius-md | --aui-radius-pill | --aui-radius-sm | --aui-space-1 | --aui-space-2 | --aui-space-4 | --aui-space-5

TypeScript definitions
type TreeViewSelection = 'none' | 'single' | 'multiple';
type TreeViewDropPosition = 'before' | 'inside' | 'after';
interface TreeNode { readonly id: string; readonly label: string; readonly icon?: IconRef; readonly expandedIcon?: IconRef; readonly children?: readonly TreeNode[]; readonly hasChildren?: boolean; readonly disabled?: boolean }
interface TreeViewLoadContext { readonly signal: AbortSignal }
interface TreeViewOptions extends Partial<TreeViewConfig> {
label: string;
nodes: readonly TreeNode[];
selection?: TreeViewSelection;
selected?: readonly string[];
checkboxes?: boolean;
checked?: readonly string[];
cascade?: boolean;
expanded?: readonly string[];
loadChildren?: ((node: TreeNode, context: TreeViewLoadContext) => Promise<readonly TreeNode[]>) | null;
draggable?: boolean;
canDrag?: (node: TreeNode) => boolean;
canDrop?: (source: TreeNode, target: TreeNode | null, position: TreeViewDropPosition) => boolean;
renamable?: boolean | ((node: TreeNode) => boolean);
filter?: string;
filterBy?: (node: TreeNode, query: string) => boolean;
itemHeight?: number;
height?: string | null;
empty?: string;
direction?: 'ltr' | 'rtl';
locale?: string;
density?: Density;
icons?: Partial<TreeViewIcons>;
}
interface TreeViewSelectDetail { selected: string[]; id: string }
interface TreeViewChangeDetail { checked: string[]; indeterminate: string[]; id: string }
interface TreeViewExpandDetail { id: string; open: boolean; expanded: string[] }
interface TreeViewMoveDetail { id: string; parentId: string | null; index: number; previousParentId: string | null; previousIndex: number; source: 'pointer' | 'keyboard' }
interface TreeViewRenameDetail { id: string; label: string; previousLabel: string }
interface TreeViewActivateDetail { id: string; node: TreeNode }

Pattern: WAI-ARIA APG Tree View with a flat DOM: every visible node is a treeitem directly inside the tree and carries aria-level, aria-posinset, and aria-setsize (only part of the tree is rendered). Roving tabindex keeps one tab stop; the focused node always stays rendered.

Checked on every docs build: the showcase passes axe (WCAG 2.2 A and AA rules) in the default, dark, and high-contrast themes and right to left; the playground loads without errors and passes axe before and after every on/off option is switched, with no Content Security Policy violations.

Key Context Action
Tab Tree Focus the active node (one tab stop).
Down / Up Tree Next or previous visible node.
Right (Left in RTL) Node Collapsed parent: expand (loading lazy children). Expanded parent: first child. Failed load: retry.
Left (Right in RTL) Node Expanded parent: collapse. Otherwise: focus the parent.
Home / End Tree First or last visible node.
Page Down / Page Up Tree Move by one visible page.
* Node Expand all siblings of the focused node.
Printable characters Tree Type-ahead to the next visible node whose label starts with the typed characters.
Enter Node Activate (aui-activate); selects in single mode; retries a failed load.
Space Node Toggle the checkbox (checkboxes), toggle selection (multiple), or select (single).
Shift + Down / Up / Space Multiple selection Extend the selection from the anchor.
Ctrl + A (Cmd + A) Multiple selection Select all visible nodes, or clear when all are selected.
F2 Renamable node Rename in a text input: Enter saves, Escape cancels.
Ctrl + X (Cmd + X) Draggable tree Cut the focused node (keyboard move).
Ctrl + V / Ctrl + Shift + V After a cut Move the cut node inside the focused node (last child) or after it.
Alt + Up / Alt + Down Draggable tree Move the focused node one place among its siblings.
Escape After a cut Cancel the move.
Element Role
viewport tree
canvas none
node treeitem
empty message status
Attribute Element Value
aria-label tree the label option
aria-multiselectable tree true with multiple selection
aria-level / aria-posinset / aria-setsize treeitem depth (1-based), position among visible siblings, and their count
aria-expanded treeitem true or false on parents (absent on leaves)
aria-selected treeitem true or false when selection is not none
aria-checked treeitem true, false, or mixed with checkboxes
aria-disabled treeitem true for disabled nodes
aria-busy treeitem true while its children load

One tab stop (roving tabindex). The focused node stays rendered while scrolling; collapsing an ancestor or filtering it out moves focus to the nearest visible ancestor. After a move or rename, focus stays on the node.

Criterion Level Note
1.3.1 Info and Relationships A
1.4.1 Use of Color A
1.4.11 Non-text Contrast AA
2.1.1 Keyboard A
2.4.3 Focus Order A
2.4.7 Focus Visible AA
2.5.7 Dragging Movements AA
2.5.8 Target Size (Minimum) AA
4.1.2 Name, Role, Value A
4.1.3 Status Messages AA

Automated test results: Accessibility and compliance.

  • Dragging has a keyboard and single-pointer alternative (cut and paste, Alt+Arrow), meeting WCAG 2.5.7.
  • Loading, load failures, moves, renames, and filter results are announced politely (failures assertively) through the shared live region (WCAG 4.1.3).
  • Selection is shown by a start-edge bar as well as color; checked and mixed states by a check mark and a dash (WCAG 1.4.1).
  • The tree is flat in the DOM (aria-level instead of nested groups) so it can be virtualized; screen readers announce levels from aria-level.
  • Manual screen-reader verification (NVDA, JAWS, VoiceOver) is pending.
Import cost Minified gzip brotli CSS brotli
@absoluteui/components/tree-view 63.4 kB 21.3 kB 19.0 kB 1.5 kB

Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.

Budget (enforced in CI) Limit
TreeView.create with 10,000 visible nodes < 30 ms average in headless Chromium
Rendered treeitem elements visible rows + 2 x overscan + 1

Tested scale: 100,000 nodes, 10,000+ visible at once (expand all); at most 500,000 nodes. The filter scans loaded nodes only.

The visible nodes are flattened once per structural change; row offsets use the shared windowing engine (typed arrays, binary search). Only visible + 2 x overscan + 1 treeitems exist; elements are recycled while scrolling. Checks are normalized in one pass per change.

Measured run times: Performance.

States

Collapsed; expanded; selected; checked; mixed; disabled node; loading children; load failed; filtered; no matches; cut; dragging; renaming; empty.

State transitions
From Trigger To
collapsed lazy parent Right Arrow, twisty click, expand() loading (aria-busy, spinner), then expanded or load failed
load failed Enter, Right Arrow, twisty click, reload() loading again
unchecked Space, checkbox click checked; descendants checked and ancestors updated (cascade); aui-change
any node Ctrl+X cut; Ctrl+V moves it inside the focused node, Ctrl+Shift+V after it; Escape cancels
any node drag over a node (top quarter / middle / bottom quarter) drop before / inside / after; aui-move
node F2 or double click on the label renaming; Enter or blur saves (aui-rename), Escape cancels
any update({ filter }) matches and their ancestors shown; others hidden
Accessibility notes
  • Drag-and-drop has a keyboard alternative (cut and paste, Alt+Arrow), meeting WCAG 2.5.7.
  • Loads, failures, moves, renames, and filter results are announced through the shared live region (WCAG 4.1.3).
  • Selection shows a start-edge bar, checks a mark or a dash: never color alone (WCAG 1.4.1).
  • The twisty is a 24 px target (WCAG 2.5.8). The e2e axe run covers three themes and RTL; manual screen-reader verification is pending.
Responsive behavior

Fills the inline size of its host; the block size comes from height, or from the host with height: null (for example a Splitter pane). Long labels are truncated with an ellipsis.

Right-to-left

Indentation, the selection bar, and text follow the writing direction; the twisty is mirrored; Left Arrow expands and Right Arrow collapses in RTL (from the host’s computed direction, or direction).

Theming

Three themes through the role tokens; forced colors use Highlight, HighlightText, and GrayText, and draw checkboxes with system colors.

Global configuration
configureAbsoluteUI({ components: { treeView: { overscan: 12 } } });
Component configuration

Instance overscan, locale, and density override configuration; configuration changes lay out existing trees again.

Icons

icons.expand (default chevron-right, mirrored in RTL), icons.loading (spinner), and icons.error (alert-circle). Node icons come from icon and expandedIcon (for example folder and folder-open from @absoluteui/icons/set).

Security

Labels are rendered as text; renamed labels come from a text input (trimmed, at most 255 characters); filter matches are <mark> elements built from text nodes. No HTML is parsed.

Data handling

No persistence, network access, or telemetry. loadChildren is the application’s function and receives an AbortSignal (aborted on destroy(), reload(), or new nodes). Results are validated (unique ids) before they are added.

Supported data scale

Tested with 100,000 nodes and 10,000+ visible nodes (expand all). The option limit is 500,000 nodes. The filter scans loaded nodes.

Edge cases
  • loadChildren resolving with ids that already exist fails the load (the node shows the error state).
  • Expanding a lazy node without loadChildren turns it into a leaf.
  • Dropping into a lazy, unloaded parent loads its children first, then appends the node.
  • A node cannot be dropped into itself or its descendants; canDrop can forbid more.
  • Collapsing the parent of the focused node moves focus to that parent.
  • Renaming to an empty or unchanged label keeps the old label.
Errors
Code Category Cause
TREE_VIEW_OPTIONS configuration Blank label, nodes not an array, a node without a string id or label, duplicate ids, more than 500,000 nodes, unknown selection, non-string ids in selected/checked/expanded, more than one selected id in single mode, non-function hooks, an itemHeight outside 24 to 200, or a height that is not a CSS length.
CFG_INVALID_VALUE / CFG_UNKNOWN_OPTION configuration Invalid or unknown configuration.

Invalid options throw before the host is modified; a failing loadChildren sets the node’s error state and emits aui-load-error.

Known limitations
  • One fixed row height; labels do not wrap.
  • The filter and type-ahead see loaded nodes only.
  • Only rendered nodes are in the DOM (find-in-page and printing see only those).
  • Touch drags start on the node icon.
  • Manual screen-reader verification is pending.
Unsupported scenarios
  • Columns per node (use Data Grid tree data).
  • Dragging between two trees.
  • Rich (HTML) labels.