Checkbox
stableA control that allows the user to toggle between checked, not checked, and indeterminate.
Basic usage
Examples
Indeterminate state
Use the indeterminate state for a "select all" parent checkbox.
Checked, unchecked and indeterminate
Checkbox supports standard and indeterminate states for bulk selection flows.
Semantic colors
Use the color prop to visually reinforce the meaning of each checkbox option.
Features
- Supports indeterminate state.
- Full keyboard navigation.
- Can be controlled or uncontrolled.
Installation
bash
pnpm dlx structyl add checkboxAPI Reference
Checkbox
A checkbox supporting an indeterminate state.
| Prop | Type | Default |
|---|---|---|
| checked | boolean | 'indeterminate'Controlled checked state. | — |
| defaultChecked | boolean | 'indeterminate'Initial checked state when uncontrolled. | — |
| onCheckedChange | (checked) => voidCalled when the checked state changes. | — |
| disabled | booleanDisable the checkbox. | false |
| required | booleanMark as required. | false |
| name | stringName for form submission. | — |
| className | stringAdditional Tailwind classes, merged with the component defaults. | — |
Keyboard interactions
Adheres to the WAI-ARIA design pattern .
| Key | Description |
|---|---|
| Space | Toggles the checkbox. |