Checkbox

Checkboxes select any number of items from a set, or turn a single option on or off.

There's one type of checkbox in Material. Use this selection control when the user needs to select one or more options from a list.

Three checkboxes in a row that are unselected, selected, and indeterminate

View interactive demo inline.

Open interactive demo in new tab.

Checkboxes may be standalone, pre-checked, or indeterminate.

<petal-checkbox touch-target="wrapper"></petal-checkbox>
<petal-checkbox touch-target="wrapper" checked></petal-checkbox>
<petal-checkbox touch-target="wrapper" indeterminate></petal-checkbox>

Associate a label with a checkbox using the <label> element.

<label>
  <petal-checkbox touch-target="wrapper"></petal-checkbox>
  Checkbox one
</label>

<petal-checkbox id="checkbox-two" touch-target="wrapper"></petal-checkbox>
<label for="checkbox-two">Checkbox two</label>

Add an aria-label attribute to checkboxes without labels or checkboxes whose labels need to be more descriptive.

<petal-checkbox aria-label="Select all checkboxes"></petal-checkbox>

<label>
  <petal-checkbox aria-label="Agree to terms and conditions"></petal-checkbox>
  Agree
</label>
bookmark

checkboxes are not automatically labelled by <label> elements and always need an aria-label. See b/294081528.

Checkbox supports Material theming and can be customized in terms of color and shape.

TokenDefault value
--md-checkbox-outline-color--md-sys-color-on-surface-variant
--md-checkbox-selected-container-color--md-sys-color-primary
--md-checkbox-selected-icon-color--md-sys-color-on-primary
--md-checkbox-container-shape2px
<style>
  :root {
    /* System tokens */
    --md-sys-color-primary: #006a6a;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-on-surface-variant: #3f4948;

    /* Component tokens */
    --md-checkbox-container-shape: 0px;
  }
</style>

<petal-checkbox touch-target="wrapper"></petal-checkbox>
<petal-checkbox touch-target="wrapper" checked></petal-checkbox>
PropertyAttributeTypeDefaultDescription
checkedcheckedbooleanfalseWhether or not the checkbox is selected.
indeterminateindeterminatebooleanfalseWhether or not the checkbox is indeterminate.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#indeterminate_state_checkboxes
requiredrequiredbooleanfalseWhen true, require the checkbox to be selected when participating in form submission.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#validation
valuevaluestring'on'The value of the checkbox that is submitted with a form when selected.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#value
namenamestringundefinedThe HTML name to use in form submission.
disableddisabledbooleanundefinedWhether or not the element is disabled.
formHTMLFormElementundefinedThe associated form element with which this element's value will submit.
labelsNodeListundefinedThe labels this element is associated with.
validityValidityStateundefinedReturns a ValidityState object that represents the validity states of the element.
https://developer.mozilla.org/en-US/docs/Web/API/ValidityState
validationMessagestringundefinedReturns a validation error message or an empty string if the element is valid.
https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/validationMessage
willValidatebooleanundefinedReturns whether an element will successfully validate based on forms validation rules and constraints.
Disabled and readonly elements will not validate.
https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate
MethodParametersReturnsDescription
formResetCallbackNonevoid
formStateRestoreCallbackstatevoid
checkValidityNonebooleanChecks the element's constraint validation and returns true if the element is valid or false if not.
If invalid, this method will dispatch an invalid event.
https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/checkValidity
reportValidityNonebooleanChecks the element's constraint validation and returns true if the element is valid or false if not.
If invalid, this method will dispatch a cancelable invalid event. If not canceled, a the current validationMessage will be reported to the user.
https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/reportValidity
setCustomValidityerrorvoidSets the element's constraint validation error message. When set to a non-empty string, validity.customError will be true and validationMessage will display the provided error.
Use this method to customize error messages reported.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity
EventTypeBubblesComposedDescription
changeEventYesNoThe native change event on <input>
inputInputEventYesYesThe native input event on <input>
About
IntroductionQuick StartMaterial 3 ExpressiveRoadmapSupportBundle SizesDesign tokensToken update v34LicensingVisual testingReleasing
Theming
Material ThemingColorTypographyShape
Components
Button groupButtonsCheckboxChipsDialogsFloating action button (FAB)Icon ButtonsListsMenusProgress indicatorsRadioRippleSelectSlidersSwitchTabsText field