Skip to content

MazSwitch

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

INFO

Before you have to import the global css files 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',
    'danger',
    'theme',
  ]
</script>

Props, Event & Slots

Props

Prop nameDescriptionTypeValuesDefault
styleStyle attribut of the component root elementTSIndexedAccessType-undefined
classClass attribut of the component root elementTSIndexedAccessType-undefined
modelValueThe model value of the switchboolean-false
idThe id of the switchstring-undefined
disabledIf the switch is disabledboolean-false
nameThe name of the switchstring-undefined
labelText labelstring-
colorThe color of the switchColor-'primary'
errorWhether there is an error with the input.boolean-
successWhether the input is successful.boolean-
warningWhether there is a warning with the input.boolean-
hintThe hint text to display below the input.string-

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