Skip to main content

toolbar_segmented

Function toolbar_segmented 

Source
pub fn toolbar_segmented(
    id: ElementId,
    segments: Vec<Segment>,
    selected: impl Binding<usize>,
) -> ToolbarEntry
Expand description

A row of mutually exclusive choices as one native control (docs/toolbars.md): the platform’s segmented control, bound to selected.

Reach for this instead of N toggles whenever exactly one choice is on at a time: a theme picker, a view mode. The platform then draws it as the single control it is, announces it as one, and keeps the exclusivity itself; three toggles leave all of that to the app.

ⓘ
toolbar_segmented(day_core::id!(theme), vec![
    segment(tr("light")).icon(Symbol::Light),
    segment(tr("system")).icon(Symbol::Auto),
    segment(tr("dark")).icon(Symbol::Dark),
], mode)
Day API ↩ Guides· daybrite.dev