@tempoxyz/ds 0.3.10 → 0.3.11
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/dist/docs/AGENTS.md +9 -0
- package/dist/docs/components/accordion.md +489 -0
- package/dist/docs/components/address-card.md +147 -0
- package/dist/docs/components/agent-logo.md +194 -0
- package/dist/docs/components/alert-dialog.md +631 -0
- package/dist/docs/components/alert.md +448 -0
- package/dist/docs/components/amount-input.md +305 -0
- package/dist/docs/components/amount.md +794 -0
- package/dist/docs/components/app-shell.md +559 -0
- package/dist/docs/components/asset-chip.md +294 -0
- package/dist/docs/components/autocomplete.md +619 -0
- package/dist/docs/components/avatar.md +321 -0
- package/dist/docs/components/badge.md +339 -0
- package/dist/docs/components/badged-logo.md +116 -0
- package/dist/docs/components/banner.md +379 -0
- package/dist/docs/components/bar-chart.md +208 -0
- package/dist/docs/components/breadcrumbs.md +380 -0
- package/dist/docs/components/button-group.md +286 -0
- package/dist/docs/components/button.md +650 -0
- package/dist/docs/components/calendar.md +375 -0
- package/dist/docs/components/callout.md +96 -0
- package/dist/docs/components/checkbox-group.md +521 -0
- package/dist/docs/components/checkbox.md +467 -0
- package/dist/docs/components/choice-group.md +516 -0
- package/dist/docs/components/choicebox.md +641 -0
- package/dist/docs/components/code.md +100 -0
- package/dist/docs/components/combobox.md +939 -0
- package/dist/docs/components/container.md +257 -0
- package/dist/docs/components/copy-button.md +642 -0
- package/dist/docs/components/date-picker.md +514 -0
- package/dist/docs/components/dialog.md +1332 -0
- package/dist/docs/components/drawer.md +966 -0
- package/dist/docs/components/empty.md +340 -0
- package/dist/docs/components/field.md +570 -0
- package/dist/docs/components/fieldset.md +398 -0
- package/dist/docs/components/frame.md +434 -0
- package/dist/docs/components/gauge.md +299 -0
- package/dist/docs/components/get-started-visual.md +117 -0
- package/dist/docs/components/grid.md +288 -0
- package/dist/docs/components/hero-visual.md +155 -0
- package/dist/docs/components/hex.md +487 -0
- package/dist/docs/components/icon-tile.md +292 -0
- package/dist/docs/components/identicon.md +371 -0
- package/dist/docs/components/inline.md +233 -0
- package/dist/docs/components/inset.md +225 -0
- package/dist/docs/components/kbd.md +423 -0
- package/dist/docs/components/list-group.md +981 -0
- package/dist/docs/components/loading-dots.md +237 -0
- package/dist/docs/components/menu.md +934 -0
- package/dist/docs/components/native-select.md +204 -0
- package/dist/docs/components/network-logo.md +248 -0
- package/dist/docs/components/number-field.md +543 -0
- package/dist/docs/components/otp-field.md +616 -0
- package/dist/docs/components/pagination.md +516 -0
- package/dist/docs/components/popover.md +544 -0
- package/dist/docs/components/progress.md +388 -0
- package/dist/docs/components/qr.md +314 -0
- package/dist/docs/components/radio-group.md +528 -0
- package/dist/docs/components/secret-value.md +406 -0
- package/dist/docs/components/select.md +751 -0
- package/dist/docs/components/separator.md +379 -0
- package/dist/docs/components/sidebar-menu.md +922 -0
- package/dist/docs/components/skeleton.md +517 -0
- package/dist/docs/components/slider.md +539 -0
- package/dist/docs/components/snippet.md +424 -0
- package/dist/docs/components/spinner.md +216 -0
- package/dist/docs/components/split-bar.md +139 -0
- package/dist/docs/components/split-button.md +464 -0
- package/dist/docs/components/stack.md +299 -0
- package/dist/docs/components/status-chip.md +226 -0
- package/dist/docs/components/status-indicator.md +119 -0
- package/dist/docs/components/status-row.md +174 -0
- package/dist/docs/components/stepper.md +451 -0
- package/dist/docs/components/success-hero.md +157 -0
- package/dist/docs/components/surface.md +639 -0
- package/dist/docs/components/switch.md +472 -0
- package/dist/docs/components/table.md +967 -0
- package/dist/docs/components/tabs.md +627 -0
- package/dist/docs/components/tempo-logo.md +185 -0
- package/dist/docs/components/text-input.md +624 -0
- package/dist/docs/components/textarea.md +352 -0
- package/dist/docs/components/toast.md +535 -0
- package/dist/docs/components/token-logo.md +371 -0
- package/dist/docs/components/token.md +247 -0
- package/dist/docs/components/tooltip.md +490 -0
- package/dist/docs/components/verification-code.md +116 -0
- package/dist/docs/components/visual.md +249 -0
- package/dist/docs/components.md +203 -0
- package/dist/docs/foundations/accessibility.md +377 -0
- package/dist/docs/foundations/agents.md +150 -0
- package/dist/docs/foundations/color.md +522 -0
- package/dist/docs/foundations/content/tone.md +194 -0
- package/dist/docs/foundations/content/voice.md +194 -0
- package/dist/docs/foundations/content/writing-style.md +406 -0
- package/dist/docs/foundations/iconography.md +282 -0
- package/dist/docs/foundations/intent.md +360 -0
- package/dist/docs/foundations/layout.md +508 -0
- package/dist/docs/foundations/linter.md +296 -0
- package/dist/docs/foundations/motion.md +151 -0
- package/dist/docs/foundations/radius-and-padding.md +86 -0
- package/dist/docs/foundations/typography.md +266 -0
- package/dist/docs/index.md +137 -0
- package/dist/docs/introduction/faq.md +132 -0
- package/dist/docs/introduction/getting-started.md +377 -0
- package/dist/docs/patterns/blockchain-values.md +709 -0
- package/dist/docs/patterns/dashboards.md +638 -0
- package/dist/docs/patterns/destructive-actions.md +626 -0
- package/dist/docs/patterns/empty-states.md +612 -0
- package/dist/docs/patterns/errors-and-validation.md +808 -0
- package/dist/docs/patterns/feedback-and-status.md +518 -0
- package/dist/docs/patterns/forms.md +679 -0
- package/dist/docs/patterns/loading.md +630 -0
- package/dist/docs/patterns/navigation.md +397 -0
- package/dist/docs/patterns/payments.md +765 -0
- package/dist/docs/patterns/responsive-layout.md +997 -0
- package/dist/docs/patterns/tables-and-lists.md +964 -0
- package/dist/docs/products/tempo-console.md +671 -0
- package/dist/docs/products/tempo-performance.md +437 -0
- package/dist/docs/products/tempo-wallet.md +438 -0
- package/package.json +1 -1
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
# Checkbox
|
|
2
|
+
|
|
3
|
+
Turns a single independent option on or off.
|
|
4
|
+
|
|
5
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Checkbox.tsx)
|
|
6
|
+
|
|
7
|
+
Figma: [Checkbox](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=3086-1190)
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
A hidden native input submits its value with the form.
|
|
12
|
+
|
|
13
|
+
## Examples
|
|
14
|
+
|
|
15
|
+
### Basic
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Checkbox, Field } from '@tempoxyz/ds'
|
|
19
|
+
|
|
20
|
+
export function Demo() {
|
|
21
|
+
return (
|
|
22
|
+
<Field.Root>
|
|
23
|
+
<Field.Item>
|
|
24
|
+
<Checkbox defaultChecked />
|
|
25
|
+
<Field.Label>Email me receipts</Field.Label>
|
|
26
|
+
</Field.Item>
|
|
27
|
+
</Field.Root>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Checkbox/Basic.tsx)
|
|
33
|
+
|
|
34
|
+
### Checked
|
|
35
|
+
|
|
36
|
+
Set `defaultChecked` for an uncontrolled checkbox, or `checked` with `onCheckedChange` to control it.
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { Checkbox, Field, style } from '@tempoxyz/ds'
|
|
40
|
+
|
|
41
|
+
function Item(props: Checkbox.Props & { label: string }) {
|
|
42
|
+
const { label, ...checkbox } = props
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Field.Root>
|
|
46
|
+
<Field.Item>
|
|
47
|
+
<Checkbox {...checkbox} />
|
|
48
|
+
<Field.Label>{label}</Field.Label>
|
|
49
|
+
</Field.Item>
|
|
50
|
+
</Field.Root>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function Demo() {
|
|
55
|
+
return (
|
|
56
|
+
<div {...styles.column()}>
|
|
57
|
+
<Item label="Unchecked" />
|
|
58
|
+
<Item defaultChecked label="Checked" />
|
|
59
|
+
</div>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
namespace styles {
|
|
64
|
+
export const column = style({ display: 'flex', flexDirection: 'column', gap: '16' })
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Checkbox/Checked.tsx)
|
|
69
|
+
|
|
70
|
+
### Indeterminate
|
|
71
|
+
|
|
72
|
+
Set `indeterminate` to show a minus and expose the mixed state.
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
import { Checkbox, Field } from '@tempoxyz/ds'
|
|
76
|
+
|
|
77
|
+
function Item(props: Checkbox.Props & { label: string }) {
|
|
78
|
+
const { label, ...checkbox } = props
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Field.Root>
|
|
82
|
+
<Field.Item>
|
|
83
|
+
<Checkbox {...checkbox} />
|
|
84
|
+
<Field.Label>{label}</Field.Label>
|
|
85
|
+
</Field.Item>
|
|
86
|
+
</Field.Root>
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function Demo() {
|
|
91
|
+
return <Item indeterminate label="Indeterminate" />
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Checkbox/Indeterminate.tsx)
|
|
96
|
+
|
|
97
|
+
### Disabled
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import { Checkbox, Field, style } from '@tempoxyz/ds'
|
|
101
|
+
|
|
102
|
+
function Item(props: Checkbox.Props & { label: string }) {
|
|
103
|
+
const { label, ...checkbox } = props
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<Field.Root>
|
|
107
|
+
<Field.Item>
|
|
108
|
+
<Checkbox {...checkbox} />
|
|
109
|
+
<Field.Label>{label}</Field.Label>
|
|
110
|
+
</Field.Item>
|
|
111
|
+
</Field.Root>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function Demo() {
|
|
116
|
+
return (
|
|
117
|
+
<div {...styles.column()}>
|
|
118
|
+
<Item disabled label="Disabled" />
|
|
119
|
+
<Item defaultChecked disabled label="Disabled checked" />
|
|
120
|
+
</div>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
namespace styles {
|
|
125
|
+
export const column = style({ display: 'flex', flexDirection: 'column', gap: '16' })
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Checkbox/Disabled.tsx)
|
|
130
|
+
|
|
131
|
+
### Size
|
|
132
|
+
|
|
133
|
+
Set `size` to `small`, `medium` (default), or `large`.
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
import { Checkbox, Field, style } from '@tempoxyz/ds'
|
|
137
|
+
|
|
138
|
+
function Item(props: Checkbox.Props & { label: string }) {
|
|
139
|
+
const { label, ...checkbox } = props
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<Field.Root>
|
|
143
|
+
<Field.Item>
|
|
144
|
+
<Checkbox {...checkbox} />
|
|
145
|
+
<Field.Label>{label}</Field.Label>
|
|
146
|
+
</Field.Item>
|
|
147
|
+
</Field.Root>
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function Demo() {
|
|
152
|
+
return (
|
|
153
|
+
<div {...styles.column()}>
|
|
154
|
+
{(['small', 'medium', 'large'] as const).map((size) => (
|
|
155
|
+
<Item defaultChecked key={size} label={size} size={size} />
|
|
156
|
+
))}
|
|
157
|
+
</div>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
namespace styles {
|
|
162
|
+
export const column = style({ display: 'flex', flexDirection: 'column', gap: '16' })
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Checkbox/Size.tsx)
|
|
167
|
+
|
|
168
|
+
## Anatomy
|
|
169
|
+
|
|
170
|
+
Import the component and assemble its parts.
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
import { Checkbox } from '@tempoxyz/ds'
|
|
174
|
+
|
|
175
|
+
<Checkbox />
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Guidelines
|
|
179
|
+
|
|
180
|
+
### When to Use
|
|
181
|
+
|
|
182
|
+
* Offer one independent choice that applies on form submit, such as Email me a receipt for each payment.
|
|
183
|
+
* Ask for agreement before a step, such as accepting the API terms before creating a key.
|
|
184
|
+
* Select table rows for a bulk action, such as revoking several API keys.
|
|
185
|
+
|
|
186
|
+
### When Not to Use
|
|
187
|
+
|
|
188
|
+
* Use [Switch](/docs/components/switch) for a setting that applies immediately.
|
|
189
|
+
* Use [CheckboxGroup](/docs/components/checkbox-group) for several related options that share one value array.
|
|
190
|
+
* If only one of several options can be chosen, use [RadioGroup](/docs/components/radio-group) or [ChoiceGroup](/docs/components/choice-group).
|
|
191
|
+
* If each option needs an icon or a description, use `Choicebox.Checkbox` from [Choicebox](/docs/components/choicebox).
|
|
192
|
+
|
|
193
|
+
### Choose Checkbox or Switch by When It Applies
|
|
194
|
+
|
|
195
|
+
* **Checkbox (on submit):** Applies when the form is submitted.
|
|
196
|
+
* **Switch (on change):** Applies immediately, such as Payment notifications.
|
|
197
|
+
|
|
198
|
+
Don't put a [Switch](/docs/components/switch) in a form that ends with Save, or a checkbox in a settings list that saves on change.
|
|
199
|
+
|
|
200
|
+
### Write the Label as the Checked Statement
|
|
201
|
+
|
|
202
|
+
**Do:** Describe what happens when the box is checked.
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
/**
|
|
206
|
+
* Do example for "Write the Label as the Checked Statement" on the Checkbox page.
|
|
207
|
+
* Describe what happens when the box is checked.
|
|
208
|
+
* @module
|
|
209
|
+
*/
|
|
210
|
+
import { Checkbox, Field } from '@tempoxyz/ds'
|
|
211
|
+
|
|
212
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
213
|
+
export function Demo() {
|
|
214
|
+
return (
|
|
215
|
+
<Field.Root>
|
|
216
|
+
<Field.Item>
|
|
217
|
+
<Checkbox defaultChecked />
|
|
218
|
+
<Field.Label>Email me a receipt for each payment</Field.Label>
|
|
219
|
+
</Field.Item>
|
|
220
|
+
</Field.Root>
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**Don't:** Write a negative label, where checking the box means don't.
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
/**
|
|
229
|
+
* Don't example for "Write the Label as the Checked Statement" on the Checkbox page.
|
|
230
|
+
* Don't write a negative label, where checking the box means don't.
|
|
231
|
+
* @module
|
|
232
|
+
*/
|
|
233
|
+
import { Checkbox, Field } from '@tempoxyz/ds'
|
|
234
|
+
|
|
235
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
236
|
+
export function Demo() {
|
|
237
|
+
return (
|
|
238
|
+
<Field.Root>
|
|
239
|
+
<Field.Item>
|
|
240
|
+
<Checkbox />
|
|
241
|
+
<Field.Label>Don't email me payment receipts</Field.Label>
|
|
242
|
+
</Field.Item>
|
|
243
|
+
</Field.Root>
|
|
244
|
+
)
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Make the Label Toggle the Box
|
|
249
|
+
|
|
250
|
+
Pair the checkbox with `Field.Item` and `Field.Label` from [Field](/docs/components/field), or wrap both in a `<label>`. Pressing the text then toggles the box.
|
|
251
|
+
|
|
252
|
+
**Do:** Put the checkbox and its `Field.Label` in one `Field.Item`.
|
|
253
|
+
|
|
254
|
+
```tsx
|
|
255
|
+
/**
|
|
256
|
+
* Do example for "Make the Label Toggle the Box" on the Checkbox page.
|
|
257
|
+
* Put the checkbox and its `Field.Label` in one `Field.Item`.
|
|
258
|
+
* @module
|
|
259
|
+
*/
|
|
260
|
+
import { Checkbox, Field } from '@tempoxyz/ds'
|
|
261
|
+
|
|
262
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
263
|
+
export function Demo() {
|
|
264
|
+
return (
|
|
265
|
+
<Field.Root>
|
|
266
|
+
<Field.Item>
|
|
267
|
+
<Checkbox />
|
|
268
|
+
<Field.Label>Email me a receipt for each payment</Field.Label>
|
|
269
|
+
</Field.Item>
|
|
270
|
+
</Field.Root>
|
|
271
|
+
)
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
**Don't:** Place plain text beside the box. It neither names nor toggles it.
|
|
276
|
+
|
|
277
|
+
```tsx
|
|
278
|
+
/**
|
|
279
|
+
* Don't example for "Make the Label Toggle the Box" on the Checkbox page.
|
|
280
|
+
* Don't place plain text beside the box. It neither names nor toggles it.
|
|
281
|
+
* @module
|
|
282
|
+
*/
|
|
283
|
+
import { Checkbox, style } from '@tempoxyz/ds'
|
|
284
|
+
|
|
285
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
286
|
+
export function Demo() {
|
|
287
|
+
return (
|
|
288
|
+
<div {...styles.row()}>
|
|
289
|
+
<Checkbox />
|
|
290
|
+
<span>Email me a receipt for each payment</span>
|
|
291
|
+
</div>
|
|
292
|
+
)
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
namespace styles {
|
|
296
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '8' })
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Use Indeterminate for Partial Selection Only
|
|
301
|
+
|
|
302
|
+
Inside a [CheckboxGroup](/docs/components/checkbox-group), set `parent` instead and let the group manage the state.
|
|
303
|
+
|
|
304
|
+
**Do:** Set `indeterminate` on a box that controls others while only some are checked.
|
|
305
|
+
|
|
306
|
+
```tsx
|
|
307
|
+
/**
|
|
308
|
+
* Do example for "Use Indeterminate for Partial Selection Only" on the Checkbox page.
|
|
309
|
+
* Set `indeterminate` on a box that controls others while only some are checked.
|
|
310
|
+
* @module
|
|
311
|
+
*/
|
|
312
|
+
import { Checkbox, Field, style } from '@tempoxyz/ds'
|
|
313
|
+
|
|
314
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
315
|
+
export function Demo() {
|
|
316
|
+
return (
|
|
317
|
+
<div {...styles.list()}>
|
|
318
|
+
<Field.Root>
|
|
319
|
+
<Field.Item>
|
|
320
|
+
<Checkbox indeterminate />
|
|
321
|
+
<Field.Label>Select all keys</Field.Label>
|
|
322
|
+
</Field.Item>
|
|
323
|
+
</Field.Root>
|
|
324
|
+
<Field.Root>
|
|
325
|
+
<Field.Item>
|
|
326
|
+
<Checkbox defaultChecked />
|
|
327
|
+
<Field.Label>prod-api-01</Field.Label>
|
|
328
|
+
</Field.Item>
|
|
329
|
+
</Field.Root>
|
|
330
|
+
<Field.Root>
|
|
331
|
+
<Field.Item>
|
|
332
|
+
<Checkbox />
|
|
333
|
+
<Field.Label>staging-api-02</Field.Label>
|
|
334
|
+
</Field.Item>
|
|
335
|
+
</Field.Root>
|
|
336
|
+
</div>
|
|
337
|
+
)
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
namespace styles {
|
|
341
|
+
export const list = style({ display: 'flex', flexDirection: 'column', gap: '12' })
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
**Don't:** Set `indeterminate` on a box that controls no other boxes.
|
|
346
|
+
|
|
347
|
+
```tsx
|
|
348
|
+
/**
|
|
349
|
+
* Don't example for "Use Indeterminate for Partial Selection Only" on the Checkbox page.
|
|
350
|
+
* Don't set `indeterminate` on a box that controls no other boxes.
|
|
351
|
+
* @module
|
|
352
|
+
*/
|
|
353
|
+
import { Checkbox, Field } from '@tempoxyz/ds'
|
|
354
|
+
|
|
355
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
356
|
+
export function Demo() {
|
|
357
|
+
return (
|
|
358
|
+
<Field.Root>
|
|
359
|
+
<Field.Item>
|
|
360
|
+
<Checkbox indeterminate />
|
|
361
|
+
<Field.Label>Email me a receipt for each payment</Field.Label>
|
|
362
|
+
</Field.Item>
|
|
363
|
+
</Field.Root>
|
|
364
|
+
)
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Leave Consent Unchecked
|
|
369
|
+
|
|
370
|
+
If a box must be checked to continue, set `required` and show a `Field.Error` when it is unchecked.
|
|
371
|
+
|
|
372
|
+
**Do:** Leave boxes that record agreement or opt in to email unchecked.
|
|
373
|
+
|
|
374
|
+
```tsx
|
|
375
|
+
/**
|
|
376
|
+
* Do example for "Leave Consent Unchecked" on the Checkbox page.
|
|
377
|
+
* Leave boxes that record agreement or opt in to email unchecked.
|
|
378
|
+
* @module
|
|
379
|
+
*/
|
|
380
|
+
import { Checkbox, Field } from '@tempoxyz/ds'
|
|
381
|
+
|
|
382
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
383
|
+
export function Demo() {
|
|
384
|
+
return (
|
|
385
|
+
<Field.Root>
|
|
386
|
+
<Field.Item>
|
|
387
|
+
<Checkbox />
|
|
388
|
+
<Field.Label>Email me product updates</Field.Label>
|
|
389
|
+
</Field.Item>
|
|
390
|
+
</Field.Root>
|
|
391
|
+
)
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
**Don't:** Preselect consent.
|
|
396
|
+
|
|
397
|
+
```tsx
|
|
398
|
+
/** Don't example for "Leave Consent Unchecked" on the Checkbox page. Don't preselect consent. @module */
|
|
399
|
+
import { Checkbox, Field } from '@tempoxyz/ds'
|
|
400
|
+
|
|
401
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
402
|
+
export function Demo() {
|
|
403
|
+
return (
|
|
404
|
+
<Field.Root>
|
|
405
|
+
<Field.Item>
|
|
406
|
+
<Checkbox defaultChecked />
|
|
407
|
+
<Field.Label>Email me product updates</Field.Label>
|
|
408
|
+
</Field.Item>
|
|
409
|
+
</Field.Root>
|
|
410
|
+
)
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
## Content
|
|
415
|
+
|
|
416
|
+
* **Explanation:** Put it in a `Field.Description` after the `Field.Item`, in the same `Field.Root`.
|
|
417
|
+
* **Links:** Keep them out of the label, where they compete with its press target. Link to terms from the description.
|
|
418
|
+
|
|
419
|
+
## Accessibility
|
|
420
|
+
|
|
421
|
+
Follows the [WAI-ARIA checkbox pattern](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/).
|
|
422
|
+
|
|
423
|
+
### Semantics
|
|
424
|
+
|
|
425
|
+
* **Control (checkbox):** Reports a checked, unchecked, or mixed state to assistive technology.
|
|
426
|
+
* **Native TextInput (input):** A hidden native input submits the value under `name`. Screen readers and Tab skip it.
|
|
427
|
+
* **Indeterminate (mixed):** Shows a minus in the box and exposes the mixed state to assistive technology.
|
|
428
|
+
* **Disabled (aria-disabled):** Dims the box, blocks changes, and removes it from the tab order.
|
|
429
|
+
* **Target Size (36 to 44px):** An invisible hit area extends each indicator past the 24px WCAG 2.2 minimum.
|
|
430
|
+
|
|
431
|
+
### Keyboard
|
|
432
|
+
|
|
433
|
+
* **Move to the Checkbox (Tab):** Moves focus to the checkbox. Each one is its own tab stop.
|
|
434
|
+
* **Toggle the Checkbox (Space):** Toggles the checkbox between the checked and unchecked states.
|
|
435
|
+
* **Submit the Form (Enter):** Submits the owning form without toggling, as a native checkbox does.
|
|
436
|
+
|
|
437
|
+
### Motion
|
|
438
|
+
|
|
439
|
+
The check animates in with a slight overshoot. Under `prefers-reduced-motion: reduce`, it fades.
|
|
440
|
+
|
|
441
|
+
### Your Responsibilities
|
|
442
|
+
|
|
443
|
+
* **Use ARIA Labels Sparingly (aria-label):** Use it only if the layout already shows the label, such as a table row selector.
|
|
444
|
+
* **Explain Disabled Checkboxes:** Say why in nearby text. A disabled checkbox cannot take focus.
|
|
445
|
+
* **Pair Invalid With an Error (Field.Error):** An invalid field outlines the box in red. Add an error message to explain it.
|
|
446
|
+
|
|
447
|
+
## Related
|
|
448
|
+
|
|
449
|
+
[CheckboxGroup](/docs/components/checkbox-group)
|
|
450
|
+
|
|
451
|
+
Use for several related checkboxes.
|
|
452
|
+
|
|
453
|
+
[Switch](/docs/components/switch)
|
|
454
|
+
|
|
455
|
+
Use for settings that apply immediately.
|
|
456
|
+
|
|
457
|
+
[Field](/docs/components/field)
|
|
458
|
+
|
|
459
|
+
Use for the label and description.
|
|
460
|
+
|
|
461
|
+
[Choicebox](/docs/components/choicebox)
|
|
462
|
+
|
|
463
|
+
Use for options that need descriptions.
|
|
464
|
+
|
|
465
|
+
[Forms](/docs/patterns/forms)
|
|
466
|
+
|
|
467
|
+
Covers placing checkboxes in a form.
|