Fusuma

Components / Basics

checkbox

A checkbox with text, ticked or not.

Try it

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

Live: Selection, where checkbox is usedOpen full size

A checkbox with text, ticked or not.

.on_toggle(f) sends what f makes of the new state; the app keeps the state and gives it back on the next view.

Signature

pub const fn checkbox<M>(text: &str, checked: bool) -> Checkbox<'_, M>

Methods

  • .enabled(enabled: bool) -> Self — Whether it can be used (it can by default).
  • .on_toggle(f: fn(bool) -> M) -> Self — Sends a message made from the new state (fn(bool) -> M, such as a variant of the message enum) when it is toggled.

Example

use fusuma::{checkbox, column};
let view = column((checkbox("Remember me", true).on_toggle(|on| on), checkbox("Subscribe", false).on_toggle(|on| on)));
let built = fusuma::doc::built::<bool, _>(&view);
assert_eq!(built.texts(), ["Remember me", "Subscribe"]);

All components · Source