The CheckBox enables you to style
input type="checkbox" elements.
The CheckBox lets the user toggle between checked and unchecked states. All regular
input type="checkbox" HTML attributes and Angular bindings are applicable.
The CheckBox can be associated with an HTML
label element like the regular
<input type="checkbox"> or with the
You can use the CheckBox in template-driven or reactive forms.
The template-driven forms enable you to bind the CheckBox to the forms model by using the
The following example demonstrates how to use the CheckBox in a template-driven form.
FormGroup provides a way to render reactive forms. For more details, refer to the Angular Documentation.
The following example demonstrates how to use the CheckBox in a reactive form.
The following example demonstrates how to use the CheckBox within a
FormField component and provide hint and error messages.
You can make the CheckBox required.
To do so use one of the following:
- Angular property binding syntax
- Angular Form Validator
The CheckBox can display an
indeterminate state when the respective property is set to
indeterminate state is independent of the
checked state and upon user interaction the current
checked state will be displayed.
By default, the CheckBox is enabled.
To disable user interaction with the element, use the
disabled attribute or Angular property binding.