Tree
A hierarchical, expandable tree rendered with Unicode box-drawing connectors. Navigate with ↑↓/jk, toggle with Enter/Space, and expand/collapse with →l/←h.
Install the package
Every component ships in the single dart_tui package.
$dart pub add dart_tui

TreeModel(
root: TreeNode(
label: 'Languages',
isExpanded: true,
children: [
TreeNode(label: 'Dart', children: [TreeNode(label: 'Flutter')]),
TreeNode(label: 'Go', children: [TreeNode(label: 'Bubble Tea')]),
],
),
height: 20,
);TreeModel
| Property | Type | Description |
|---|---|---|
| root | TreeNode | Root node. Each node has a label, isExpanded flag and children. |
| cursor | int | Index into the flattened visible node list. |
| height | int | Visible rows before scrolling. Defaults to 20. |
| styles | TreeStyles | Styling for the cursor, labels and connectors. |
Keybindings
↑ / k, ↓ / jMove cursor
→ / lExpand node
← / hCollapse node
enter / spaceToggle node