Switch
Switch represents a controlled binary setting.
Control an immediate setting
Section titled “Control an immediate setting”Switch("Use dark appearance", dark_mode) .OnChanged([dark_mode](bool checked) { dark_mode = checked; })Construct it with bool or State<bool>, with or without a StringVariant label.
The caller remains authoritative and must accept or reject each emitted value.
Use a switch for an immediately applied setting. Use a checkbox when the value participates in a form or a set of independently submitted choices.
Interaction and theme
Section titled “Interaction and theme”SwitchStyle controls track and thumb geometry, checked and unchecked colors and borders, disabled states, state-layer size, radius, and animation duration.
Switch role, checked state, label, focus, and activation semantics are provided automatically.
- Constructors:
Switch(bool|State<bool>)andSwitch(StringVariant, bool|State<bool>). - Event:
.OnChanged(function)withbool. - Theme style:
SwitchStyle. - Common modifiers:
Enabled,Semantics,Opacity.

