---
title: "MazCheckbox"
description: "MazCheckbox is a standalone component that replaces the standard html input checkbox. Color options are available."
package: "maz-ui"
url: "https://maz-ui.com/components/maz-checkbox"
---

# MazCheckbox

> MazCheckbox is a standalone component that replaces the standard html input checkbox. Color options are available.

- Package: `maz-ui`
- Import: `import MazCheckbox from 'maz-ui/components/MazCheckbox'`
- Nuxt: auto-imported by `@maz-ui/nuxt`, no import needed in a Nuxt app
- Web: https://maz-ui.com/components/maz-checkbox

> Before use it, you should install the MazUi plugin in your project, follow instructions in [Getting Started](../guide/getting-started.md)

## Basic usage

`v-model=""`

```vue
<script lang="ts" setup>
import MazCheckbox from 'maz-ui/components/MazCheckbox'
import { ref } from 'vue'

const checked = ref(false)
</script>

<template>
  <MazCheckbox v-model="checked" :label="checked ? 'Checked' : 'Unchecked'" />
</template>
```

## Colors

`v-model=""`

**Details: View code**

```vue
<script lang="ts" setup>
import type { Color } from 'maz-ui/components'
import MazCheckbox from 'maz-ui/components/MazCheckbox'
import { ref } from 'vue'

const chosenColors = ref([])

const colors: Color[] = [
  'primary',
  'secondary',
  'info',
  'success',
  'warning',
  'destructive',
  'contrast',
  'accent',
]
</script>

<template>
  <MazCheckbox
    v-for="color in colors"
    :id="color"
    :key="color"
    v-model="chosenColors"
    :color="color"
    name="color"
    :value="color"
  >
    {{ color }}
  </MazCheckbox>
</template>
```

## Sizing

`v-model=""`

**Details: View code**

```vue
<script lang="ts" setup>
import type { MazSize } from 'maz-ui/components'
import MazCheckbox from 'maz-ui/components/MazCheckbox'
import { ref } from 'vue'

const chosenSizes = ref([])

const sizes: MazSize[] = ['mini', 'xs', 'sm', 'md', 'lg', 'xl']
</script>

<template>
  <MazCheckbox
    v-for="size in sizes"
    :key="size"
    v-model="chosenSizes"
    name="size"
    :value="size"
    :size="size"
  >
    {{ size }}
  </MazCheckbox>
</template>
```

## Disabled

## MazCheckbox API

`import MazCheckbox from 'maz-ui/components/MazCheckbox'`

### Props

- `model-value` (`T`, `v-model`): The model value of the checkbox.
- `id` (`string`): The id of the checkbox.
- `color` (`"primary" | "secondary" | "accent" | "info" | "success" | "warning" | "destructive" | "contrast" | "transparent"`, default: `"primary"`): The color of the checkbox.
- `value` (`MazCheckboxValue`): The value of the checkbox when selected.
- `name` (`string`, default: `"m-checkbox"`): The name of the checkbox.
- `size` (`"xs" | "sm" | "md" | "lg" | "xl" | "mini"`): The size of the checkbox.
- `label` (`string`): Text label.
- `disabled` (`boolean`): If the checkbox is disabled.
- `error` (`boolean`): Whether there is an error with the input.
- `success` (`boolean`): Whether the input is successful.
- `warning` (`boolean`): Whether there is a warning with the input.
- `hint` (`string`): The hint text to display below the input.

### Events

- `@update:model-value` (payload: `value: T`): Emitted when the model value change
- `@blur` (payload: `value: FocusEvent`): Emitted when the checkbox lost focus
- `@change` (payload: `value: T`): Emitted when the model value change
- `@focus` (payload: `value: FocusEvent`): Emitted when the checkbox is focused

### Slots

- `#default` Bindings: `value: MazCheckboxValue`.
