Checkbox
Checkboxes are most commonly used to give users a way to make a range of selections (zero, one, or multiple).
Example
Live Editor
Result
Loading...
Usage Rules
Do:
- Have options unchecked by default
- Use if multiple options can be selected
- Use as a single option with yes/no or on/off answer
- Layout your option list vertically, with one choice per line
- Use active wording and avoid negations in labels
- Use in parent-child combination with other checkboxes
Don’t:
- Use as action buttons
- Use if only one option can be selected
Variants
Disabled
Live Editor
Result
Loading...
Helper Text
You can add an extra description to radio using helperText
.
Live Editor
Result
Loading...
Indeterminate
A Checkbox can be in an indeterminate state, controlled using the indeterminate
prop. Using it changes the Checkbox's visual appearance, but not its value. The indeterminate
prop takes precedence over checked
prop.
Live Editor
Result
Loading...
Ref
Live Editor
Result
Loading...
Props
Name | Type | Default |
---|---|---|
disabled Native HTML attribute: Link |
| — |
css Add custom styles to this component. Use with caution. Learn more here: Link |
| — |
inputFieldCss |
| — |
label The label for the checkbox |
| — |
aria-label Provide at least one label(visual or non-visual) property for better accessibility. Check Accessibility page for more info: Link |
| — |
aria-labelledby Provide at least one label(visual or non-visual) property for better accessibility. Check Accessibility page for more info: Link |
| — |
id Native HTML attribute: Link .
Internally, this component uses a random id. We use it to associate an input with a label element.
As the random id might break snapshot tests it can be overridden by setting an explicit id. |
| — |
onKeyDown Keyboard event callback |
| — |
indeterminate Don't use this prop together with the 'checked' prop |
| false |
checked Native HTML attribute: Link |
| — |
required Native HTML attribute: Link |
| — |
readOnly Native HTML attribute: Link |
| — |
onChange Native HTML callback: Link |
| — |
value Native HTML attribute: Link |
| — |
helperText HelperText for checkbox |
| — |
tabIndex Tab index |
| — |
ref |
| — |
key |
| — |
data-{foo} Data attributes can be used by testing libraries to retrieve components or assert their existence |
| — |
* - the prop is required. |