pub fn switch(args: impl Into<SwitchArgs>, state: SwitchState)Expand description
§switch
Renders an animated on/off toggle switch.
§Usage
Use for settings or any other boolean state that the user can control.
§Parameters
args— configures the switch’s appearance andon_togglecallback; seeSwitchArgs.state— a clonableSwitchStateto manage the checked/unchecked state.
§Examples
use std::sync::Arc;
use tessera_ui_basic_components::switch::{switch, SwitchArgsBuilder, SwitchState};
let switch_state = SwitchState::new(false);
switch(
SwitchArgsBuilder::default()
.on_toggle(Arc::new(|checked| {
println!("Switch is now: {}", if checked { "ON" } else { "OFF" });
}))
.build()
.unwrap(),
switch_state,
);