-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitch.vue
More file actions
247 lines (234 loc) · 5.81 KB
/
switch.vue
File metadata and controls
247 lines (234 loc) · 5.81 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<!-- eslint-disable vue/multi-word-component-names -->
<script setup>
const switchSchema = [
{
$formkit: 'nuxtUISwitch',
id: 'switch-basic',
name: 'switch1',
label: 'Basic Switch',
help: 'Simple on/off toggle',
validation: 'required',
},
{
$formkit: 'nuxtUISwitch',
name: 'switch2',
label: 'Enable Notifications',
description: 'Receive email notifications for updates',
},
{
$formkit: 'nuxtUISwitch',
name: 'switch3',
label: 'Dark Mode',
description: 'Switch between light and dark theme',
value: true,
},
{
$formkit: 'nuxtUISwitch',
name: 'switch4',
label: 'With Checked Icon',
description: 'Custom icon when checked',
checkedIcon: 'i-heroicons-bell',
},
{
$formkit: 'nuxtUISwitch',
name: 'switch5',
label: 'Checked/Unchecked Icons',
description: 'Different icons for checked and unchecked states',
checkedIcon: 'i-heroicons-check',
uncheckedIcon: 'i-heroicons-x-mark',
},
{
$formkit: 'nuxtUISwitch',
name: 'switch6',
label: 'Loading State',
description: 'Switch in loading state',
loading: true,
},
{
$formkit: 'nuxtUISwitch',
name: 'switch7',
label: 'Custom Loading Icon',
description: 'Custom loading icon',
loading: true,
loadingIcon: 'i-heroicons-arrow-path',
},
{
$formkit: 'nuxtUISwitch',
name: 'switch8',
label: 'Extra Small Size',
size: 'xs',
},
{
$formkit: 'nuxtUISwitch',
name: 'switch9',
label: 'Small Size',
size: 'sm',
},
{
$formkit: 'nuxtUISwitch',
name: 'switch10',
label: 'Medium Size (Default)',
size: 'md',
},
{
$formkit: 'nuxtUISwitch',
name: 'switch11',
label: 'Large Size',
size: 'lg',
},
{
$formkit: 'nuxtUISwitch',
name: 'switch12',
label: 'Extra Large Size',
size: 'xl',
},
{
$formkit: 'nuxtUISwitch',
name: 'switch13',
label: 'Primary Color',
description: 'Primary color switch',
color: 'primary',
},
{
$formkit: 'nuxtUISwitch',
name: 'switch14',
label: 'Success Color',
description: 'Success color switch',
color: 'success',
},
{
$formkit: 'nuxtUISwitch',
name: 'switch15',
label: 'Error Color',
description: 'Error color switch',
color: 'error',
},
{
$formkit: 'nuxtUISwitch',
name: 'switch16',
label: 'Warning Color',
description: 'Warning color switch',
color: 'warning',
},
{
$formkit: 'nuxtUISwitch',
name: 'switch17',
label: 'Enabled by Default',
description: 'Pre-selected switch',
value: true,
},
{
$formkit: 'nuxtUISwitch',
name: 'switch18',
label: 'Disabled',
description: 'Disabled switch',
disabled: true,
value: false,
},
{
$formkit: 'nuxtUISwitch',
name: 'switch19',
label: 'Disabled (On)',
description: 'Disabled switch in on state',
disabled: true,
value: true,
},
]
</script>
<template>
<div>
<UContainer>
<div class="mb-8">
<h1 class="text-4xl font-bold mb-4">
Switch Component
</h1>
<p class="text-lg text-muted-foreground mb-2">
The Switch component integrates FormKit with Nuxt UI's USwitch component, providing a seamless toggle switch experience.
</p>
<p class="text-muted-foreground">
Explore various switch configurations, validation patterns, styling options, and states below.
</p>
</div>
<USeparator class="my-8" />
<div class="space-y-12">
<section>
<h2 class="text-2xl font-semibold mb-4">
Basic Usage
</h2>
<p class="text-muted-foreground mb-6">
Basic switches with labels, descriptions, and default values.
</p>
<FUDataEdit
:data="{}"
:schema="switchSchema.slice(0, 3)"
/>
</section>
<USeparator />
<section>
<h2 class="text-2xl font-semibold mb-4">
Icons
</h2>
<p class="text-muted-foreground mb-6">
Add custom icons or different icons for on and off states.
</p>
<FUDataEdit
:data="{}"
:schema="switchSchema.slice(3, 5)"
/>
</section>
<USeparator />
<section>
<h2 class="text-2xl font-semibold mb-4">
Loading State
</h2>
<p class="text-muted-foreground mb-6">
Show loading state with default or custom loading icons.
</p>
<FUDataEdit
:data="{}"
:schema="switchSchema.slice(5, 7)"
/>
</section>
<USeparator />
<section>
<h2 class="text-2xl font-semibold mb-4">
Sizes
</h2>
<p class="text-muted-foreground mb-6">
Available sizes: xs, sm, md (default), lg, and xl.
</p>
<FUDataEdit
:data="{}"
:schema="switchSchema.slice(7, 12)"
/>
</section>
<USeparator />
<section>
<h2 class="text-2xl font-semibold mb-4">
Colors
</h2>
<p class="text-muted-foreground mb-6">
Customize switch colors including primary, success, error, and warning.
</p>
<FUDataEdit
:data="{}"
:schema="switchSchema.slice(12, 16)"
/>
</section>
<USeparator />
<section>
<h2 class="text-2xl font-semibold mb-4">
States
</h2>
<p class="text-muted-foreground mb-6">
Different states including default value and disabled (both on and off).
</p>
<FUDataEdit
:data="{}"
:schema="switchSchema.slice(16, 19)"
/>
</section>
</div>
</UContainer>
</div>
</template>