Skip to main content

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

FieldTypeMeaningNotes / default behavior
idStringStable item identifier.Required. Used by TreeView.expanded_ids and selected_id.
iconOption<String>Optional leading icon source.Defaults to None.
labelStringVisible node label.Required.
childrenVec<TreeItem>Child nodes nested under this item.Defaults to an empty list.
on_toggleOption<ActionEnvelope>Intended expansion-toggle action.Present in the public struct, but see note below.
on_selectOption<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.

TreeView, Breadcrumb, Icon, and Text.