Checkbox
A tri-state checkbox control with support for checked, unchecked, and indeterminate states.
Primitive: CheckboxARIA: role="checkbox"Keyboard: Space
Receive email notifications
Send marketing emails
Disabled option
checkbox_example.rs
use stratum_leptos::*;
view! {
<Checkbox default_checked=true>
"Receive email notifications"
</Checkbox>
<Checkbox>"Send marketing emails"</Checkbox>
<Checkbox disabled=true>"Disabled option"</Checkbox>
}
Installation
stratum add checkboxProps
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | Option<TriState> | None | Controlled checked state (True, False, Mixed) |
| default_checked | bool | false | Initial state for uncontrolled usage |
| disabled | bool | false | Prevents interaction |
| required | bool | false | Marks as required for form validation |
| on_change | Option<Callback<bool>> | None | Fires when checked state changes |
| class | Option<String> | None | Additional CSS classes |
Accessibility
- Renders with
role="checkbox"andaria-checked(supports"true","false","mixed"). Spacekey toggles the checkbox.- Supports
aria-disabledandaria-required.