TreeItem
TreeItem is the recursive data record used by TreeView.
Each item represents one node in a hierarchy. It can have its own label, optional icon, child items, and selection or expansion actions.
Example
use fission::prelude::*;
let item = TreeItem {
id: "src".into(),
icon: None,
label: "src/".into(),
children: vec![TreeItem {
id: "main_rs".into(),
icon: None,
label: "main.rs".into(),
children: vec![],
on_toggle: None,
on_select: Some(open_main_file_action),
}],
on_toggle: Some(toggle_src_folder_action),
on_select: Some(select_src_folder_action),
};
Field table
| Field | Type | Meaning | Notes / default behavior |
|---|---|---|---|
id | String | Stable item identifier. | Required. Used by TreeView.expanded_ids and selected_id. |
icon | Option<String> | Optional leading icon source. | Defaults to None. |
label | String | Visible node label. | Required. |
children | Vec<TreeItem> | Child nodes nested under this item. | Defaults to an empty list. |
on_toggle | Option<ActionEnvelope> | Intended expansion-toggle action. | Present in the public struct, but see note below. |
on_select | Option<ActionEnvelope> | Action fired when the row is selected. | Defaults to None. |
Current implementation note
TreeItem exposes on_toggle, but the checked-in TreeView renderer does not currently render a separate expansion affordance or invoke that action for you. Expansion is still reflected through expanded_ids, but the interaction path must be composed carefully at the app level.
Related
TreeView, Breadcrumb, Icon, and Text.