CheckBox Overview

The CheckBox enables you to style input type="checkbox" elements.

Basic Usage

The CheckBox lets the user toggle between checked and unchecked states. All regular input type="checkbox" HTML attributes and Angular bindings are applicable.

Associating with Labels

The CheckBox can be associated with an HTML label element like the regular <input type="checkbox"> or with the Label component.

Example
View Source
Edit In Stackblitz  
Change Theme:

Forms Support

You can use the CheckBox in template-driven or reactive forms.

Template Forms

The template-driven forms enable you to bind the CheckBox to the forms model by using the ngModel directive.

The following example demonstrates how to use the CheckBox in a template-driven form.

Example
View Source
Edit In Stackblitz  
Change Theme:

Reactive Forms

The 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.

Example
View Source
Edit In Stackblitz  
Change Theme:

FormField Association

The following example demonstrates how to use the CheckBox within a FormField component and provide hint and error messages.

Example
View Source
Edit In Stackblitz  
Change Theme:

Required CheckBox

You can make the CheckBox required.

To do so use one of the following:

Example
View Source
Edit In Stackblitz  
Change Theme:

Indeterminate State

The CheckBox can display an indeterminate state when the respective property is set to true.

The indeterminate state is independent of the checked state and upon user interaction the current checked state will be displayed.

Example
View Source
Edit In Stackblitz  
Change Theme:

Disabled CheckBox

By default, the CheckBox is enabled.

To disable user interaction with the element, use the disabled attribute or Angular property binding.

Example
View Source
Edit In Stackblitz  
Change Theme: