Overview
<mat-checkbox> provides the same functionality as a native <input type="checkbox"> enhanced with Material Design styling and animations.
Basic Usage
- Template
- Reactive Forms
API Reference
MatCheckbox
Selector:mat-checkbox
Exported as: matCheckbox
Inputs
Whether the checkbox is checked.
Whether the checkbox is disabled.
Whether the checkbox is indeterminate. This is also known as “mixed” mode and can be used to represent a checkbox with three states.
Whether the label should appear after or before the checkbox. Defaults to ‘after’.
Whether the checkbox is required.
Theme color of the checkbox. This API is supported in M2 themes only.
Whether the checkbox has a ripple.
Whether the checkbox should remain interactive when it is disabled.
The value attribute of the native input element.
A unique id for the checkbox input. If none is supplied, it will be auto-generated.
Name value will be applied to the input element if present.
Tabindex for the checkbox.
Attached to the aria-label attribute of the host element.
Users can specify the
aria-labelledby attribute which will be forwarded to the input element.The ‘aria-describedby’ attribute is read after the element’s label and field type.
Outputs
Event emitted when the checkbox’s
checked value changes.Event emitted when the checkbox’s
indeterminate value changes.Methods
Focuses the checkbox.
Toggles the
checked state of the checkbox.MatCheckboxChange
The source checkbox of the event.
The new
checked value of the checkbox.Accessibility
- The checkbox uses a native
<input type="checkbox">element - The checkbox label is associated with the input using a
<label>element - Use
aria-labeloraria-labelledbywhen the checkbox doesn’t have a visible label - The component supports keyboard interaction (Space to toggle)
- Disabled checkboxes are not focusable and are announced as disabled to screen readers