Skip to main content

Module list

Module list 

Source
Expand description

ListItem โ€” a clickable, themed row used to build list-style UIs.

State (the selected index) lives on the caller, just like Checkbox holds &mut bool. The matching pattern is:

โ“˜
egui::ScrollArea::vertical().show(ui, |ui| {
    for (i, item) in items.iter().enumerate() {
        let r = ui.add(
            sc::ListItem::new(item)
                .selected(selected == Some(i)),
        );
        if r.clicked() {
            selected = Some(i);
        }
    }
});

For visual grouping a List container wraps the rows in a bordered, rounded frame.

Structsยง

List
A bordered, rounded container that visually groups a list of ListItems.
ListItem
One row in a list. Stateless; the caller controls selected.