Skip to content

MazSwitch

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

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

NameDescriptionTypeRequiredDefault
styleStyle attribut of the component root elementNative typeNoundefined
classClass attribut of the component root elementNative typeNoundefined
model-valueThe model value of the switchbooleanNofalse
idThe id of the switchstringNoundefined
disabledIf the switch is disabledbooleanNofalse
nameThe name of the switchstringNoundefined
labelText labelstringNoundefined
colorThe color of the switchMazColorNo'primary'
errorWhether there is an error with the input.booleanNoundefined
successWhether the input is successful.booleanNoundefined
warningWhether there is a warning with the input.booleanNoundefined
hintThe hint text to display below the input.stringNoundefined

Events

Event namePropertiesDescription
update:model-valuevalue boolean - The new valueEmitted when the model value changes
changevalue boolean - The new valueEmitted when the model value changes
blurvalue FocusEvent - The focus eventEmitted when the switch lost focus
focusvalue FocusEvent - The focus eventEmitted when the switch is focused

Slots

NameDescriptionBindings
defaultThe label of the switchvalue Boolean - The value of the switch