Switch ​

A macOS switch (NSSwitch). The caption sits to the left of the toggle, as in System Settings, and clicking it toggles the control. This is the only animated control in the library; the motion respects prefers-reduced-motion.

Usage ​

vue
<script setup lang="ts">
import { MacSwitch } from '@macvue/core'
import { ref } from 'vue'

const enabled = ref(true)
</script>

<template>
  <MacSwitch v-model="enabled">
    Wi-Fi
  </MacSwitch>
</template>

Sizes ​

All five macOS control sizes; regular is the default.

Liquid Glass ​

The base switch keeps its solid knob at the native size. Add data-macvue-glass="on" to an ancestor to enable Liquid Glass; the switch automatically shows its enlarged clicked lens only during press or drag. See the Liquid Glass guide for the opt-in boundary, fallbacks and prior art.

regular
extraLarge

Disabled ​

API ​

Props ​

PropTypeDefault
modelValue (v-model)boolean—
defaultValueboolean—
size'extra-large' | 'large' | 'regular' | 'small' | 'mini''regular'
disabledbooleanfalse
namestring—
valuestring'on'
requiredbooleanfalse

With name set, the switch renders a hidden input inside a <form> and participates in native form submission.

Events ​

EventPayload
update:modelValueboolean

Slots ​

SlotDescription
defaultSwitch caption.

Exposed ​

NameTypeDescription
elRef<HTMLInputElement | null>The underlying range input.
focus() => voidFocuses the switch.
blur() => voidRemoves focus from the switch.