Fusuma

Components / Components

tree_item

One row of a tree: indented by depth, a triangle that opens and closes it when it has children (expanded is Some), and the label as a choice.

Try it

This is the Pickers page of the gallery, running in your browser: tree_item is on it, and it is the real widget. Press Run, then use it.

Live: Pickers, where tree_item is usedOpen full size

Also on this pagecalendartime_pickeraccordionsplit_viewselect

One row of a tree: indented by depth, a triangle that opens and closes it when it has children (expanded is Some), and the label as a choice. Build a tree by putting a row and then, under show(expanded, column(..)), its children's rows one level deeper.

One row of a tree, depth levels in. expanded is None for a leaf, Some(open) for a branch; on_toggle opens and closes it, on_select chooses it.

Signature

pub fn tree_item<'a, M: Clone + 'a>( label: &'a str, depth: u32, expanded: Option<bool>, selected: bool, on_toggle: M, on_select: M, ) -> impl View<M> + 'a

Example

use fusuma::{column, tree_item};
let view = column((
    tree_item("src", 0, Some(true), false, (), ()),
    tree_item("main.rs", 1, None, true, (), ()),
));
let built = fusuma::doc::built::<(), _>(&view);
assert!(built.texts().contains(&"main.rs"));

All components · Source