Checkbox is a specialized form control that emits an <input>
with a type of checkbox.
Different states of a checkbox can be set using the checked
and indeterminate
properties.
Inline checkboxes will be shown on the same horizontal row rather than stacked. Use the inline
property for this option.
Use the required
property to mark checkboxes as required. Labels will display a visual indication while input controls will have a required
attribute added to help with assistive technologies.
The validation tooltip will be triggered when hovering over the icon next to the checkbox. Use the validationMessage
property to set a validation state.
Use the disabled
property to disable a checkbox. A disabled element is unusable and un-clickable.
ReadOnly is not a supported state for the Checkbox component.
Property | Type | Default | Description |
---|---|---|---|
label | String | Required | Text label for checkbox input. |
checked | Boolean | false | When true , the checkbox renders as “checked”. |
className | String | Any custom classes to add to the <label> element. | |
disabled | Boolean | false | When true , the checkbox gets the disabled attribute. |
hiddenLabel | Boolean | false | When true , the label will not be shown. It will still be present with a screen-reader-only class which allows it to be read to assistive technologies. |
indeterminate | Boolean | false | When true , the checkbox renders a “mixed” state (shows as a “-“ in the checkbox). |
inline | Boolean | false | When true , checkboxes will be shown on the same row rather than stacked. |
labelClassName | String | Classes to be added to the wrapping <label> tag. | |
labelProps | Object | Other props to be spread onto the wrapping <label> tag. | |
required | Boolean | false | Adds the required attribute to the <input> element. NOTE: This does not perform any validation, but rather just marks the field as required. |
size | String | 'lg' | Size of the <label> element. Options are 'lg' , 'md' , 'sm' . |
validationMessage | Object | An object identifying a validation message. The object will include properties for state and text ; e.g., { state: 'warning', text: 'This is your last warning' } . The options for state are 'error' and 'warning' . text is the message shown in the validation tooltip; as with all text, it must be localized. |
Property | Parameters | Description |
---|---|---|
onChange | checked (Boolean), event | Callback function for onChange events. |