---
title: "Angular Forms Checkbox Example | Mobiscroll"
component: "Forms"
framework: "Angular"
library_version: "6.1.5"
url: "https://demo.mobiscroll.com/angular/forms/checkbox"
---

# Checkbox - Angular Forms demo

Angular checkbox and checklist demo and styling with or without description text. Supports disabled styling.

- [Live demo](https://demo.mobiscroll.com/angular/forms/checkbox)
- [View code on GitHub](https://github.com/acidb/mobiscroll-demos-angular/tree/main/src/demos/form-components/forms/checkbox)
- This demo in other frameworks: [JavaScript](https://demo.mobiscroll.com/javascript/forms/checkbox.md), [jQuery](https://demo.mobiscroll.com/jquery/forms/checkbox.md), [React](https://demo.mobiscroll.com/react/forms/checkbox.md), [Vue](https://demo.mobiscroll.com/vue/forms/checkbox.md)

## Description

Use checkboxes for multiple choice lists or properties or `true/false` properties of an event. Different color presets are available.

## What this demo shows

- This demo shows different examples for checkboxes.
- **Checkbox states** Checkboxes in checked and unchecked states.
- **Disabled states** Disabled checkboxes in both checked and unchecked states.
- **Supporting content** Checkboxes with titles and descriptive text.
- **Color presets** The primary, secondary, success, danger, warning, and info checkbox colors.
- **Selection patterns** Checkboxes for selecting multiple options and setting `true/false` event properties.

## Best for

- **Multiple-choice lists** Letting users select any number of options from a list.
- **Event properties** Setting independent `true/false` properties for an event.
- **Settings forms** Pairing checkbox titles with descriptive text when an option needs additional context.
- **Unavailable options** Showing checked or unchecked values that users cannot currently change.
- **Color-coded options** Applying preset colors when checkboxes need distinct visual meaning.

## Tutorial

```html
<mbsc-checkbox label="Option 1" description="Checked checkbox" [(ngModel)]="ch1"></mbsc-checkbox>
<mbsc-checkbox label="Option 2" description="Empty checkbox" [(ngModel)]="ch2"></mbsc-checkbox>
<mbsc-checkbox label="Option 3" description="Disabled checkbox" [(ngModel)]="ch3" disabled="true"></mbsc-checkbox>
<mbsc-checkbox label="Option 4" description="Disabled and checked checkbox" [(ngModel)]="ch4" disabled="true">
</mbsc-checkbox>
```

```html
<mbsc-checkbox label="Primary" color="primary" [(ngModel)]="primary"></mbsc-checkbox>
<mbsc-checkbox label="Secondary" color="secondary" [(ngModel)]="secondary"></mbsc-checkbox>
<mbsc-checkbox label="Success" color="success" [(ngModel)]="success"></mbsc-checkbox>
<mbsc-checkbox label="Danger" color="danger" [(ngModel)]="danger"></mbsc-checkbox>
<mbsc-checkbox label="Warning" color="warning" [(ngModel)]="warning"></mbsc-checkbox>
<mbsc-checkbox label="Info" color="info" [(ngModel)]="info"></mbsc-checkbox>
```

## Code

### Component

```ts
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MbscModule, setOptions } from '@mobiscroll/angular';

setOptions({
  theme: 'ios',
  themeVariant: 'light'
});

@Component({
  selector: 'app-root', 
  templateUrl: './app.component.html',
  standalone: true,
  imports: [CommonModule, FormsModule, MbscModule],
})
export class AppComponent {
  ch1 = true;
  ch2 = false;
  ch3 = false;
  ch4 = true;
  primary = true;
  secondary = true;
  success = true;
  danger = true;
  warning = true;
  info = true;
}
```

### Template

```html
<mbsc-page>
  <div class="mbsc-form-group">
    <div class="mbsc-form-group-title">Checkbox</div>
    <mbsc-checkbox label="Option 1" description="Checked checkbox" [(ngModel)]="ch1"></mbsc-checkbox>
    <mbsc-checkbox label="Option 2" description="Empty checkbox" [(ngModel)]="ch2"></mbsc-checkbox>
    <mbsc-checkbox label="Option 3" description="Disabled checkbox" [(ngModel)]="ch3" [disabled]="true"></mbsc-checkbox>
    <mbsc-checkbox label="Option 4" description="Disabled and checked checkbox" [(ngModel)]="ch4" [disabled]="true"> </mbsc-checkbox>
  </div>
  <div class="mbsc-form-group">
    <div class="mbsc-form-group-title">Checkbox colors</div>
    <mbsc-checkbox label="Primary" color="primary" [(ngModel)]="primary"></mbsc-checkbox>
    <mbsc-checkbox label="Secondary" color="secondary" [(ngModel)]="secondary"></mbsc-checkbox>
    <mbsc-checkbox label="Success" color="success" [(ngModel)]="success"></mbsc-checkbox>
    <mbsc-checkbox label="Danger" color="danger" [(ngModel)]="danger"></mbsc-checkbox>
    <mbsc-checkbox label="Warning" color="warning" [(ngModel)]="warning"></mbsc-checkbox>
    <mbsc-checkbox label="Info" color="info" [(ngModel)]="info"></mbsc-checkbox>
  </div>
</mbsc-page>
```

## Implementation notes

- `label` sets the checkbox's primary text; `description` adds secondary supporting text below/beside it.
- `disabled` (boolean prop/attribute) disables the checkbox in either its checked or unchecked state; it does not change the checked value.
- `color` accepts six presets: `primary`, `secondary`, `success`, `danger`, `warning`, `info` (no `light`/`dark` variant for checkboxes).
- Checked state handling differs by framework: React exposes `checked`/`defaultChecked` (controlled/uncontrolled); Vue two-way binds via `v-model` on a `ref<boolean>`, with no separate `defaultChecked` - the bound ref's initial value is the initial checked state; Angular two-way binds via `[(ngModel)]`; JS/jQuery uses the native `checked` attribute on `input[type="checkbox"][mbsc-checkbox]`.
- Framework differences: React `<Checkbox label="..." description="..." defaultChecked={true} disabled={true} color="primary" />`; Vue `<MbscCheckbox v-model="option1" label="..." description="..." :disabled="true" color="primary" />`; Angular `<mbsc-checkbox label="..." description="..." [(ngModel)]="ch1" [disabled]="true" color="primary"></mbsc-checkbox>`; JS/jQuery `<label><input mbsc-checkbox type="checkbox" data-label="..." data-description="..." data-color="primary" checked disabled /></label>`.

## Run it in your project

1. If not signed up yet, or don't own a license, you can [start a free trial](https://mobiscroll.com/starttrial).

2. Clone the repository:

   ```
   git clone https://github.com/acidb/mobiscroll-demos-angular.git
   ```

3. If not installed yet, install the Mobiscroll CLI from NPM:

   ```
   npm install -g @mobiscroll/cli
   ```

4. Config Mobiscroll - open a terminal window in the root directory and run:

   ```
   mobiscroll config angular
   ```

5. Install dependencies - open a terminal window in the root directory and run:

   ```
   npm install
   ```

6. Run the project:

   ```
   ng serve
   ```

On a trial, add `--trial` to the config command: `mobiscroll config angular --trial`.

Running a demo locally requires a Mobiscroll trial or a license; setup is per framework at https://mobiscroll.com/docs/angular/getting-started/installation

## Related demos

- Next: [Switch](https://demo.mobiscroll.com/angular/forms/switch.md) - Angular switch/toggle demo with or without description. Alternative to the checkbox. Supports disabled styling.
