MazSwitch
MazSwitch is a standalone component that replaces the standard html input checkbox. Color options are available.
Before use it, you should install the MazUi plugin in your project, follow instructions in Getting Started
Disabled
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>Props
| Name | Description | Type | Required | Default |
|---|---|---|---|---|
| style | Style attribut of the component root element | Native type | No | undefined |
| class | Class attribut of the component root element | Native type | No | undefined |
| model-value | The model value of the switch | boolean | No | false |
| id | The id of the switch | string | No | undefined |
| disabled | If the switch is disabled | boolean | No | false |
| name | The name of the switch | string | No | undefined |
| label | Text label | string | No | undefined |
| color | The color of the switch | MazColor | No | 'primary' |
| error | Whether there is an error with the input. | boolean | No | undefined |
| success | Whether the input is successful. | boolean | No | undefined |
| warning | Whether there is a warning with the input. | boolean | No | undefined |
| hint | The hint text to display below the input. | string | No | undefined |
Events
| Event name | Properties | Description |
|---|---|---|
| update:model-value | value boolean - The new value | Emitted when the model value changes |
| change | value boolean - The new value | Emitted when the model value changes |
| blur | value FocusEvent - The focus event | Emitted when the switch lost focus |
| focus | value FocusEvent - The focus event | Emitted when the switch is focused |
Slots
| Name | Description | Bindings |
|---|---|---|
| default | The label of the switch | value Boolean - The value of the switch |