pub fn checkbox(args: impl Into<CheckboxArgs>, state: Arc<CheckboxState>)Expand description
§checkbox
Renders an interactive checkbox with an animated checkmark.
§Usage
Use to capture a boolean (true/false) choice from the user.
§Parameters
args— configures the checkbox’s appearance andon_togglecallback; seeCheckboxArgs.state— a clonableCheckboxStatethat manages the checkmark and ripple animations.
§Examples
use std::sync::{Arc, Mutex};
use tessera_ui_basic_components::checkbox::{checkbox, CheckboxArgs, CheckboxState};
let is_checked = Arc::new(Mutex::new(false));
let on_toggle = {
let is_checked = is_checked.clone();
Arc::new(move |new_state| {
*is_checked.lock().unwrap() = new_state;
})
};
let args = CheckboxArgs { on_toggle, ..Default::default() };
// In a real UI, the on_toggle callback would be fired on click.
// For this test, we can simulate the callback being called.
(args.on_toggle)(true);
assert_eq!(*is_checked.lock().unwrap(), true);
(args.on_toggle)(false);
assert_eq!(*is_checked.lock().unwrap(), false);