TreeView
TreeView is the hierarchy widget for folder-like or outline-like structures.
Use it when the product needs parent-child relationships to stay visible, such as file trees, navigation trees, nested categories, or expandable sidebars. A tree is about structure first and selection second.
Example
use fission::prelude::*;
use std::collections::HashSet;
fission_component! {
pub FolderTree<()> {
props {
items: Vec<TreeItem>,
expanded: HashSet<String>,
selected: Option<String>,
}
}
view(tree, _state, _cx) =>
TreeView(
items: tree.items.clone(),
expanded_ids: tree.expanded.clone(),
selected_id: tree.selected.clone(),
)
}
The parent builds real folder records with registered selection actions and
durable folder ids. It owns expansion and selection sets; this presentation
component neither fabricates folders nor implements a second navigation model.
Field table
| | | |
|---|
| | Root items in the hierarchy. | |
| | Item ids whose children should currently be shown. | |
| | Currently selected item id. | |
State ownership and current behavior
TreeView is another explicitly controlled widget. It does not own expansion state, selection state, or navigation rules. It simply reads expanded_ids and selected_id and renders the tree accordingly.
The checked-in renderer is strongest today as a hierarchical selection view: it indents children, highlights the selected row, and can show nested structure clearly. One important limitation is that while TreeItem has an on_toggle field, the current renderer does not provide a built-in expansion toggle control that dispatches it. If you need full interactive expand-collapse behavior today, validate the exact user experience carefully and be prepared to compose around that limitation.
Specific advice
Trees can become deep quickly. If the hierarchy is only one or two levels deep, a simpler list or grouped navigation often reads better. Use a tree when the structure itself is important for orientation.
Check the tree in context
Keep expanded_ids and selected_id in application state, and give every TreeItem a stable id.
The current renderer shows the controlled expanded and selected values, but does not provide a built-in expansion toggle. If users need to change expansion, compose and test that interaction explicitly.
Test nested labels, selected-state semantics, and long paths in the width where the tree will actually appear.