Checkboxes allow the user to select one or more items from a set.
Checkboxes can be used to turn an option on or off.
If you have multiple options appearing in a list, you can preserve space by using checkboxes instead of on/off switches. If you have a single option, avoid using a checkbox and use an on/off switch instead.
{{ādemoā: āCheckboxes.jsā}}
You can provide a label to the Checkbox
thanks to the FormControlLabel
component.
{{ādemoā: āCheckboxLabels.jsā}}
Use the size
prop or customize the font size of the svg icons to change the size of the checkboxes.
{{ādemoā: āSizeCheckboxes.jsā}}
{{ādemoā: āColorCheckboxes.jsā}}
{{ādemoā: āIconCheckboxes.jsā}}
You can control the checkbox with the checked
and onChange
props:
{{ādemoā: āControlledCheckbox.jsā}}
A checkbox input can only have two states in a form: checked or unchecked. It either submits its value or doesnāt. Visually, there are three states a checkbox can be in: checked, unchecked, or indeterminate.
You can change the indeterminate icon using the indeterminateIcon
prop.
{{ādemoā: āIndeterminateCheckbox.jsā}}
When indeterminate is set, the value of the
checked
prop only impacts the form submitted values. It has no accessibility or UX implications.
FormGroup
is a helpful wrapper used to group selection control components.
{{ādemoā: āCheckboxesGroup.jsā}}
You can change the placement of the label:
{{ādemoā: āFormControlLabelPosition.jsā}}
Here is an example of customizing the component. You can learn more about this in the overrides documentation page.
{{ādemoā: āCustomizedCheckbox.jsā}}
šØ If you are looking for inspiration, you can check MUI Treasuryās customization examples.
(WAI-ARIA: https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/)
<label>
element (FormControlLabel).aria-label
, aria-labelledby
, title
) via the inputProps
prop.<Checkbox
value="checkedA"
inputProps={{
'aria-label': 'Checkbox A',
}}
/>