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

# Checkbox - JavaScript Forms demo

Javascript checkbox and checklist demo and styling with or without description text. Supports disabled styling. Plain JS api for usage everywhere.

- [Live demo](https://demo.mobiscroll.com/javascript/forms/checkbox)
- [View code on GitHub](https://github.com/acidb/mobiscroll-demos-javascript/tree/main/src/demos/form-components/forms/checkbox)
- This demo in other frameworks: [jQuery](https://demo.mobiscroll.com/jquery/forms/checkbox.md), [Angular](https://demo.mobiscroll.com/angular/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
<label>
    <input mbsc-checkbox data-label="Option 1" data-description="Checked checkbox" type="checkbox" checked />
</label>
<label>
    <input mbsc-checkbox data-label="Option 2" data-description="Empty checkbox" type="checkbox" />
</label>
<label>
    <input mbsc-checkbox data-label="Option 3" data-description="Disabled checkbox" type="checkbox" disabled />
</label>
<label>
    <input mbsc-checkbox data-label="Option 4" data-description="Disabled and checked checkbox" type="checkbox" checked disabled />
</label>
```

```html
<label>
    <input mbsc-checkbox data-label="Primary" data-color="primary" type="checkbox" checked />
</label>
<label>
    <input mbsc-checkbox data-label="Secondary" data-color="secondary" type="checkbox" checked />
</label>
<label>
    <input mbsc-checkbox data-label="Success" data-color="success" type="checkbox" checked />
</label>
<label>
    <input mbsc-checkbox data-label="Danger" data-color="danger" type="checkbox" checked />
</label>
<label>
    <input mbsc-checkbox data-label="Warning" data-color="warning" type="checkbox" checked />
</label>
<label>
    <input mbsc-checkbox data-label="Info" data-color="info" type="checkbox" checked />
</label>
```

## Code

### JS

```js
mobiscroll.setOptions({
  theme: 'ios',
  themeVariant: 'light'
});
```

### HTML

```html
<label> <input id="chboxDeductFromStore" mbsc-switch data-label="Deduct Product/Consumable From Store" data-description="Remove the Product/Consumable from your store by work order product" type="checkbox" checked /></label>

<!--<div class="mbsc-form-group">-->
<!--    <div class="mbsc-form-group-title">Checkbox</div>-->
<!--    <label>-->
<!--        <input mbsc-checkbox data-label="Option 1" data-description="Checked checkbox" type="checkbox" checked />-->
<!--    </label>-->
<!--    <label>-->
<!--        <input mbsc-checkbox data-label="Option 2" data-description="Empty checkbox" type="checkbox" />-->
<!--    </label>-->
<!--    <label>-->
<!--        <input mbsc-checkbox data-label="Option 3" data-description="Disabled checkbox" type="checkbox" disabled />-->
<!--    </label>-->
<!--    <label>-->
<!--        <input mbsc-checkbox data-label="Option 4" data-description="Disabled and checked checkbox" type="checkbox" checked disabled />-->
<!--    </label>-->
<!--</div>-->
<!--<div class="mbsc-form-group">-->
<!--    <div class="mbsc-form-group-title">Checkbox colors</div>-->
<!--    <label>-->
<!--        <input mbsc-checkbox data-label="Primary" data-color="primary" type="checkbox" checked />-->
<!--    </label>-->
<!--    <label>-->
<!--        <input mbsc-checkbox data-label="Secondary" data-color="secondary" type="checkbox" checked />-->
<!--    </label>-->
<!--    <label>-->
<!--        <input mbsc-checkbox data-label="Success" data-color="success" type="checkbox" checked />-->
<!--    </label>-->
<!--    <label>-->
<!--        <input mbsc-checkbox data-label="Danger" data-color="danger" type="checkbox" checked />-->
<!--    </label>-->
<!--    <label>-->
<!--        <input mbsc-checkbox data-label="Warning" data-color="warning" type="checkbox" checked />-->
<!--    </label>-->
<!--    <label>-->
<!--        <input mbsc-checkbox data-label="Info" data-color="info" type="checkbox" checked />-->
<!--    </label>-->
<!--</div>-->
```

## 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-javascript.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 javascript
   ```

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

   ```
   npm install
   ```

6. Run the project:

   ```
   npm run dev
   ```

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

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

## Related demos

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