Skip to content
SENVENLI UI

Tree

A hierarchy to browse: folders and files, categories, with nodes that open and close.
Files and folders
import { Tree } from "@senvenli/react/collection";

Guidelines

When to use it

  • Data with parents and children people browse: files, categories, an org chart.

Use something else when

Do and avoid

  • Keep labels short; three or four levels at most.

Accessibility

Built in

  • Arrows move, Right opens and Left closes a node, Home and End jump; the chevron and Enter expand.

You provide

  • An aria-label naming the tree.

API reference

Tree

aria-labelRequired
string

Names the tree for screen readers ("Files", "Categories").

itemsRequired
readonly TreeNode[]
selectionMode
"none" | "single" | "multiple"Default "none"

none (default) for navigation with onAction, single or multiple to pick nodes.

selectedKeys
Iterable<Key>
defaultSelectedKeys
Iterable<Key>
onSelectionChange
(keys: Selection) => void
expandedKeys
Iterable<Key>
defaultExpandedKeys
Iterable<Key>
onExpandedChange
(keys: Set<Key>) => void
onAction
(key: Key) => void

What pressing a node does (open the file, go to the category).