Switch
rust
pub fn switch(args: impl Into<SwitchArgs>, state: SwitchState)The switch component displays a toggle that can switch between on and off states.
Arguments
args: impl Into<SwitchArgs>This argument configures the style of the
switchcomponent, including size, color, border, and other properties. You can useSwitchArgsBuilderto construct it.state: SwitchStateThis argument manages the state of the
switchcomponent, including whether it is currently on or off.SwitchStateis a clonable struct that encapsulates a shared reference to the state internally. You can create an initial state withSwitchState::new(bool). Use thestate.toggle()method to toggle the switch state.
Preview
