Skip to main content

Module checkbox

Module checkbox 

Source
Expand description

Checkbox — a two-state or tristate checkbox with an optional label.

Checkbox renders a square (or rounded-square / circle) toggle box alongside an optional label and caption. Two modes are supported:

  • Two-state (Checkbox::new): toggles a Signal<bool> between true (checked) and false (unchecked) on click or Space.
  • Tristate (Checkbox::tristate): cycles a Signal<CheckState> between Checked and Unchecked on user interaction; the Indeterminate state is set only by external sources such as TreeCheckedModel aggregation — clicking from Indeterminate goes to Checked, not a further third state.

Chrome (box shape, fill, focus ring) is driven by the active CheckboxStyle; three visual variants are available via [CheckboxVariant].

§Accessibility

Announces as Role::CheckBox. A label is required in debug builds unless .labels_hidden(true) is set (for embedding inside a composite row that owns the AT name). Keyboard: Space toggles; lone-KeyUp guard prevents spurious toggle when focus is restored after a shortcut.

let checked = Signal::new(false);
let _cb = Checkbox::new(checked)
    .label(lit!("Accept terms and conditions"));

Structs§

Checkbox
A checkbox that toggles a Signal<bool> or cycles a Signal<CheckState>.