pub fn switch(args: impl Into<SwitchArgs>)
Expand description
A UI component that displays a toggle switch for boolean state.
The switch
component provides a customizable on/off control, commonly used for toggling settings.
It can be controlled via external state (SwitchState
) or by using the checked
and on_toggle
parameters.
§Arguments
args
- Parameters for configuring the switch, seeSwitchArgs
.
§Example
use tessera_ui_basic_components::switch::{SwitchArgs, switch};
use std::sync::Arc;
switch(SwitchArgs {
checked: false,
on_toggle: Arc::new(|checked| {
println!("Switch toggled: {}", checked);
}),
width: tessera_ui::Dp(60.0),
height: tessera_ui::Dp(36.0),
..Default::default()
});