Checkbox
A native input type="checkbox" with a styled indicator for checked and indeterminate. Inside a Field it takes the field's id, disabled, required and ARIA wiring.
Use for
- a checkbox in a form
- a select-all checkbox with an indeterminate state
- a row selection checkbox
Practices
| Guidance | Practice |
|---|---|
| Do | Put it in a Field with a Field.Label so it gets a label and its messages. |
| Do | Use indeterminate for a select-all when only some rows are selected. |
| Don’t | Expect xstyle to reach the input. It styles the wrapper (cl-checkbox); every other prop and the ref go to the input. |
API reference
Checkbox
A wrapper span around the input (cl-checkbox-input) and two indicators (cl-checkbox-indicator with data-state). The wrapper carries data-size and data-disabled.
Slot: cl-checkbox
| Prop | Type | Description |
|---|---|---|
size | 'sm' | 'md' | sm or md.Default: 'md' |
indeterminate | boolean | Sets the input to its indeterminate state.Default: false |
Examples
In a field
<Field.Root orientation='horizontal'>
<Checkbox checked={accepted} onChange={e => setAccepted(e.target.checked)} />
<Field.Content>
<Field.Label>{m.acceptTerms}</Field.Label>
</Field.Content>
</Field.Root>