You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -168,8 +178,15 @@ of assets, etc. where the checkboxes need to be noticed.
168
178
169
179
The `invalid` attribute indicates that the checkbox's value is invalid. When set, appropriate ARIA attributes will be automatically applied.
170
180
181
+
When a checkbox is in an invalid state, provide help text to explain the error and guide the user toward a solution. Wrap the checkbox in an `<sp-field-group>` to associate the help text with the checkbox. (See [help text](#help-text) for more information.)
182
+
171
183
```html
172
-
<sp-checkboxinvalid>Invalid</sp-checkbox>
184
+
<sp-field-groupverticallabel="Terms and conditions"invalid>
185
+
<sp-checkboxinvalid>I accept the terms and conditions</sp-checkbox>
186
+
<sp-help-textslot="negative-help-text"icon>
187
+
You must accept the terms to continue.
188
+
</sp-help-text>
189
+
</sp-field-group>
173
190
```
174
191
175
192
#### Disabled
@@ -196,6 +213,86 @@ Checkboxes have a `readonly` attribute for when they’re in the disabled state
196
213
<sp-checkboxreadonly>Read-only</sp-checkbox>
197
214
```
198
215
216
+
### Help text
217
+
218
+
Help text can be accessibly associated with checkboxes by using the `help-text` or `negative-help-text` slots on an `<sp-field-group>` element. When using the `negative-help-text` slot, `<sp-field-group>` will self manage the presence of this content based on the value of the `invalid` property on your `<sp-field-group>` element. Content within the `help-text` slot will be shown by default. When your `<sp-field-group>` should receive help text based on state outside of the complexity of `invalid` or not, manage the content addressed to the `help-text` from above to ensure that it displays the right messaging and possesses the right `variant`.
219
+
220
+
Read more about using [help text](../help-text).
221
+
222
+
<sp-tabsselected="self"autolabel="Help text usage with checkboxes">
When a single checkbox requires validation, wrap it in an `<sp-field-group>` to associate help text:
281
+
282
+
```html
283
+
<sp-field-groupverticallabel="Agreement"invalid>
284
+
<sp-checkboxinvalid>
285
+
I have read and accept the terms of service
286
+
</sp-checkbox>
287
+
<sp-help-textslot="negative-help-text"icon>
288
+
You must accept the terms of service to continue.
289
+
</sp-help-text>
290
+
</sp-field-group>
291
+
```
292
+
293
+
</sp-tab-panel>
294
+
</sp-tabs>
295
+
199
296
### Behaviors
200
297
201
298
#### Handling events
@@ -236,6 +333,14 @@ Sets of checkboxes should always have a clear label that describes what the list
236
333
</sp-field-group>
237
334
```
238
335
336
+
#### Provide help text in the correct location
337
+
338
+
Checkbox groups should use help text for error messaging and descriptions. Descriptions are valuable for giving context about a selection or for clarifying the options.
339
+
340
+
It is [not currently possible](https://w3c.github.io/webcomponents-cg/#cross-root-aria) to provide accessible ARIA references between elements in different shadow roots. To ensure proper association between elements, help text must be included via the `slot="help-text"` or `slot="negative-help-text"` on the parent `<sp-field-group>`.
341
+
342
+
See [help text](../help-text) for more information.
343
+
239
344
#### Keyboard Navigation
240
345
241
346
Checkboxes can be toggled using the <kbd>Space</kbd> key when focused. They follow the standard tab order of the page.
Copy file name to clipboardExpand all lines: 1st-gen/packages/field-group/README.md
+20-3Lines changed: 20 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -121,6 +121,23 @@ Help text can be accessibly associated with an `<sp-field-group>` element by usi
121
121
</sp-field-group>
122
122
```
123
123
124
+
### States
125
+
126
+
#### Invalid
127
+
128
+
When a group of checkboxes fails validation, use the `invalid` attribute on the field group along with `negative-help-text` to explain the error. Set the `invalid` attribute on individual checkboxes as well to apply the appropriate visual styling.
@@ -131,9 +148,9 @@ Every field group should have a label. A field without a label is ambiguous and
131
148
132
149
The description in the help text is flexible and encompasses a range of guidance. Sometimes this guidance is about what to input, and sometime it’s about how to input. This includes information such as:
133
150
134
-
-An overall description of the input field
135
-
-Hints for what kind of information needs to be input
136
-
-Specific formatting examples or requirements
151
+
- An overall description of the input field
152
+
- Hints for what kind of information needs to be input
153
+
- Specific formatting examples or requirements
137
154
138
155
Learn more about [using help text](https://spectrum.adobe.com/page/text-field/#Use-help-text-to-show-hints,-formatting,-and-requirements).
0 commit comments