UI Components

Tree

A tree of labeled nodes with optional glyphs, which the person browses with the arrow keys and typing, and which can let them reorder its nodes. Clicking a node, or pressing Enter or Space on it, activates it, and a branch also opens or closes. When movable, dragging a node or pressing Alt with an arrow key proposes a move, which assistive technology hears; the owner applies it to its nodes, and the rows then glide to their new places, unless reduced motion is preferred, with the moved node keeping focus. A move replaces the announcement of an earlier move in the same tree that assistive technology has not yet spoken, so a held key is heard as its last move.

Examples

Loading…

States

Loading…

API

Selector nol-tree

Import from @noldova/ui.components.angular

Inputs

NameTypeDefaultDescription
nodesreadonly TreeNode[] Required

The top-level nodes, each with its children. A branch that starts open opens the first time it appears.

labelstring Required

The tree's accessible name.

currentstring | nullnull

The id of the current node, which is highlighted, selected for assistive technology and the tree's tab stop, or null for none; null when not bound.

movablebooleanfalse

Whether the person can move nodes, by dragging or with Alt and the arrow keys; false when not bound.

Outputs

NameTypeDescription
activatedTreeNode

Emits the node the person activated; the owner usually makes it TreeComponent.current.

movedTreeMove

Emits a move the person made in a movable tree. The tree does not change its nodes; the owner applies the move, usually with TreeMove.apply, and binds the result.

Accessibility

KeyAction
TabMoves the focus into the tree, its one Tab stop: to the row focused last, or the current row, or the first.
Arrow DownMoves to the next row.
Arrow UpMoves to the previous row.
Arrow RightOpens a closed branch, or moves into an open one.
Arrow LeftCloses an open branch, or moves to the row's parent.
HomeMoves to the first row.
EndMoves to the last row.
A letterMoves to a row whose label starts with what is typed.
EnterChooses the row, and opens or closes a branch.
SpaceChooses the row, and opens or closes a branch.
Alt+Arrow UpIn a movable tree, moves the focused row before its previous sibling.
Alt+Arrow DownIn a movable tree, moves the focused row after its next sibling.
Alt+Arrow RightIn a movable tree, moves the focused row into the branch before it, as its last child, opening that branch; Left in a right-to-left layout.
Alt+Arrow LeftIn a movable tree, moves the focused row out to just after its parent; Right in a right-to-left layout.

It is a tree named by its label; each row is a tree item at its level, marked expanded or collapsed when it is a branch, and the current row is marked selected.

A row is named by its label, which wraps when it is long; its twistie and its icon are hidden from assistive technology.

A movable tree's rows name the Alt and arrow keys that move them as their keyboard shortcuts; its owner applies each move the tree reports, the focus stays on the moved row, and the move is announced politely, such as Moved Notes to position 2 of 3.

Specification

Loading…