-
Notifications
You must be signed in to change notification settings - Fork 100
Expand file tree
/
Copy pathcheckbox.html
More file actions
443 lines (432 loc) · 20.8 KB
/
checkbox.html
File metadata and controls
443 lines (432 loc) · 20.8 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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
---
layout: page
title: Checkbox
figma: https://www.figma.com/file/GQB9GupHvraMioGRPbwKhO/Form-Elements
description: A checkable input that visually shows if an option is true or false.
---
<section class="stacks-section">
{% header "h2", "Base style" %}
<div class="stacks-preview">
{% copybutton %}
{% highlight html %}
<!-- Base -->
<fieldset>
<div class="d-flex gs8">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="example-name" id="example-item" />
</div>
<label class="flex--item s-label fw-normal" for="example-item">Checkbox Label</label>
</div>
</fieldset>
<!-- Disabled -->
<fieldset class="mt8">
<div class="d-flex gs8 is-disabled">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="example-disabled" id="example-item-disabled" disabled />
</div>
<label class="flex--item s-label fw-normal" for="example-item-disabled">Checkbox Label</label>
</div>
</fieldset>
{% endhighlight %}
{% endcopybutton %}
<div class="stacks-preview--example">
<!-- Base -->
<fieldset>
<div class="d-flex gs8">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="example-name" id="example-item" />
</div>
<label class="flex--item s-label fw-normal" for="example-item">Checkbox Label</label>
</div>
</fieldset>
<!-- Disabled -->
<fieldset class="mt8">
<div class="d-flex gs8 is-disabled">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="example-disabled" id="example-item-disabled" disabled />
</div>
<label class="flex--item s-label fw-normal" for="example-item-disabled">Checkbox Label</label>
</div>
</fieldset>
<!-- Checked -->
<fieldset class="mt8">
<div class="d-flex gs8">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="example-checked" id="example-item-checked" checked />
</div>
<label class="flex--item s-label fw-normal" for="example-item-checked">Checkbox Label</label>
</div>
</fieldset>
<!-- Disabled and checked -->
<fieldset class="mt8">
<div class="d-flex gs8 is-disabled">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="example-checked-disabled" id="example-item-checked-disabled" disabled checked />
</div>
<label class="flex--item s-label fw-normal" for="example-item-checked-disabled">Checkbox Label</label>
</div>
</fieldset>
</div>
</div>
</section>
<section class="stacks-section">
{% header "h2", "Accessibility" %}
<p class="stacks-copy">The best accessibility is semantic HTML. Most screen readers understand how to parse inputs if they’re correctly formatted. When it comes to checkboxes, there are a few things to keep in mind:</p>
<ul class="stacks-list">
<li>All inputs should have an <code class="stacks-code fs-body2">id</code> attribute.</li>
<li>Be sure to associate the checkbox label by using the <code class="stacks-code fs-body2">for</code> attribute. The value here is the input’s <code class="stacks-code fs-body2">id</code>.</li>
<li>If you have a group of related checkboxes, use the <code class="stacks-code fs-body2">fieldset</code> and <code class="stacks-code fs-body2">legend</code> to group them together.</li>
</ul>
<p class="stacks-copy">For more information, please read Gov.UK’s article, <a href="https://accessibility.blog.gov.uk/2016/07/22/using-the-fieldset-and-legend-elements/" target="_blank"><em>"Using the fieldset and legend elements"</em></a>.</p>
</section>
<section class="stacks-section">
{% header "h2", "Examples" %}
{% header "h3", "Vertical group" %}
<div class="stacks-preview">
{% copybutton %}
{% highlight html %}
<fieldset class="d-flex gs8 gsy fd-column">
<legend class="flex--item s-label">Which types of fruit do you like? <span class="ml4 fw-normal fc-light">(Check all that apply)</span></legend>
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-vert-checkbox-1" />
</div>
<label class="flex--item s-label fw-normal" for="choice-vert-checkbox-1">Apples</label>
</div>
</div>
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-vert-checkbox-2" />
</div>
<label class="flex--item s-label fw-normal" for="choice-vert-checkbox-2">Oranges</label>
</div>
</div>
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-vert-checkbox-3" />
</div>
<label class="flex--item s-label fw-normal" for="choice-vert-checkbox-3">Bananas</label>
</div>
</div>
</fieldset>
{% endhighlight %}
{% endcopybutton %}
<div class="stacks-preview--example">
<fieldset class="d-flex gs8 gsy fd-column">
<legend class="flex--item s-label">Which types of fruit do you like? <span class="ml4 fw-normal fc-light">(Check all that apply)</span></legend>
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-vert-checkbox-1" />
</div>
<label class="flex--item s-label fw-normal" for="choice-vert-checkbox-1">Apples</label>
</div>
</div>
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-vert-checkbox-2" />
</div>
<label class="flex--item s-label fw-normal" for="choice-vert-checkbox-2">Oranges</label>
</div>
</div>
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-vert-checkbox-3" />
</div>
<label class="flex--item s-label fw-normal" for="choice-vert-checkbox-3">Bananas</label>
</div>
</div>
</fieldset>
</div>
</div>
{% header "h3", "Horizontal group" %}
<div class="stacks-preview">
{% copybutton %}
{% highlight html %}
<fieldset class="d-flex gs8 gsy fd-column">
<legend class="flex--item s-label">Which types of fruit do you like? <span class="ml4 fw-normal fc-light">(Check all that apply)</span></legend>
<div class="flex--item">
<div class="d-flex gs16">
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-horz-checkbox-1" />
</div>
<label class="flex--item s-label fw-normal" for="choice-horz-checkbox-1">Apples</label>
</div>
</div>
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-horz-checkbox-2" />
</div>
<label class="flex--item s-label fw-normal" for="choice-horz-checkbox-2">Oranges</label>
</div>
</div>
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-horz-checkbox-3" />
</div>
<label class="flex--item s-label fw-normal" for="choice-horz-checkbox-3">Bananas</label>
</div>
</div>
</div>
</div>
</fieldset>
{% endhighlight %}
{% endcopybutton %}
<div class="stacks-preview--example">
<fieldset class="d-flex gs8 gsy fd-column">
<legend class="flex--item s-label">Which types of fruit do you like? <span class="ml4 fw-normal fc-light">(Check all that apply)</span></legend>
<div class="flex--item">
<div class="d-flex gs16">
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-horz-checkbox-1" />
</div>
<label class="flex--item s-label fw-normal" for="choice-horz-checkbox-1">Apples</label>
</div>
</div>
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-horz-checkbox-2" />
</div>
<label class="flex--item s-label fw-normal" for="choice-horz-checkbox-2">Oranges</label>
</div>
</div>
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-horz-checkbox-3" />
</div>
<label class="flex--item s-label fw-normal" for="choice-horz-checkbox-3">Bananas</label>
</div>
</div>
</div>
</div>
</fieldset>
</div>
</div>
{% header "h3", "With description copy" %}
<div class="stacks-preview">
{% copybutton %}
{% highlight html %}
<fieldset class="d-flex gs8 gsy fd-column">
<legend class="flex--item s-label">Which types of fruit do you like? <span class="ml4 fw-normal fc-light">(Check all that apply)</span></legend>
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-copy-checkbox-1" />
</div>
<div class="flex--item">
<label class="d-block mb4 s-label fw-normal" for="choice-copy-checkbox-1">
Apples
<p class="s-description">A sweet, edible fruit produced by an apple tree (Malus pumila).</p>
</label>
</div>
</div>
</div>
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-copy-checkbox-2" />
</div>
<div class="flex--item">
<label class="d-block mb4 s-label fw-normal" for="choice-copy-checkbox-2">
Oranges
<p class="s-description">A fruit of the citrus species Citrus × sinensis in the family Rutaceae.</p>
</label>
</div>
</div>
</div>
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-copy-checkbox-3" />
</div>
<div class="flex--item">
<label class="d-block mb4 s-label fw-normal" for="choice-copy-checkbox-3">
Bananas
<p class="s-description">A fruit – botanically a berry – produced by several kinds of large herbaceous flowering plants in the genus Musa.</p>
</label>
</div>
</div>
</div>
</fieldset>
{% endhighlight %}
{% endcopybutton %}
<div class="stacks-preview--example">
<fieldset class="d-flex gs8 gsy fd-column">
<legend class="flex--item s-label">Which types of fruit do you like? <span class="ml4 fw-normal fc-light">(Check all that apply)</span></legend>
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-copy-checkbox-1" />
</div>
<div class="flex--item">
<label class="d-block mb4 s-label fw-normal" for="choice-copy-checkbox-1">
Apples
<p class="s-description">A sweet, edible fruit produced by an apple tree (Malus pumila).</p>
</label>
</div>
</div>
</div>
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-copy-checkbox-2" />
</div>
<div class="flex--item">
<label class="d-block mb4 s-label fw-normal" for="choice-copy-checkbox-2">
Oranges
<p class="s-description">A fruit of the citrus species Citrus × sinensis in the family Rutaceae.</p>
</label>
</div>
</div>
</div>
<div class="flex--item">
<div class="d-flex gs8 gsx">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-copy-checkbox-3" />
</div>
<div class="flex--item">
<label class="d-block mb4 s-label fw-normal" for="choice-copy-checkbox-3">
Bananas
<p class="s-description">A fruit – botanically a berry – produced by several kinds of large herbaceous flowering plants in the genus Musa.</p>
</label>
</div>
</div>
</div>
</fieldset>
</div>
</div>
</section>
<section class="stacks-section">
{% header "h2", "Validation states" %}
<p class="stacks-copy">Checkboxes use the same validation states as <a href="{{ "/product/components/inputs" | url }}">inputs</a>.</p>
{% header "h3", "Validation classes" %}
<div class="overflow-x-auto mb32" tabindex="0">
<table class="wmn4 s-table s-table__bx-simple">
<thead>
<tr>
<th scope="col" class="s-table--cell2">Class</th>
<th scope="col" class="s-table--cell4">Applies</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
{% for item in inputs.checkbox %}
{% assign state = item.validation %}
{% for class in state %}
<tr>
<th scope="row"><code class="flex--item stacks-code bg-white">{{ class.class }}</code></th>
<td>{{ class.applies }}</td>
<td>{{ class.description }}</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
{% header "h3", "Validation examples" %}
<div class="stacks-preview">
{% copybutton %}
{% highlight html %}
<fieldset class="d-flex gs8 gsy fd-column">
<legend class="flex--item s-label">Which types of fruit do you like? <span class="ml4 fw-normal fc-light">(Check all that apply)</span></legend>
<div class="flex--item">
<div class="d-flex gs8 gsx has-warning">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-valid-checkbox-1" />
</div>
<div class="flex--item">
<label class="d-block mb4 s-label fw-normal" for="choice-valid-checkbox-1">
Apples
<p class="s-input-message"><strong>Note:</strong> Apples are currently not in season.</p>
</label>
</div>
</div>
</div>
<div class="flex--item">
<div class="d-flex gs8 gsx has-error">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-valid-checkbox-2" />
</div>
<div class="flex--item">
<label class="d-block mb4 s-label fw-normal" for="choice-valid-checkbox-2">
Oranges
<p class="s-input-message">All oranges are currently <strong>out of stock</strong>.</p>
</label>
</div>
</div>
</div>
<div class="flex--item">
<div class="d-flex gs8 gsx has-success">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-valid-checkbox-3" />
</div>
<div class="flex--item">
<label class="d-block mb4 s-label fw-normal" for="choice-valid-checkbox-3">
Bananas
<p class="s-input-message">You’ve successfully selected the most amazing fruit in the world.</p>
</label>
</div>
</div>
</div>
</fieldset>
{% endhighlight %}
{% endcopybutton %}
<div class="stacks-preview--example">
<fieldset class="d-flex gs8 gsy fd-column">
<legend class="flex--item s-label">Which types of fruit do you like? <span class="ml4 fw-normal fc-light">(Check all that apply)</span></legend>
<div class="flex--item">
<div class="d-flex gs8 gsx has-warning">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-valid-checkbox-1" />
</div>
<div class="flex--item">
<label class="d-block mb4 s-label fw-normal" for="choice-valid-checkbox-1">
Apples
<p class="s-input-message"><strong>Note:</strong> Apples are currently not in season.</p>
</label>
</div>
</div>
</div>
<div class="flex--item">
<div class="d-flex gs8 gsx has-error">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-valid-checkbox-2" />
</div>
<div class="flex--item">
<label class="d-block mb4 s-label fw-normal" for="choice-valid-checkbox-2">
Oranges
<p class="s-input-message">All oranges are currently <strong>out of stock</strong>.</p>
</label>
</div>
</div>
</div>
<div class="flex--item">
<div class="d-flex gs8 gsx has-success">
<div class="flex--item">
<input class="s-checkbox" type="checkbox" name="" id="choice-valid-checkbox-3" />
</div>
<div class="flex--item">
<label class="d-block mb4 s-label fw-normal" for="choice-valid-checkbox-3">
Bananas
<p class="s-input-message">You’ve successfully selected the most amazing fruit in the world.</p>
</label>
</div>
</div>
</div>
</fieldset>
</div>
</div>
</section>