Fusuma

Components / Basics

switch

A switch with text, on or off.

Try it

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

Live: Controls, where switch is usedOpen full size

A switch with text, on or off.

.on_toggle(f) sends what f makes of the new state.

Signature

pub const fn switch<M>(text: &str, on: bool) -> Switch<'_, M>

Methods

  • .on_toggle(f: fn(bool) -> M) -> Self — Sends a message made from the new state when it is toggled.

Example

use fusuma::{column, switch};
let view = column((switch("Wi-Fi", true).on_toggle(|on| on),));
let built = fusuma::doc::built::<bool, _>(&view);
assert_eq!(built.texts(), ["Wi-Fi"]);

All components · Source