pub fn switch<S, R>(text: impl Into<String>, on: Sig<S, bool, R>) -> El<S>Expand description
An on and off switch labeled text, bound to on.
It is a native checkbox with role="switch", so a screen reader says
“switch, on” rather than “checkbox, checked”, and Space toggles it.
use hypersig::Signals;
use hypersig_ui::switch;
use serde::{Deserialize, Serialize};
#[derive(Signals, Serialize, Deserialize)]
struct Settings {
airplane: bool,
}
let airplane = switch::<Settings, _>("Airplane mode", Settings::airplane());
assert!(airplane.render().contains(r#"role="switch""#));