---
title: "MazSwitch"
description: "MazSwitch 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-switch"
---

# MazSwitch

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

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

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

```vue
<template>
  <MazSwitch
    v-for="color in colors"
    v-model="switchValue"
    :color="color"
    :name="color"
    :key="color"
  />

  <p>Disabled</p>

  <MazSwitch
    v-model="switchValue"
    name="disabled"
    disabled
  >
    {{ color }}
  </MazSwitch>
</template>

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

  const switchValue = ref(false)
  const switchValueDisabled = ref(false)

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

## MazSwitch API

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

### Props

- `model-value` (`boolean`, default: `false`, `v-model`): The model value of the switch.
- `id` (`string`): The id of the switch.
- `disabled` (`boolean`): If the switch is disabled.
- `name` (`string`): The name of the switch.
- `label` (`string`): Text label.
- `color` (`"primary" | "secondary" | "accent" | "info" | "success" | "warning" | "destructive" | "contrast" | "transparent"`, default: `"primary"`): The color of the switch.
- `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: boolean`): Emitted when the model value changes
- `@blur` (payload: `value: FocusEvent`): Emitted when the switch lost focus
- `@change` (payload: `value: boolean`): Emitted when the model value changes
- `@focus` (payload: `value: FocusEvent`): Emitted when the switch is focused

### Slots

- `#default`: The label of the switch Bindings: `value: boolean` (The value of the switch).
