Skip to main content

toggle_group

Function toggle_group 

Source
pub fn toggle_group<I, V, L>(
    key: impl Into<String>,
    current: &impl Display,
    options: I,
) -> El
where I: IntoIterator<Item = (V, L)>, V: Display, L: Into<String>,
Expand description

A row of mutually-exclusive toggle items — pick one. current is the currently-pressed value, formatted via std::fmt::Display and compared against each option’s value. options is an iterable of (value, label) pairs.

Per-item routed keys are {key}:toggle:{value}. Apps fold those back into their value field with apply_event_single.

Use this for view-mode pickers (list / grid / kanban), text alignment (left / center / right), and similar one-of-N choices without panel content. When each option owns a panel, reach for crate::widgets::tabs instead.