-
Notifications
You must be signed in to change notification settings - Fork 198
/
Copy pathToggleButton.vue
56 lines (50 loc) · 1 KB
/
ToggleButton.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<script setup lang="ts">
defineProps<{ text: string }>()
const active = defineModel<boolean>()
</script>
<template>
<div class="wrapper" @click="active = !active">
<span class="text">{{ text }}</span>
<div class="toggle" :class="[{ active: modelValue }]">
<div class="indicator" />
</div>
</div>
</template>
<style scoped>
.wrapper {
display: flex;
align-items: center;
cursor: pointer;
user-select: none;
}
.text {
color: var(--text-light);
}
.toggle {
display: inline-block;
margin-left: 4px;
width: 32px;
height: 18px;
border-radius: 12px;
position: relative;
background-color: var(--border);
}
.indicator {
font-size: 12px;
background-color: var(--text-light);
width: 14px;
height: 14px;
border-radius: 50%;
transition: transform ease-in-out 0.2s;
position: absolute;
left: 2px;
top: 2px;
color: var(--bg);
text-align: center;
}
.active .indicator {
background-color: var(--color-branding);
transform: translateX(14px);
color: white;
}
</style>