Switch
rust
pub fn switch(args: impl Into<SwitchArgs>, state: Arc<RwLock<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
switch
component, including size, color, border, and other properties. You can useSwitchArgsBuilder
to construct it.state: Arc<RwLock<SwitchState>>
This argument manages the state of the
switch
component, including whether it is currently on or off. You can create an initial state withSwitchState::new(bool)
. Use theSwitchState::toggle(&mut self)
method to toggle the switch state.