Switch
A toggle switch for binary on/off states.
Primitive: SwitchARIA: role="switch"Keyboard: Space, Enter
Notifications enabled
Dark mode
Disabled
switch_example.rs
use stratum_leptos::*;
view! {
<Switch default_checked=true>"Notifications"</Switch>
<Switch>"Dark mode"</Switch>
<Switch disabled=true>"Disabled"</Switch>
}Installation
stratum add switchProps
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | Option<bool> | None | Controlled checked state |
| default_checked | bool | false | Initial state for uncontrolled usage |
| disabled | bool | false | Prevents interaction |
| on_change | Option<Callback<bool>> | None | Fires when toggled |
Accessibility
- Renders with
role="switch"andaria-checked. SpaceandEntertoggle the switch.- Focus visible indicator always shown.