Files
Aether/frontend/src/components/ui/switch.vue
T

31 lines
736 B
Vue
Raw Normal View History

2025-12-10 20:52:44 +08:00
<template>
<button
type="button"
role="switch"
:aria-checked="modelValue"
:disabled="disabled"
class="relative inline-flex h-6 w-11 items-center rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-50"
2025-12-10 20:52:44 +08:00
:class="[
modelValue ? 'bg-primary' : 'bg-muted'
]"
@click="$emit('update:modelValue', !modelValue)"
>
<span
2025-12-12 16:15:07 +08:00
class="inline-block h-4 w-4 transform rounded-full bg-white transition-transform"
2025-12-10 20:52:44 +08:00
:class="[
modelValue ? 'translate-x-6' : 'translate-x-1'
]"
/>
</button>
</template>
<script setup lang="ts">
defineProps<{
modelValue: boolean
disabled?: boolean
2025-12-10 20:52:44 +08:00
}>()
defineEmits<{
'update:modelValue': [value: boolean]
}>()
</script>