@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
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ButtonGroup
|
|
3
|
+
description: Displays multiple buttons in a layout.
|
|
4
|
+
api_name: app-home
|
|
5
|
+
source_url:
|
|
6
|
+
html: >-
|
|
7
|
+
https://shopify.dev/docs/api/app-home/polaris-web-components/actions/buttongroup
|
|
8
|
+
md: >-
|
|
9
|
+
https://shopify.dev/docs/api/app-home/polaris-web-components/actions/buttongroup.md
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Button​Group
|
|
13
|
+
|
|
14
|
+
Displays multiple buttons in a layout.
|
|
15
|
+
|
|
16
|
+
## Properties
|
|
17
|
+
|
|
18
|
+
* accessibilityLabel
|
|
19
|
+
|
|
20
|
+
string
|
|
21
|
+
|
|
22
|
+
Label for the button group that describes the content of the group for screen reader users to understand what's included.
|
|
23
|
+
|
|
24
|
+
* gap
|
|
25
|
+
|
|
26
|
+
"base" | "none"
|
|
27
|
+
|
|
28
|
+
Default: 'base'
|
|
29
|
+
|
|
30
|
+
The gap between elements.
|
|
31
|
+
|
|
32
|
+
## Slots
|
|
33
|
+
|
|
34
|
+
* children
|
|
35
|
+
|
|
36
|
+
HTMLElement
|
|
37
|
+
|
|
38
|
+
The content of the ButtonGroup.
|
|
39
|
+
|
|
40
|
+
* primary-action
|
|
41
|
+
|
|
42
|
+
HTMLElement
|
|
43
|
+
|
|
44
|
+
The primary action button for the group. Accepts a single Button element with a `variant` of `primary`. Cannot be used when gap="none".
|
|
45
|
+
|
|
46
|
+
* secondary-actions
|
|
47
|
+
|
|
48
|
+
HTMLElement
|
|
49
|
+
|
|
50
|
+
Secondary action buttons for the group. Accepts Button elements with a `variant` of `secondary` or `auto`.
|
|
51
|
+
|
|
52
|
+
Examples
|
|
53
|
+
|
|
54
|
+
### Examples
|
|
55
|
+
|
|
56
|
+
* #### Code
|
|
57
|
+
|
|
58
|
+
##### jsx
|
|
59
|
+
|
|
60
|
+
```jsx
|
|
61
|
+
<s-button-group>
|
|
62
|
+
<s-button slot="primary-action">Save</s-button>
|
|
63
|
+
<s-button slot="secondary-actions">Cancel</s-button>
|
|
64
|
+
</s-button-group>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
##### html
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<s-button-group>
|
|
71
|
+
<s-button slot="primary-action">Save</s-button>
|
|
72
|
+
<s-button slot="secondary-actions">Cancel</s-button>
|
|
73
|
+
</s-button-group>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
* #### Basic usage
|
|
77
|
+
|
|
78
|
+
##### Description
|
|
79
|
+
|
|
80
|
+
Standard button group with cancel and primary action for form workflows.
|
|
81
|
+
|
|
82
|
+
##### jsx
|
|
83
|
+
|
|
84
|
+
```jsx
|
|
85
|
+
<s-button-group>
|
|
86
|
+
<s-button slot="secondary-actions">Cancel</s-button>
|
|
87
|
+
<s-button slot="primary-action" variant="primary">
|
|
88
|
+
Save
|
|
89
|
+
</s-button>
|
|
90
|
+
</s-button-group>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
##### html
|
|
94
|
+
|
|
95
|
+
```html
|
|
96
|
+
<s-button-group>
|
|
97
|
+
<s-button slot="secondary-actions">Cancel</s-button>
|
|
98
|
+
<s-button slot="primary-action" variant="primary">Save</s-button>
|
|
99
|
+
</s-button-group>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
* #### Bulk action buttons
|
|
103
|
+
|
|
104
|
+
##### Description
|
|
105
|
+
|
|
106
|
+
Action buttons for selected items with destructive option.
|
|
107
|
+
|
|
108
|
+
##### jsx
|
|
109
|
+
|
|
110
|
+
```jsx
|
|
111
|
+
<s-button-group>
|
|
112
|
+
<s-button slot="secondary-actions">Archive</s-button>
|
|
113
|
+
<s-button slot="secondary-actions">Export</s-button>
|
|
114
|
+
<s-button slot="secondary-actions" tone="critical">
|
|
115
|
+
Delete
|
|
116
|
+
</s-button>
|
|
117
|
+
</s-button-group>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
##### html
|
|
121
|
+
|
|
122
|
+
```html
|
|
123
|
+
<s-button-group>
|
|
124
|
+
<s-button slot="secondary-actions">Archive</s-button>
|
|
125
|
+
<s-button slot="secondary-actions">Export</s-button>
|
|
126
|
+
<s-button slot="secondary-actions" tone="critical">Delete</s-button>
|
|
127
|
+
</s-button-group>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
* #### Form action buttons
|
|
131
|
+
|
|
132
|
+
##### Description
|
|
133
|
+
|
|
134
|
+
Typical form completion actions with clear visual hierarchy.
|
|
135
|
+
|
|
136
|
+
##### jsx
|
|
137
|
+
|
|
138
|
+
```jsx
|
|
139
|
+
<s-button-group>
|
|
140
|
+
<s-button slot="secondary-actions">Cancel</s-button>
|
|
141
|
+
<s-button slot="primary-action" variant="primary">
|
|
142
|
+
Save product
|
|
143
|
+
</s-button>
|
|
144
|
+
</s-button-group>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
##### html
|
|
148
|
+
|
|
149
|
+
```html
|
|
150
|
+
<s-button-group>
|
|
151
|
+
<s-button slot="secondary-actions">Cancel</s-button>
|
|
152
|
+
<s-button slot="primary-action" variant="primary">Save product</s-button>
|
|
153
|
+
</s-button-group>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
* #### Buttons with icons
|
|
157
|
+
|
|
158
|
+
##### Description
|
|
159
|
+
|
|
160
|
+
Icon-labeled buttons for common actions.
|
|
161
|
+
|
|
162
|
+
##### jsx
|
|
163
|
+
|
|
164
|
+
```jsx
|
|
165
|
+
<s-button-group>
|
|
166
|
+
<s-button slot="secondary-actions" icon="duplicate">
|
|
167
|
+
Duplicate
|
|
168
|
+
</s-button>
|
|
169
|
+
<s-button slot="secondary-actions" icon="archive">
|
|
170
|
+
Archive
|
|
171
|
+
</s-button>
|
|
172
|
+
<s-button slot="secondary-actions" icon="delete" tone="critical">
|
|
173
|
+
Delete
|
|
174
|
+
</s-button>
|
|
175
|
+
</s-button-group>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
##### html
|
|
179
|
+
|
|
180
|
+
```html
|
|
181
|
+
<s-button-group>
|
|
182
|
+
<s-button slot="secondary-actions" icon="duplicate">Duplicate</s-button>
|
|
183
|
+
<s-button slot="secondary-actions" icon="archive">Archive</s-button>
|
|
184
|
+
<s-button slot="secondary-actions" icon="delete" tone="critical">
|
|
185
|
+
Delete
|
|
186
|
+
</s-button>
|
|
187
|
+
</s-button-group>
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
* #### Segmented appearance
|
|
191
|
+
|
|
192
|
+
##### Description
|
|
193
|
+
|
|
194
|
+
Tightly grouped buttons for view switching and filter options.
|
|
195
|
+
|
|
196
|
+
##### jsx
|
|
197
|
+
|
|
198
|
+
```jsx
|
|
199
|
+
<s-button-group gap="none">
|
|
200
|
+
<s-button slot="secondary-actions">Day</s-button>
|
|
201
|
+
<s-button slot="secondary-actions">Week</s-button>
|
|
202
|
+
<s-button slot="secondary-actions">Month</s-button>
|
|
203
|
+
</s-button-group>
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
##### html
|
|
207
|
+
|
|
208
|
+
```html
|
|
209
|
+
<s-button-group gap="none">
|
|
210
|
+
<s-button slot="secondary-actions">Day</s-button>
|
|
211
|
+
<s-button slot="secondary-actions">Week</s-button>
|
|
212
|
+
<s-button slot="secondary-actions">Month</s-button>
|
|
213
|
+
</s-button-group>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
* #### Destructive actions pattern
|
|
217
|
+
|
|
218
|
+
##### Description
|
|
219
|
+
|
|
220
|
+
Confirmation dialog style with cancel option and destructive action.
|
|
221
|
+
|
|
222
|
+
##### jsx
|
|
223
|
+
|
|
224
|
+
```jsx
|
|
225
|
+
<s-button-group>
|
|
226
|
+
<s-button slot="secondary-actions">Cancel</s-button>
|
|
227
|
+
<s-button slot="secondary-actions" tone="critical">
|
|
228
|
+
Delete product
|
|
229
|
+
</s-button>
|
|
230
|
+
</s-button-group>
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
##### html
|
|
234
|
+
|
|
235
|
+
```html
|
|
236
|
+
<s-button-group>
|
|
237
|
+
<s-button slot="secondary-actions">Cancel</s-button>
|
|
238
|
+
<s-button slot="secondary-actions" tone="critical">Delete product</s-button>
|
|
239
|
+
</s-button-group>
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Useful for
|
|
243
|
+
|
|
244
|
+
* Accessing related actions in a consistent layout
|
|
245
|
+
* Making secondary actions visible alongside primary actions
|
|
246
|
+
|
|
247
|
+
## Best practices
|
|
248
|
+
|
|
249
|
+
* Group together related calls to action
|
|
250
|
+
* Avoid too many actions that may cause uncertainty
|
|
251
|
+
* Consider how buttons will work on small screens
|
package/docs/checkbox.md
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Checkbox
|
|
3
|
+
description: >-
|
|
4
|
+
Give users a clear way to make selections, such as agreeing to terms or
|
|
5
|
+
choosing multiple items from a list.
|
|
6
|
+
api_name: app-home
|
|
7
|
+
source_url:
|
|
8
|
+
html: 'https://shopify.dev/docs/api/app-home/polaris-web-components/forms/checkbox'
|
|
9
|
+
md: >-
|
|
10
|
+
https://shopify.dev/docs/api/app-home/polaris-web-components/forms/checkbox.md
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Checkbox
|
|
14
|
+
|
|
15
|
+
Give users a clear way to make selections, such as agreeing to terms or choosing multiple items from a list.
|
|
16
|
+
|
|
17
|
+
## Properties
|
|
18
|
+
|
|
19
|
+
* accessibilityLabel
|
|
20
|
+
|
|
21
|
+
string
|
|
22
|
+
|
|
23
|
+
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.
|
|
24
|
+
|
|
25
|
+
* checked
|
|
26
|
+
|
|
27
|
+
boolean
|
|
28
|
+
|
|
29
|
+
Default: false
|
|
30
|
+
|
|
31
|
+
Whether the control is active.
|
|
32
|
+
|
|
33
|
+
* defaultChecked
|
|
34
|
+
|
|
35
|
+
boolean
|
|
36
|
+
|
|
37
|
+
Default: false
|
|
38
|
+
|
|
39
|
+
Whether the control is active by default.
|
|
40
|
+
|
|
41
|
+
* defaultIndeterminate
|
|
42
|
+
|
|
43
|
+
boolean
|
|
44
|
+
|
|
45
|
+
Default: false
|
|
46
|
+
|
|
47
|
+
* details
|
|
48
|
+
|
|
49
|
+
string
|
|
50
|
+
|
|
51
|
+
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.
|
|
52
|
+
|
|
53
|
+
This will also be exposed to screen reader users.
|
|
54
|
+
|
|
55
|
+
* disabled
|
|
56
|
+
|
|
57
|
+
boolean
|
|
58
|
+
|
|
59
|
+
Default: false
|
|
60
|
+
|
|
61
|
+
Disables the field, disallowing any interaction.
|
|
62
|
+
|
|
63
|
+
* error
|
|
64
|
+
|
|
65
|
+
string
|
|
66
|
+
|
|
67
|
+
Indicate an error to the user. The field will be given a specific stylistic treatment to communicate problems that have to be resolved immediately.
|
|
68
|
+
|
|
69
|
+
* id
|
|
70
|
+
|
|
71
|
+
string
|
|
72
|
+
|
|
73
|
+
A unique identifier for the element.
|
|
74
|
+
|
|
75
|
+
* indeterminate
|
|
76
|
+
|
|
77
|
+
boolean
|
|
78
|
+
|
|
79
|
+
* label
|
|
80
|
+
|
|
81
|
+
string
|
|
82
|
+
|
|
83
|
+
Visual content to use as the control label.
|
|
84
|
+
|
|
85
|
+
* name
|
|
86
|
+
|
|
87
|
+
string
|
|
88
|
+
|
|
89
|
+
An identifier for the field that is unique within the nearest containing form.
|
|
90
|
+
|
|
91
|
+
* required
|
|
92
|
+
|
|
93
|
+
boolean
|
|
94
|
+
|
|
95
|
+
Default: false
|
|
96
|
+
|
|
97
|
+
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.
|
|
98
|
+
|
|
99
|
+
* value
|
|
100
|
+
|
|
101
|
+
string
|
|
102
|
+
|
|
103
|
+
The value used in form data when the checkbox is checked.
|
|
104
|
+
|
|
105
|
+
## Events
|
|
106
|
+
|
|
107
|
+
Learn more about [registering events](https://shopify.dev/docs/api/app-home/using-polaris-components#event-handling).
|
|
108
|
+
|
|
109
|
+
* change
|
|
110
|
+
|
|
111
|
+
CallbackEventListener<'input'>
|
|
112
|
+
|
|
113
|
+
* input
|
|
114
|
+
|
|
115
|
+
CallbackEventListener<'input'>
|
|
116
|
+
|
|
117
|
+
### CallbackEventListener
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
(EventListener & {
|
|
121
|
+
(event: CallbackEvent<T>): void;
|
|
122
|
+
}) | null
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### CallbackEvent
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
Event & {
|
|
129
|
+
currentTarget: HTMLElementTagNameMap[T];
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Examples
|
|
134
|
+
|
|
135
|
+
### Examples
|
|
136
|
+
|
|
137
|
+
* #### Code
|
|
138
|
+
|
|
139
|
+
##### jsx
|
|
140
|
+
|
|
141
|
+
```jsx
|
|
142
|
+
<s-checkbox
|
|
143
|
+
label="Require a confirmation step"
|
|
144
|
+
details="Ensure all criteria are met before proceeding"
|
|
145
|
+
/>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
##### html
|
|
149
|
+
|
|
150
|
+
```html
|
|
151
|
+
<s-checkbox
|
|
152
|
+
label="Require a confirmation step"
|
|
153
|
+
details="Ensure all criteria are met before proceeding"
|
|
154
|
+
></s-checkbox>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
* #### Indeterminate state
|
|
158
|
+
|
|
159
|
+
##### Description
|
|
160
|
+
|
|
161
|
+
Checkbox in indeterminate state, commonly used for "select all" functionality when some items are selected.
|
|
162
|
+
|
|
163
|
+
##### jsx
|
|
164
|
+
|
|
165
|
+
```jsx
|
|
166
|
+
const [selectedItems, setSelectedItems] = useState([]);
|
|
167
|
+
const items = ['Item 1', 'Item 2', 'Item 3'];
|
|
168
|
+
|
|
169
|
+
const toggleItem = (value, checked) => setSelectedItems(checked ? [...selectedItems, value] : selectedItems.filter(item => item !== value));
|
|
170
|
+
const toggleAll = (checked) => setSelectedItems(checked ? items : []);
|
|
171
|
+
const isSelected = (item) => selectedItems.includes(item);
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
<s-stack gap="small">
|
|
175
|
+
<s-checkbox
|
|
176
|
+
label="Select all items"
|
|
177
|
+
indeterminate={selectedItems.length !== 0 && selectedItems.length !== items.length}
|
|
178
|
+
checked={selectedItems.length === items.length}
|
|
179
|
+
onChange={e => toggleAll(e.currentTarget.checked)}
|
|
180
|
+
/>
|
|
181
|
+
<s-divider />
|
|
182
|
+
{items.map(i => (
|
|
183
|
+
<s-checkbox key={i} label={i} checked={isSelected(i)} onChange={e => toggleItem(i, e.currentTarget.checked)} />
|
|
184
|
+
))}
|
|
185
|
+
</s-stack>
|
|
186
|
+
);
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
* #### Error state
|
|
190
|
+
|
|
191
|
+
##### Description
|
|
192
|
+
|
|
193
|
+
Checkbox with validation error message for required form fields.
|
|
194
|
+
|
|
195
|
+
##### jsx
|
|
196
|
+
|
|
197
|
+
```jsx
|
|
198
|
+
<s-checkbox
|
|
199
|
+
label="I agree to the terms"
|
|
200
|
+
error="You must accept the terms to continue"
|
|
201
|
+
/>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
##### html
|
|
205
|
+
|
|
206
|
+
```html
|
|
207
|
+
<s-checkbox
|
|
208
|
+
label="I agree to the terms"
|
|
209
|
+
error="You must accept the terms to continue"
|
|
210
|
+
></s-checkbox>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
* #### Help text
|
|
214
|
+
|
|
215
|
+
##### Description
|
|
216
|
+
|
|
217
|
+
Checkbox with descriptive details text to provide additional context about the option.
|
|
218
|
+
|
|
219
|
+
##### jsx
|
|
220
|
+
|
|
221
|
+
```jsx
|
|
222
|
+
<s-checkbox
|
|
223
|
+
label="Send order notifications"
|
|
224
|
+
details="You'll receive emails when orders are placed, fulfilled, or cancelled"
|
|
225
|
+
/>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
##### html
|
|
229
|
+
|
|
230
|
+
```html
|
|
231
|
+
<s-checkbox
|
|
232
|
+
label="Send order notifications"
|
|
233
|
+
details="You'll receive emails when orders are placed, fulfilled, or cancelled"
|
|
234
|
+
></s-checkbox>
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
* #### Disabled state
|
|
238
|
+
|
|
239
|
+
##### Description
|
|
240
|
+
|
|
241
|
+
Checkbox in disabled state with explanatory details about why it's unavailable.
|
|
242
|
+
|
|
243
|
+
##### jsx
|
|
244
|
+
|
|
245
|
+
```jsx
|
|
246
|
+
<s-checkbox
|
|
247
|
+
label="Advanced settings"
|
|
248
|
+
disabled
|
|
249
|
+
details="Contact your administrator to enable advanced settings"
|
|
250
|
+
/>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
##### html
|
|
254
|
+
|
|
255
|
+
```html
|
|
256
|
+
<s-checkbox
|
|
257
|
+
label="Advanced settings"
|
|
258
|
+
disabled
|
|
259
|
+
details="Contact your administrator to enable advanced settings"
|
|
260
|
+
></s-checkbox>
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
* #### Settings group
|
|
264
|
+
|
|
265
|
+
##### Description
|
|
266
|
+
|
|
267
|
+
Multiple checkboxes for different configuration options with helpful details.
|
|
268
|
+
|
|
269
|
+
##### jsx
|
|
270
|
+
|
|
271
|
+
```jsx
|
|
272
|
+
<s-stack gap="base">
|
|
273
|
+
<s-checkbox label="Show only published products" checked />
|
|
274
|
+
<s-checkbox
|
|
275
|
+
label="Enable inventory tracking"
|
|
276
|
+
details="Track inventory levels and receive low stock alerts"
|
|
277
|
+
checked
|
|
278
|
+
/>
|
|
279
|
+
<s-checkbox
|
|
280
|
+
label="View customer data"
|
|
281
|
+
details="Allow staff to access customer contact information and order history"
|
|
282
|
+
/>
|
|
283
|
+
</s-stack>
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
##### html
|
|
287
|
+
|
|
288
|
+
```html
|
|
289
|
+
<s-stack gap="base">
|
|
290
|
+
<s-checkbox label="Show only published products" checked></s-checkbox>
|
|
291
|
+
<s-checkbox
|
|
292
|
+
label="Enable inventory tracking"
|
|
293
|
+
details="Track inventory levels and receive low stock alerts"
|
|
294
|
+
checked
|
|
295
|
+
></s-checkbox>
|
|
296
|
+
<s-checkbox
|
|
297
|
+
label="View customer data"
|
|
298
|
+
details="Allow staff to access customer contact information and order history"
|
|
299
|
+
></s-checkbox>
|
|
300
|
+
</s-stack>
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
* #### Checkbox validation
|
|
304
|
+
|
|
305
|
+
##### Description
|
|
306
|
+
|
|
307
|
+
Interactive example showing required checkbox validation with dynamic error messages.
|
|
308
|
+
|
|
309
|
+
##### jsx
|
|
310
|
+
|
|
311
|
+
```jsx
|
|
312
|
+
const [checked, setChecked] = useState(false);
|
|
313
|
+
const errorMessage = 'You must accept the terms to continue';
|
|
314
|
+
const [error, setError] = useState(errorMessage);
|
|
315
|
+
|
|
316
|
+
return (
|
|
317
|
+
<s-section>
|
|
318
|
+
<s-stack gap="base" justifyContent="start">
|
|
319
|
+
<s-text-field label="Name" />
|
|
320
|
+
<s-checkbox
|
|
321
|
+
label="I agree to the terms"
|
|
322
|
+
checked={checked}
|
|
323
|
+
error={error}
|
|
324
|
+
onChange={(e) => {
|
|
325
|
+
setChecked(e.currentTarget.checked);
|
|
326
|
+
setError(e.currentTarget.checked ? '' : errorMessage);
|
|
327
|
+
}}
|
|
328
|
+
/>
|
|
329
|
+
</s-stack>
|
|
330
|
+
</s-section>
|
|
331
|
+
)
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
## Best practices
|
|
335
|
+
|
|
336
|
+
* Use ChoiceList when rendering multiple checkboxes to provide a consistent and accessible selection interface
|
|
337
|
+
* Work independently from each other
|
|
338
|
+
* Be framed positively (e.g., "Publish store" not "Hide store")
|
|
339
|
+
* Always have a label when used to activate or deactivate a setting
|
|
340
|
+
* Be listed in a logical order (alphabetical, numerical, time-based, etc.)
|
|
341
|
+
|
|
342
|
+
## Content guidelines
|
|
343
|
+
|
|
344
|
+
* Start each option with a capital letter
|
|
345
|
+
* Don't use commas or semicolons at the end of each line
|
|
346
|
+
* Use first person when asking merchants to agree to terms (e.g., "I agree to the Terms of Service")
|