Checkbox
Anatomy
A labeled checkbox input with optional description, indeterminate state, and validation styling. Wraps a standard HTML checkbox with custom indicator and text layout.
maud_ui::primitives::checkbox
Props
Generated from public Rust fields. Defaults are evaluated from the implementation.
| Prop | Type | Default | Description |
|---|---|---|---|
name | String | "checkbox" | No description |
value | String | "on" | No description |
label | String | "Checkbox" | No description |
description | Option<String> | None | No description |
id | String | "checkbox" | No description |
checked | bool | false | No description |
indeterminate | bool | false | No description |
disabled | bool | false | No description |
required | bool | false | No description |
aria_invalid | bool | false | No description |
Examples
Checkbox
Usage and composition
Import
use maud_ui::primitives::checkbox::{self, Props};
Example
use maud::html;
use maud_ui::primitives::checkbox;
html! {
(checkbox::render(checkbox::Props {
name: "agree".into(),
value: "yes".into(),
label: "I agree to the terms".into(),
id: "terms-checkbox".into(),
checked: false,
description: None,
indeterminate: false,
disabled: false,
required: false,
aria_invalid: false,
}))
}
Related
Label, RadioButton (for mutually exclusive options), Form (for grouping checkboxes)
Shadcn reference
https://ui.shadcn.com/docs/components/base/checkbox
Accessibility
Checkbox input is labeled via a <label> element wrapping the control and text. Indeterminate state is visual only (CSS class). The aria-invalid attribute signals form validation errors. Keyboard: Space/Enter toggles, Tab navigates.