Checkbox
Overview
The Checkbox
component is a controlled input that can be used to allow users to select one or more options from a set. It supports a variety of states including checked, unchecked, indeterminate, disabled, and error.
When to use
- When you need to present a list of options and allow the user to select one or more of them.
- When you need to provide a binary choice or toggle feature.
When to consider an alternative
- When you need to allow the user to select one option from a small set of options, consider using the
Radio
component.
Component
Default
Checkbox can be used as a controlled or uncontrolled input. To make controlled pass with checked
and onChange
props.
Disabled
The Checkbox component can be disabled using the disabled
prop.
Indeterminate
The Checkbox component can be in an indeterminate state using the indeterminate
prop. This is typically used to indicate a "partially checked" state in nested checkboxes.
Error
The Checkbox component can be in an error state using the error
prop. This is typically used to indicate that there was a problem with the user's selection.
Controlled by other element
Properties
Default
Property | Type | Required | Default |
---|---|---|---|
utilClassNames | String | false | - |
children | Node | false | - |
checkboxRef | Shape {
"current": "Any"
} | false | - |
label | String | false | - |
checked | Bool | false | - |
disabled | Bool | false | - |
error | Bool | false | - |
indeterminate | Bool | false | - |
onChange | Func | false | - |