@abraracs/better-shopify-wc-mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +110 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +325 -0
- package/docs/avatar.md +481 -0
- package/docs/badge.md +266 -0
- package/docs/banner.md +350 -0
- package/docs/box.md +618 -0
- package/docs/button.md +604 -0
- package/docs/buttongroup.md +251 -0
- package/docs/checkbox.md +346 -0
- package/docs/chip.md +261 -0
- package/docs/choicelist.md +416 -0
- package/docs/clickable.md +703 -0
- package/docs/clickablechip.md +377 -0
- package/docs/colorfield.md +416 -0
- package/docs/colorpicker.md +152 -0
- package/docs/datefield.md +706 -0
- package/docs/datepicker.md +443 -0
- package/docs/divider.md +263 -0
- package/docs/dropzone.md +331 -0
- package/docs/emailfield.md +377 -0
- package/docs/grid.md +1246 -0
- package/docs/heading.md +201 -0
- package/docs/icon.md +295 -0
- package/docs/image.md +517 -0
- package/docs/link.md +456 -0
- package/docs/menu.md +331 -0
- package/docs/modal.md +640 -0
- package/docs/moneyfield.md +385 -0
- package/docs/numberfield.md +393 -0
- package/docs/orderedlist.md +224 -0
- package/docs/page.md +319 -0
- package/docs/paragraph.md +333 -0
- package/docs/passwordfield.md +381 -0
- package/docs/popover.md +419 -0
- package/docs/querycontainer.md +121 -0
- package/docs/searchfield.md +319 -0
- package/docs/section.md +267 -0
- package/docs/select.md +449 -0
- package/docs/spinner.md +121 -0
- package/docs/stack.md +748 -0
- package/docs/switch.md +365 -0
- package/docs/table.md +805 -0
- package/docs/text.md +339 -0
- package/docs/textarea.md +328 -0
- package/docs/textfield.md +425 -0
- package/docs/thumbnail.md +245 -0
- package/docs/tooltip.md +130 -0
- package/docs/unorderedlist.md +135 -0
- package/docs/urlfield.md +314 -0
- package/package.json +43 -0
package/docs/switch.md
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Switch
|
|
3
|
+
description: Give users a clear way to toggle options on or off.
|
|
4
|
+
api_name: app-home
|
|
5
|
+
source_url:
|
|
6
|
+
html: 'https://shopify.dev/docs/api/app-home/polaris-web-components/forms/switch'
|
|
7
|
+
md: 'https://shopify.dev/docs/api/app-home/polaris-web-components/forms/switch.md'
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Switch
|
|
11
|
+
|
|
12
|
+
Give users a clear way to toggle options on or off.
|
|
13
|
+
|
|
14
|
+
## Properties
|
|
15
|
+
|
|
16
|
+
* accessibilityLabel
|
|
17
|
+
|
|
18
|
+
string
|
|
19
|
+
|
|
20
|
+
A label used for users using assistive technologies like screen readers. When set, any children or `label` supplied will not be announced. This can also be used to display a control without a visual label, while still providing context to users using screen readers.
|
|
21
|
+
|
|
22
|
+
* checked
|
|
23
|
+
|
|
24
|
+
boolean
|
|
25
|
+
|
|
26
|
+
Default: false
|
|
27
|
+
|
|
28
|
+
Whether the control is active.
|
|
29
|
+
|
|
30
|
+
* defaultChecked
|
|
31
|
+
|
|
32
|
+
boolean
|
|
33
|
+
|
|
34
|
+
Default: false
|
|
35
|
+
|
|
36
|
+
Whether the control is active by default.
|
|
37
|
+
|
|
38
|
+
* details
|
|
39
|
+
|
|
40
|
+
string
|
|
41
|
+
|
|
42
|
+
Additional text to provide context or guidance for the field. This text is displayed along with the field and its label to offer more information or instructions to the user.
|
|
43
|
+
|
|
44
|
+
This will also be exposed to screen reader users.
|
|
45
|
+
|
|
46
|
+
* disabled
|
|
47
|
+
|
|
48
|
+
boolean
|
|
49
|
+
|
|
50
|
+
Default: false
|
|
51
|
+
|
|
52
|
+
Disables the field, disallowing any interaction.
|
|
53
|
+
|
|
54
|
+
* error
|
|
55
|
+
|
|
56
|
+
string
|
|
57
|
+
|
|
58
|
+
Indicate an error to the user. The field will be given a specific stylistic treatment to communicate problems that have to be resolved immediately.
|
|
59
|
+
|
|
60
|
+
* id
|
|
61
|
+
|
|
62
|
+
string
|
|
63
|
+
|
|
64
|
+
A unique identifier for the element.
|
|
65
|
+
|
|
66
|
+
* label
|
|
67
|
+
|
|
68
|
+
string
|
|
69
|
+
|
|
70
|
+
Visual content to use as the control label.
|
|
71
|
+
|
|
72
|
+
* labelAccessibilityVisibility
|
|
73
|
+
|
|
74
|
+
"visible" | "exclusive"
|
|
75
|
+
|
|
76
|
+
Default: 'visible'
|
|
77
|
+
|
|
78
|
+
Changes the visibility of the component's label.
|
|
79
|
+
|
|
80
|
+
* `visible`: the label is visible to all users.
|
|
81
|
+
* `exclusive`: the label is visually hidden but remains in the accessibility tree.
|
|
82
|
+
|
|
83
|
+
* name
|
|
84
|
+
|
|
85
|
+
string
|
|
86
|
+
|
|
87
|
+
An identifier for the field that is unique within the nearest containing form.
|
|
88
|
+
|
|
89
|
+
* required
|
|
90
|
+
|
|
91
|
+
boolean
|
|
92
|
+
|
|
93
|
+
Default: false
|
|
94
|
+
|
|
95
|
+
Whether the field needs a value. This requirement adds semantic value to the field, but it will not cause an error to appear automatically. If you want to present an error when this field is empty, you can do so with the `error` property.
|
|
96
|
+
|
|
97
|
+
* value
|
|
98
|
+
|
|
99
|
+
string
|
|
100
|
+
|
|
101
|
+
The value used in form data when the checkbox is checked.
|
|
102
|
+
|
|
103
|
+
## Events
|
|
104
|
+
|
|
105
|
+
Learn more about [registering events](https://shopify.dev/docs/api/app-home/using-polaris-components#event-handling).
|
|
106
|
+
|
|
107
|
+
* change
|
|
108
|
+
|
|
109
|
+
CallbackEventListener<'input'>
|
|
110
|
+
|
|
111
|
+
* input
|
|
112
|
+
|
|
113
|
+
CallbackEventListener<'input'>
|
|
114
|
+
|
|
115
|
+
### CallbackEventListener
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
(EventListener & {
|
|
119
|
+
(event: CallbackEvent<T>): void;
|
|
120
|
+
}) | null
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### CallbackEvent
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
Event & {
|
|
127
|
+
currentTarget: HTMLElementTagNameMap[T];
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Examples
|
|
132
|
+
|
|
133
|
+
### Examples
|
|
134
|
+
|
|
135
|
+
* #### Code
|
|
136
|
+
|
|
137
|
+
##### jsx
|
|
138
|
+
|
|
139
|
+
```jsx
|
|
140
|
+
<s-switch
|
|
141
|
+
label="Enable feature"
|
|
142
|
+
details="Ensure all criteria are met before enabling"
|
|
143
|
+
/>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
##### html
|
|
147
|
+
|
|
148
|
+
```html
|
|
149
|
+
<s-switch
|
|
150
|
+
label="Enable feature"
|
|
151
|
+
details="Ensure all criteria are met before enabling"
|
|
152
|
+
></s-switch>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
* #### Basic switch
|
|
156
|
+
|
|
157
|
+
##### Description
|
|
158
|
+
|
|
159
|
+
Standard toggle switch for enabling or disabling merchant preferences. This example demonstrates a simple switch with a label, allowing users to toggle a single setting on or off.
|
|
160
|
+
|
|
161
|
+
##### jsx
|
|
162
|
+
|
|
163
|
+
```jsx
|
|
164
|
+
<s-switch id="basic-switch" label="Enable notifications" />
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
##### html
|
|
168
|
+
|
|
169
|
+
```html
|
|
170
|
+
<s-switch id="basic-switch" label="Enable notifications"></s-switch>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
* #### Disabled switch
|
|
174
|
+
|
|
175
|
+
##### Description
|
|
176
|
+
|
|
177
|
+
Locked switch with explanatory text for unavailable premium features. This example shows a switch that is visually disabled and cannot be interacted with, typically used to indicate a feature is not currently available.
|
|
178
|
+
|
|
179
|
+
##### jsx
|
|
180
|
+
|
|
181
|
+
```jsx
|
|
182
|
+
<s-switch
|
|
183
|
+
id="disabled-switch"
|
|
184
|
+
label="Feature locked (Premium plan required)"
|
|
185
|
+
checked={true}
|
|
186
|
+
disabled={true}
|
|
187
|
+
/>
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
##### html
|
|
191
|
+
|
|
192
|
+
```html
|
|
193
|
+
<s-switch
|
|
194
|
+
id="disabled-switch"
|
|
195
|
+
label="Feature locked (Premium plan required)"
|
|
196
|
+
checked="true"
|
|
197
|
+
disabled="true"
|
|
198
|
+
></s-switch>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
* #### Form integration
|
|
202
|
+
|
|
203
|
+
##### Description
|
|
204
|
+
|
|
205
|
+
Multiple switches within a form for notification preferences submission. This example illustrates how switches can be used together in a form to allow users to configure multiple related settings simultaneously.
|
|
206
|
+
|
|
207
|
+
##### jsx
|
|
208
|
+
|
|
209
|
+
```jsx
|
|
210
|
+
<form>
|
|
211
|
+
<s-switch
|
|
212
|
+
id="email-notifications"
|
|
213
|
+
label="Email notifications"
|
|
214
|
+
name="emailNotifications"
|
|
215
|
+
value="enabled"
|
|
216
|
+
/>
|
|
217
|
+
<s-switch
|
|
218
|
+
id="sms-notifications"
|
|
219
|
+
label="SMS notifications"
|
|
220
|
+
name="smsNotifications"
|
|
221
|
+
value="enabled"
|
|
222
|
+
/>
|
|
223
|
+
</form>
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
##### html
|
|
227
|
+
|
|
228
|
+
```html
|
|
229
|
+
<form>
|
|
230
|
+
<s-switch
|
|
231
|
+
id="email-notifications"
|
|
232
|
+
label="Email notifications"
|
|
233
|
+
name="emailNotifications"
|
|
234
|
+
value="enabled"
|
|
235
|
+
></s-switch>
|
|
236
|
+
<s-switch
|
|
237
|
+
id="sms-notifications"
|
|
238
|
+
label="SMS notifications"
|
|
239
|
+
name="smsNotifications"
|
|
240
|
+
value="enabled"
|
|
241
|
+
></s-switch>
|
|
242
|
+
</form>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
* #### Hidden label for accessibility
|
|
246
|
+
|
|
247
|
+
##### Description
|
|
248
|
+
|
|
249
|
+
Switch with visually hidden label that remains accessible to screen readers. This example demonstrates how to create a switch with a label that is only perceivable by assistive technologies, maintaining accessibility while minimizing visual clutter.
|
|
250
|
+
|
|
251
|
+
##### jsx
|
|
252
|
+
|
|
253
|
+
```jsx
|
|
254
|
+
<s-switch
|
|
255
|
+
id="hidden-label-switch"
|
|
256
|
+
labelAccessibilityVisibility="exclusive"
|
|
257
|
+
label="Toggle feature"
|
|
258
|
+
checked={true}
|
|
259
|
+
/>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
##### html
|
|
263
|
+
|
|
264
|
+
```html
|
|
265
|
+
<s-switch
|
|
266
|
+
id="hidden-label-switch"
|
|
267
|
+
labelAccessibilityVisibility="exclusive"
|
|
268
|
+
label="Toggle feature"
|
|
269
|
+
checked="true"
|
|
270
|
+
></s-switch>
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
* #### With details and error
|
|
274
|
+
|
|
275
|
+
##### Description
|
|
276
|
+
|
|
277
|
+
Required switch with validation error and contextual details for user guidance. This example shows a switch that requires user interaction, provides additional context through details, and displays an error message when validation fails.
|
|
278
|
+
|
|
279
|
+
##### jsx
|
|
280
|
+
|
|
281
|
+
```jsx
|
|
282
|
+
<s-switch
|
|
283
|
+
id="terms-switch"
|
|
284
|
+
label="Agree to terms and conditions"
|
|
285
|
+
details="You must agree to continue with the purchase"
|
|
286
|
+
error="Agreement is required"
|
|
287
|
+
name="termsAgreement"
|
|
288
|
+
required={true}
|
|
289
|
+
value="agreed"
|
|
290
|
+
/>
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
##### html
|
|
294
|
+
|
|
295
|
+
```html
|
|
296
|
+
<s-switch
|
|
297
|
+
id="terms-switch"
|
|
298
|
+
label="Agree to terms and conditions"
|
|
299
|
+
details="You must agree to continue with the purchase"
|
|
300
|
+
error="Agreement is required"
|
|
301
|
+
name="termsAgreement"
|
|
302
|
+
required="true"
|
|
303
|
+
value="agreed"
|
|
304
|
+
></s-switch>
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
* #### Switch with accessibility label
|
|
308
|
+
|
|
309
|
+
##### Description
|
|
310
|
+
|
|
311
|
+
Switch with enhanced accessibility description for screen reader users. This example illustrates how to provide a more descriptive accessibility label that provides additional context beyond the visible label.
|
|
312
|
+
|
|
313
|
+
##### jsx
|
|
314
|
+
|
|
315
|
+
```jsx
|
|
316
|
+
<s-switch
|
|
317
|
+
id="event-switch"
|
|
318
|
+
label="Feature toggle"
|
|
319
|
+
accessibilityLabel="Toggle feature on or off"
|
|
320
|
+
/>
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
##### html
|
|
324
|
+
|
|
325
|
+
```html
|
|
326
|
+
<s-switch
|
|
327
|
+
id="event-switch"
|
|
328
|
+
label="Feature toggle"
|
|
329
|
+
accessibilityLabel="Toggle feature on or off"
|
|
330
|
+
></s-switch>
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
* #### Settings panel with Stack
|
|
334
|
+
|
|
335
|
+
##### Description
|
|
336
|
+
|
|
337
|
+
Group of related switches arranged in a vertical stack for settings configuration. This example demonstrates how to use the Stack component to create a clean, organized layout for multiple related switch settings.
|
|
338
|
+
|
|
339
|
+
##### jsx
|
|
340
|
+
|
|
341
|
+
```jsx
|
|
342
|
+
<s-stack gap="small-200">
|
|
343
|
+
<s-switch id="notifications-setting" label="Push notifications" />
|
|
344
|
+
<s-switch id="autosave-setting" label="Auto-save drafts" />
|
|
345
|
+
<s-switch
|
|
346
|
+
id="analytics-setting"
|
|
347
|
+
label="Usage analytics"
|
|
348
|
+
checked={true}
|
|
349
|
+
/>
|
|
350
|
+
</s-stack>
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
##### html
|
|
354
|
+
|
|
355
|
+
```html
|
|
356
|
+
<s-stack gap="base">
|
|
357
|
+
<s-switch id="notifications-setting" label="Push notifications"></s-switch>
|
|
358
|
+
<s-switch id="autosave-setting" label="Auto-save drafts"></s-switch>
|
|
359
|
+
<s-switch
|
|
360
|
+
id="analytics-setting"
|
|
361
|
+
label="Usage analytics"
|
|
362
|
+
checked="true"
|
|
363
|
+
></s-switch>
|
|
364
|
+
</s-stack>
|
|
365
|
+
```
|