tui-treelistview
A tree-list widget for Ratatui.
Specialization: this widget is less about passive tree rendering and more about full interaction with tree data (navigate, toggle, reorder, add, rename, delete), so it fits editing workflows as much as browsing.

IMPORTANT: This widget is the open part of a closed-source project, so highly specialized features may be.
How it works
The widget is split into three layers:
- Data:
TreeModelis the minimal tree contract (root, children, contains). Your app owns the data. - State:
TreeListViewStatestores expanded nodes, selection, scroll offset, and caches of visible nodes/marks. - View:
TreeListViewbuilds rows from the current state and renders aratatui::widgets::Table.
Rendering flow in one sentence: state builds a flat list of visible nodes, the view turns them into table rows using your label renderer + columns, and Ratatui draws the table (with optional scrollbar).
Practical usage pattern:
- Implement
TreeModelfor your data. - Provide a label renderer (
TreeLabelRendererorTreeLabelProvider) and columns (TreeColumns). - Keep a
TreeListViewStatein your app state, mutate it on input (handle_action/handle_key), and renderTreeListVieweach frame. - (Optional) Enable filtering (
with_filter+TreeFilterConfig), editing actions (editfeature), and keymaps (keymapfeature).
TreeModel contract
TreeModel is intentionally minimal, but it assumes a real tree:
- No cycles (depth-first traversal is used).
- Each node has a single parent (no shared nodes / DAG).
Idis stable across frames so expansion/selection works.children(id)returns a deterministic slice for the lifetime of the model reference.contains(id)matches your model storage (used for pruning marks).
Usage
Add the crate from crates.io:
[]
= { = "x.y.z", = false } # replace with latest
Or pull directly from GitHub (e.g. for unreleased changes):
[]
= { = "https://github.com/hexqnt/tui-treelistview", = false }
See examples/ for working snippets.
Examples
Most examples render into an in-memory buffer and exit immediately.
Use demo for an interactive terminal UI (edits are in-memory only).
Run from the workspace root:
Examples that require features:
Interactive demo (path + depth):
Keys: arrows/hjkl navigate, Enter toggle, Shift+Up/Down reorder, Del/d detach, Shift+Del or S delete, y/p move, a add, e rename, q/Esc quit.