Skip to main content

Checkbox

Turns one option on or off.

<mm-checkbox name="notify" value="failures" label="Notify me when this pipeline fails" checked></mm-checkbox>

Guidance​

Checkboxes turn one option on or off: "Notify me when this pipeline fails", "Include deprecated assets". The label sits beside the 16px box and is clickable, with an optional description line under it. indeterminate shows a dash for a parent whose children are mixed.

The checked box is filled with ink (mm-text) and carries an mm-on-inverse tick. It is not burnt sienna: the guidelines reserves burnt sienna for the primary action, links, the active tab and the current selection, at most once per row. A settings list can hold a dozen ticked boxes, which would spend the accent many times over and read as a row of selections. Ink keeps the state unmistakable at 17:1 while leaving the accent for what it marks.

Keyboard: Space toggles (https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/). The control is a native checkbox inside the shadow root, so it is announced as mixed when indeterminate.

Form-associated: submits value (default on) under name only while checked, as a native checkbox does. required means it must be ticked. The checked attribute is the default the form resets to.

Properties​

PropertyAttributeTypeDefaultDescription
checkedcheckedbooleanfalse
indeterminateindeterminatebooleanfalseShows a dash for a mixed state; cleared when the user toggles.
valuevaluestring'on'Submitted under name while checked. Default on.
descriptiondescriptionstring''A second line under the label.
labellabelstring''Field label. Rendered above the control unless hide-label, and always the accessible name.
helphelpstring''Help text under the control.
errorerrorstring''Error text: a sentence saying what to fix. Shows the crimson border, an icon and sets aria-invalid.
hideLabelhide-labelbooleanfalseHides the label visually; it stays the accessible name.
optionaloptionalbooleanfalseMarks the field as optional, in words.
namenamestring''Name submitted with the form.
disableddisabledbooleanfalseDisables the control and excludes it from submission.
requiredrequiredbooleanfalseRequires a value before the form submits.
formHTMLFormElement | null
validityValidityState
validationMessagestring
willValidateboolean
isDisabledbooleanTrue when disabled directly or by a disabled ancestor fieldset.

Methods​

MethodDescription
click()Toggles like a click.
formResetCallback()Restore the initial value when the owning form resets.

Events​

EventDetailDescription
mm-inputCustomEvent<MmCheckedDetail>When the box is toggled.
mm-changeCustomEvent<MmCheckedDetail>When the box is toggled.
inputInputEventNative, composed; when the box is toggled.
changeEventNative, re-dispatched on the host when the box is toggled.

CSS parts​

PartDescription
controlThe native checkbox drawn as the box.
labelThe label beside the box.
descriptionThe description line.
helpThe help line.
errorThe error line.

Examples​

Every state of mm-checkbox in Storybook, with keyboard and screen reader tests.