Components

Switch

A toggle control for binary or custom on/off values.

An accessible on/off toggle. Renders as a role="switch" button and supports custom v-model values, labels, descriptions, and fully custom track/thumb rendering via slots.

Anatomy

  • #thumb: Sliding indicator inside the track.
  • #label: Label beside the switch.
  • #description: Supplementary text below the label.

Usage

Email notificationsReceive updates about your account.Dark modeApply a dark theme to the interface.Sound effectsPlay sounds for actions and alerts.

Examples

Custom thumb

Use #thumb to replace the sliding indicator while keeping switch behavior.

<template>
  <Switch v-model="enabled" class="my-switch">
    <template #thumb="{ checked }">
      <span :class="['thumb', { 'thumb--on': checked }]" />
    </template>
  </Switch>
</template>

With description

Use description when the switch label needs more context.

<template>
  <Switch
    v-model="enabled"
    label="Dark mode"
    description="Applies a dark theme across the interface."
  />
</template>

Custom true/false values

Use custom values when the model stores domain values instead of booleans.

<script setup lang="ts">
const theme = ref<"dark" | "light">("light");
</script>

<template>
  <Switch
    v-model="theme"
    true-value="dark"
    false-value="light"
    label="Dark mode"
  />
</template>

Icon-only switch

Use aria-label when there's no visible label text.

<template>
  <Switch v-model="muted" aria-label="Mute audio" class="my-switch" />
</template>

API Reference

Props

PropTypeDefaultDescription
disabledbooleanfalseDisables the switch.
idstringautoHTML id for the button element.
namestringHTML name for form submission.
requiredbooleanfalseMarks the field as required.
trueValueboolean | string | numbertrueModel value when switched on.
falseValueboolean | string | numberfalseModel value when switched off.
labelstringLabel text. Slot #label takes priority.
descriptionstringDescription text. Slot #description takes priority.
ariaLabelstringaria-label for icon-only switches with no visible label.
uiSwitchUiCSS class overrides.

Slots

SlotScoped propsDescription
thumb{ checked }The sliding thumb indicator.
labelLabel text. Defaults to the label prop.
descriptionDescription text. Defaults to the description prop.

Emits

EventPayloadDescription
value-change[value: SwitchValue, details]Fired when the switch state changes.

UI Options

KeyDescription
wrapperThe outer wrapper element.
rootThe interactive button (the switch track).
thumbThe thumb indicator element.
inputHidden native input used for form submission.
textWrapper around label and description.
labelThe label element.
descriptionThe description element.

Styling Hooks

UI keyCSS classData attrs
wrapperakaza-switch-wrapper
rootakaza-switchdata-akaza-state, data-akaza-disabled
thumbakaza-switch-thumbdata-akaza-state
inputakaza-switch-input
textakaza-switch-text
labelakaza-switch-label
descriptionakaza-switch-description