TreeSelect
TreeSelect is a generic tree selection component available with the tree feature. It reuses TreeItem and TreeState from tui-tree-widget, and only captures hierarchical navigation, collapse/expand, confirm selection, and input exclusivity. It does not bind itself to files, directories, or any other business meaning.

This recording is generated by docs/tapes/tree-select.tape. The example defaults to components/select, moves to multi-select with j, submits with Enter, goes back to the parent node to collapse/expand, and finally switches to the empty-tree state.
Press h/l to collapse or expand, j/k to move, Space to toggle the current node, Enter to submit, e to toggle the empty tree, and q to quit.
Feature
Section titled “Feature”TreeSelect is behind the tree feature:
Examples use the full feature, so they can be run directly. The library has an intentionally empty default feature set; a bare cargo check will not compile the tree component.
Minimal form
Section titled “Minimal form”default_selection is not an index; it is a node path. For a default path like components/select, the component selects select and opens its ancestor node components, making the default item visible on the first frame.
TreeItem
Section titled “TreeItem”The T in TreeItem<T> is the node identifier, not display text. Identifiers only need to be unique within the same level, and on_select returns the final identifier in the current path.
The framework does not put business types such as PathBuf, file extensions, or section IDs into the component API. For file trees, directory trees, or chapter trees, convert business data to TreeItem<T> in your application layer.
External state
Section titled “External state”By default, TreeSelect stores its own TreeState<T>. If the page needs to show the current path, reset across components, or keep state outside a modal, pass external state:
TreeState::selected() returns the full path slice, for example ["components", "select"]. on_select on Enter returns only the current node id; if business code needs the full path, read it directly from the external TreeState.
Input and empty state
Section titled “Input and empty state”TreeSelect uses an EventScope::Current handler:
h/Left: collapse the current node or move back to the parent.l/Right: expand the current node.j/k/Down/Up: move among visible nodes.Space: toggle the current node’s expanded state.Enter: submit the current node.
When active: false, it does not handle events. When items is empty, it also does not consume tree-navigation keys, so the parent can still handle page-level shortcuts such as e and q in the example.
Layout and style
Section titled “Layout and style”TreeSelect can receive width, height, margin, and offset directly. Its border still uses the native Block from tui-tree-widget, keeping the wrapper thin:
To put it in a modal, render it directly in the Modal subtree. Its Current handler belongs to the modal input layer, so components behind the modal do not process the same keys. For ordinary single-select, see Select; for ordinary multi-select, see MultiSelect; for long lists and custom rows, see VirtualList.