Tree

Hierarchical data — folders, categories, menus — with keyboard navigation, single, multiple and checkbox selection, search, lazy children, drag and drop, a context menu and virtual scroll.

Features15APIThemingAccessibility

Basic

A tree of nodes. Tab moves into it, the arrows walk and open branches, letters jump to a label.

Expand

[(expandedKeys)] keeps the open nodes; expandAll() and collapseAll() open or close everything. Nodes with expanded: true start open.

  • Documents
Open: docs

Selection

selectionMode single or multiple. With metaKeySelection a click replaces the selection and Ctrl / ⌘ + click adds a node.

Single
Selected: —
Multiple
Selected: —

Checkbox

selectionMode="checkbox": a parent checks its branch and shows a dash while partly checked. Turn off propagateSelectionUp / propagateSelectionDown to check nodes on their own; highlightOnSelect tints checked rows.

Whole branches
  • Documents
    • Work
      • Expenses.xlsx
      • Resume.pdf
0 checked
Nodes on their own
  • Documents
    • Work
      • Expenses.xlsx
      • Resume.pdf

Filter

filter adds a search field. lenient keeps the whole branch under a match, strict keeps only matching descendants. filterBy lists the searched fields.

Lenient
Strict

Lazy

Nodes with leaf: false and no children load on demand: nodeExpand fires, the toggler spins until the new children arrive.

Drag drop

draggableNodes and droppableNodes move nodes before, after or into another node, also between trees with matching scopes. Alt + arrows move the focused node by keyboard. With validateDrop the move waits for accept().

Inbox
  • Today
    • Weekly report
    • Team lunch
    • Invoice 1043
  • Later
Archive
  • Old threads

Context menu

contextMenu opens on a right click or Shift + F10. The node gets a focus ring and lands in [(contextMenuSelection)].

Templates

txTreeNode changes node content, txTreeNode="type" only for nodes of that type. Header, footer, empty state, toggler and checkbox icons have their own templates too.

Bookmarks

Events

Every action has an output: nodeSelect, nodeUnselect, nodeExpand, nodeCollapse, nodeDoubleClick.

Virtual scroll

virtualScroll with a scrollHeight renders only the visible rows — here 10 000 nodes.

  • Group 1
  • Item 1.1
  • Item 1.2
  • Item 1.3
  • Item 1.4
  • Item 1.5
  • Item 1.6
  • Item 1.7
  • Item 1.8
  • Item 1.9
  • Item 1.10
  • Item 1.11
  • Item 1.12
  • Item 1.13
  • Item 1.14
  • Item 1.15
  • Item 1.16
  • Item 1.17
  • Item 1.18
  • Item 1.19

Loading

loading covers the tree with a mask and a spinner. With loadingMode="icon" only nodes with loading: true spin in their toggler.

Mask
Icon

Scroll height

scrollHeight limits the height and scrolls the nodes; flex fills a parent with a fixed height.

  • Documents
    • Work
      • Expenses.xlsx
      • Resume.pdf
    • Home
      • Invoices.txt
  • Events
    • Meeting
    • Product review
  • Movies
    • Classics
    • Series

Design tokens

dt changes the tokens of one tree — a wider indent, pill-shaped rows and a tinted selection.

  • Documents
    • Work
      • Expenses.xlsx
      • Resume.pdf

Pass through

pt adds classes and styles to the parts of the tree; unstyled keeps only behaviour and ARIA.

  • Documents
  • Documents