File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ <script lang="ts" setup>
2
+ import { Switch } from ' @headlessui/vue'
3
+
4
+ defineProps <{
5
+ description? : string ,
6
+ label? : string ,
7
+ }>()
8
+
9
+ const modelValue = defineModel <boolean >()
10
+ </script >
11
+
12
+ <template >
13
+ <div >
14
+ <label class =" inline-flex items-center gap-2 cursor-pointer" >
15
+ <Switch
16
+ v-model =" modelValue"
17
+ :class =" modelValue ? 'bg-primary' : 'bg-layer'"
18
+ class =" inline-flex relative h-5 items-stretch justify-stretch shrink-0 grow-0 cursor-pointer rounded border border-layer transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2"
19
+ >
20
+ <span class =" sr-only" >Toggle</span >
21
+ <span aria-hidden =" true" class =" pointer-events-none inline-flex aspect-[2/1] overflow-hidden" >
22
+ <span
23
+ class ="
24
+ relative
25
+ font-bold text-[0.4rem] leading-none
26
+ inline-flex items-center gap-0
27
+ border-2 border-transparent
28
+ aspect-square w-1/2
29
+ transform-gpu transition duration-200 ease-in-out
30
+ "
31
+ :class =" {
32
+ 'translate-x-[100%]': modelValue,
33
+ 'translate-x-0': !modelValue,
34
+ }"
35
+ >
36
+ <span class =" absolute block right-full mr-1" >ON</span >
37
+ <span
38
+ class =" relative bg-current block rounded-sm h-full w-full"
39
+ />
40
+ <span class =" absolute block left-full ml-1" >OFF</span >
41
+ </span >
42
+ </span >
43
+ </Switch >
44
+ <span v-if =" label" >{{ label }}</span >
45
+ </label >
46
+ <small v-if =" description" class =" block text-layer-muted" >{{ description }}</small >
47
+ </div >
48
+ </template >
You can’t perform that action at this time.
0 commit comments