Checkbox
Checkboxes let people select one or more items from a set, or turn an option on or off.
<label>
<md-gb-checkbox></md-gb-checkbox>
Remember me
</label>Install with shadcn/ui: npx shadcn@latest add https://material-web.dev/3.0/r/md-checkbox.json (setup)
Usage guidelines
Link to “Usage guidelines”- Select from a set. Use checkboxes when people can pick any number of options from a list, or to turn one option on or off.
- Label every checkbox. The label is the adjacent text, and it should say what checking the box does.
- Use a parent for a group. A parent checkbox shows an indeterminate state when only some of its children are checked.
- Don't apply density by default. Let people opt in to a denser layout.
Anatomy
Link to “Anatomy”A checkbox is one element. A <label> next to it, or around it, provides the text.
<label>
<md-gb-checkbox></md-gb-checkbox>
Send me updates
</label>Examples
Link to “Examples”Checked and indeterminate
Link to “Checked and indeterminate”Add checked for a selected checkbox. Add indeterminate for a parent whose children are partly selected.
<label>
<md-gb-checkbox checked></md-gb-checkbox>
Email
</label>
<label>
<md-gb-checkbox indeterminate></md-gb-checkbox>
All notifications
</label>Error
Link to “Error”Add error to mark a checkbox as invalid. With required, it must be checked to submit a form.
<label>
<md-gb-checkbox required error></md-gb-checkbox>
I accept the terms
</label>Disabled
Link to “Disabled”A disabled checkbox can't be changed.
<label>
<md-gb-checkbox disabled></md-gb-checkbox>
Unavailable option
</label>Density
Link to “Density”Set density from 0 (default) to -3 to shrink the checkbox. The touch target stays 48px.
<label>
<md-gb-checkbox density="-2"></md-gb-checkbox>
Compact option
</label>Parent and children
Link to “Parent and children”Call linkParentCheckbox(parent, children) from checkbox-group.js. Checking the parent checks every child, and a partial selection makes the parent indeterminate.
<label>
<md-gb-checkbox id="all"></md-gb-checkbox>
All notifications
</label>
<label>
<md-gb-checkbox class="channel" checked></md-gb-checkbox>
Email
</label>
<label>
<md-gb-checkbox class="channel"></md-gb-checkbox>
Push
</label>import {linkParentCheckbox} from '@material/web/labs/gb/components/checkbox/checkbox-group.js';
const parent = document.querySelector('md-gb-checkbox#all')!;
const children = [...document.querySelectorAll('md-gb-checkbox.channel')];
linkParentCheckbox(parent, children);Accessibility
Link to “Accessibility”- The adjacent
<label>text is the checkbox's accessible name. Usearia-labelwhen there is no visible label or it needs more detail. - Space toggles the focused checkbox, and Tab moves between checkboxes.
- A checkbox exposes its checked, unchecked or mixed state.
<md-gb-checkbox aria-label="Select all messages"></md-gb-checkbox>Compatibility
Link to “Compatibility”Material Design 3Spec checked80% tokens
45 of 82 buildable spec units are tested, 4 are excluded with a written reason and 0 are uncovered (the target is 0). 43 of 54 token declarations match the spec (80%), and 11 have no spec token.
checkbox on m3.material.io (opens in a new tab) How compliance is measured
BaselineWidely availableChrome 124Edge 124Firefox 125Safari 17.4
The component’s own CSS and JavaScript rely only on web platform features that are Baseline widely available: it works in Chrome 124, Edge 124, Firefox 125, Safari 17.4 and later.
It uses no newer features.
Browser support Learn more about Baseline (opens in a new tab)
WAI-ARIAaxe and ARIA 1.3 passCheckbox
Roles the component renders: checkbox (opens in a new tab), textbox (opens in a new tab).
Follows the WAI-ARIA Authoring Practices: Checkbox (opens in a new tab).
2 rendered states run through axe-core and the WAI-ARIA 1.3 role and attribute rules in a real browser, with no known gaps.
WAI-ARIA 1.3 (opens in a new tab) ARIA Authoring Practices (opens in a new tab) Accessibility
Lighthouse97 · 100 · 100 · 100
Performance Accessibility Best practices SEO
Audits under 90:
- Eliminate render-blocking resources
- Minify JavaScript
- Enable text compression
- Network dependency tree
- Render blocking requests
Lighthouse 12.8.2 (desktop, 2026-11-08) on the component alone: its first example on a page of its own, without this site's shell. The modules are the development build (not bundled or minified), so the performance score is indicative.
API reference
Link to “API reference”<md-gb-checkbox>
Link to “<md-gb-checkbox>”A Material Design component.
Properties
Link to “Properties”| Property | Attribute | Type | Default |
|---|---|---|---|
checkedWhether or not the checkbox is selected. |
checked |
boolean |
false |
densityThe density, from 0 (default) to -3. Each step down removes 4px from the checkbox's layout box (48px) and state layer (40px); the touch target stays 48px. Values are clamped to that range. checkbox.md: don't apply density by default; let people opt in to a denser layout. |
density |
Density |
|
errorWhether or not the checkbox is invalid. |
error |
boolean |
false |
indeterminateWhether or not the checkbox is indeterminate. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#indeterminate_state_checkboxes |
indeterminate |
boolean |
false |
requiredWhen 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 |
required |
boolean |
false |
valueThe 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 |
value |
string |
'on' |
Events
Link to “Events”| Event | Description |
|---|---|
changeEvent |
Fired when the checkbox is checked or unchecked. |
inputInputEvent |
Fired when the checkbox is checked or unchecked. |
CSS parts
Link to “CSS parts”| Part | Description |
|---|---|
::part(checkbox) |
The checkbox's root element. |
CSS custom properties
Link to “CSS custom properties”| Property | Description |
|---|---|
--container-color |
|
--container-shape |
|
--container-size |
|
--density-step |
Size removed per density step. |
--icon-color |
|
--icon-size |
|
--outline-color |
|
--outline-width |
|
--state-layer-color |
|
--state-layer-shape |
|
--state-layer-size |
State layer size at density 0. |
--target-size |
The minimum touch target size, kept at any density. |