Skip to content

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 ​

NameDescriptionTypeRequiredDefaultPossible values
model-valuev-model The model value of the switchbooleanNofalse-
idThe id of the switchstringNo--
disabledIf the switch is disabledbooleanNo--
nameThe name of the switchstringNo--
labelText labelstringNo--
colorThe color of the switch"primary" | "secondary" | "accent" | "info" | "success" | "warning" | "destructive" | "contrast" | "transparent"No"primary"'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'destructive' | 'contrast' | 'transparent'
errorWhether there is an error with the input.booleanNo--
successWhether the input is successful.booleanNo--
warningWhether there is a warning with the input.booleanNo--
hintThe hint text to display below the input.stringNo--

Events ​

Event namePayloadDescription
update:model-valuevalue: booleanEmitted when the model value changes
blurvalue: FocusEventEmitted when the switch lost focus
changevalue: booleanEmitted when the model value changes
focusvalue: FocusEventEmitted when the switch is focused

Slots ​

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