@tempoxyz/ds 0.3.14 → 0.3.15

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.
Files changed (131) hide show
  1. package/dist/docs/AGENTS.md +73 -10
  2. package/dist/docs/{marketing/introduction/getting-started.md → marketing.md} +28 -20
  3. package/dist/docs/product/components/actions.md +2058 -0
  4. package/dist/docs/product/components/blockchain.md +3825 -0
  5. package/dist/docs/product/components/data-display.md +5901 -0
  6. package/dist/docs/product/components/feedback-and-status.md +4008 -0
  7. package/dist/docs/product/components/forms-and-inputs.md +10543 -0
  8. package/dist/docs/product/components/layout.md +3339 -0
  9. package/dist/docs/product/components/navigation.md +2914 -0
  10. package/dist/docs/product/components/overlays.md +4917 -0
  11. package/dist/docs/product/components.md +125 -125
  12. package/dist/docs/product/foundations.md +4596 -0
  13. package/dist/docs/product/patterns.md +10129 -0
  14. package/package.json +1 -1
  15. package/dist/docs/index.md +0 -145
  16. package/dist/docs/product/components/accordion.md +0 -489
  17. package/dist/docs/product/components/address-card.md +0 -147
  18. package/dist/docs/product/components/agent-logo.md +0 -194
  19. package/dist/docs/product/components/alert-dialog.md +0 -631
  20. package/dist/docs/product/components/alert.md +0 -448
  21. package/dist/docs/product/components/amount-input.md +0 -305
  22. package/dist/docs/product/components/amount.md +0 -794
  23. package/dist/docs/product/components/app-shell.md +0 -559
  24. package/dist/docs/product/components/asset-chip.md +0 -294
  25. package/dist/docs/product/components/autocomplete.md +0 -620
  26. package/dist/docs/product/components/avatar.md +0 -321
  27. package/dist/docs/product/components/badge.md +0 -339
  28. package/dist/docs/product/components/badged-logo.md +0 -116
  29. package/dist/docs/product/components/banner.md +0 -379
  30. package/dist/docs/product/components/bar-chart.md +0 -208
  31. package/dist/docs/product/components/breadcrumbs.md +0 -380
  32. package/dist/docs/product/components/button-group.md +0 -286
  33. package/dist/docs/product/components/button.md +0 -650
  34. package/dist/docs/product/components/calendar.md +0 -375
  35. package/dist/docs/product/components/callout.md +0 -96
  36. package/dist/docs/product/components/checkbox-group.md +0 -521
  37. package/dist/docs/product/components/checkbox.md +0 -467
  38. package/dist/docs/product/components/choice-group.md +0 -516
  39. package/dist/docs/product/components/choicebox.md +0 -641
  40. package/dist/docs/product/components/code.md +0 -100
  41. package/dist/docs/product/components/combobox.md +0 -939
  42. package/dist/docs/product/components/container.md +0 -257
  43. package/dist/docs/product/components/copy-button.md +0 -642
  44. package/dist/docs/product/components/date-picker.md +0 -514
  45. package/dist/docs/product/components/dialog.md +0 -1332
  46. package/dist/docs/product/components/drawer.md +0 -966
  47. package/dist/docs/product/components/empty.md +0 -340
  48. package/dist/docs/product/components/field.md +0 -570
  49. package/dist/docs/product/components/fieldset.md +0 -398
  50. package/dist/docs/product/components/frame.md +0 -434
  51. package/dist/docs/product/components/gauge.md +0 -299
  52. package/dist/docs/product/components/get-started-visual.md +0 -117
  53. package/dist/docs/product/components/grid.md +0 -288
  54. package/dist/docs/product/components/hero-visual.md +0 -155
  55. package/dist/docs/product/components/hex.md +0 -487
  56. package/dist/docs/product/components/icon-tile.md +0 -292
  57. package/dist/docs/product/components/identicon.md +0 -371
  58. package/dist/docs/product/components/inline.md +0 -233
  59. package/dist/docs/product/components/inset.md +0 -225
  60. package/dist/docs/product/components/kbd.md +0 -423
  61. package/dist/docs/product/components/list-group.md +0 -981
  62. package/dist/docs/product/components/loading-dots.md +0 -237
  63. package/dist/docs/product/components/menu.md +0 -934
  64. package/dist/docs/product/components/native-select.md +0 -204
  65. package/dist/docs/product/components/network-logo.md +0 -248
  66. package/dist/docs/product/components/number-field.md +0 -543
  67. package/dist/docs/product/components/otp-field.md +0 -616
  68. package/dist/docs/product/components/pagination.md +0 -516
  69. package/dist/docs/product/components/popover.md +0 -544
  70. package/dist/docs/product/components/progress.md +0 -388
  71. package/dist/docs/product/components/qr.md +0 -314
  72. package/dist/docs/product/components/radio-group.md +0 -528
  73. package/dist/docs/product/components/secret-value.md +0 -406
  74. package/dist/docs/product/components/select.md +0 -751
  75. package/dist/docs/product/components/separator.md +0 -379
  76. package/dist/docs/product/components/sidebar-menu.md +0 -922
  77. package/dist/docs/product/components/skeleton.md +0 -517
  78. package/dist/docs/product/components/slider.md +0 -539
  79. package/dist/docs/product/components/snippet.md +0 -424
  80. package/dist/docs/product/components/spinner.md +0 -216
  81. package/dist/docs/product/components/split-bar.md +0 -139
  82. package/dist/docs/product/components/split-button.md +0 -464
  83. package/dist/docs/product/components/stack.md +0 -299
  84. package/dist/docs/product/components/status-chip.md +0 -226
  85. package/dist/docs/product/components/status-indicator.md +0 -119
  86. package/dist/docs/product/components/status-row.md +0 -174
  87. package/dist/docs/product/components/stepper.md +0 -451
  88. package/dist/docs/product/components/success-hero.md +0 -157
  89. package/dist/docs/product/components/surface.md +0 -639
  90. package/dist/docs/product/components/switch.md +0 -472
  91. package/dist/docs/product/components/table.md +0 -968
  92. package/dist/docs/product/components/tabs.md +0 -627
  93. package/dist/docs/product/components/tempo-logo.md +0 -185
  94. package/dist/docs/product/components/text-input.md +0 -624
  95. package/dist/docs/product/components/textarea.md +0 -352
  96. package/dist/docs/product/components/toast.md +0 -535
  97. package/dist/docs/product/components/token-logo.md +0 -371
  98. package/dist/docs/product/components/token.md +0 -247
  99. package/dist/docs/product/components/tooltip.md +0 -490
  100. package/dist/docs/product/components/verification-code.md +0 -116
  101. package/dist/docs/product/components/visual.md +0 -249
  102. package/dist/docs/product/foundations/accessibility.md +0 -377
  103. package/dist/docs/product/foundations/agents.md +0 -159
  104. package/dist/docs/product/foundations/color.md +0 -522
  105. package/dist/docs/product/foundations/content/tone.md +0 -194
  106. package/dist/docs/product/foundations/content/voice.md +0 -194
  107. package/dist/docs/product/foundations/content/writing-style.md +0 -406
  108. package/dist/docs/product/foundations/iconography.md +0 -282
  109. package/dist/docs/product/foundations/intent.md +0 -360
  110. package/dist/docs/product/foundations/layout.md +0 -508
  111. package/dist/docs/product/foundations/linter.md +0 -523
  112. package/dist/docs/product/foundations/motion.md +0 -151
  113. package/dist/docs/product/foundations/radius-and-padding.md +0 -86
  114. package/dist/docs/product/foundations/typography.md +0 -331
  115. package/dist/docs/product/introduction/faq.md +0 -133
  116. package/dist/docs/product/introduction/getting-started.md +0 -377
  117. package/dist/docs/product/patterns/blockchain-values.md +0 -709
  118. package/dist/docs/product/patterns/dashboards.md +0 -638
  119. package/dist/docs/product/patterns/destructive-actions.md +0 -626
  120. package/dist/docs/product/patterns/empty-states.md +0 -612
  121. package/dist/docs/product/patterns/errors-and-validation.md +0 -808
  122. package/dist/docs/product/patterns/feedback-and-status.md +0 -518
  123. package/dist/docs/product/patterns/forms.md +0 -679
  124. package/dist/docs/product/patterns/loading.md +0 -630
  125. package/dist/docs/product/patterns/navigation.md +0 -397
  126. package/dist/docs/product/patterns/payments.md +0 -765
  127. package/dist/docs/product/patterns/responsive-layout.md +0 -997
  128. package/dist/docs/product/patterns/tables-and-lists.md +0 -1170
  129. package/dist/docs/product/products/tempo-console.md +0 -671
  130. package/dist/docs/product/products/tempo-performance.md +0 -435
  131. package/dist/docs/product/products/tempo-wallet.md +0 -438
@@ -1,516 +0,0 @@
1
- # ChoiceGroup
2
-
3
- A segmented control for a few mutually exclusive options.
4
-
5
- [View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/ChoiceGroup.tsx)
6
-
7
- Figma: [Base - Segment Item](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=3075-548) (`ChoiceGroup.Item`), [Controls/Segmented Control Item Small](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-5484) (`ChoiceGroup.Item`), [Segmented Control](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=3075-535) (`ChoiceGroup.Root`)
8
-
9
- ## Overview
10
-
11
- A single-select control with radio semantics. One option is always selected.
12
-
13
- ## Examples
14
-
15
- ### Basic
16
-
17
- ```tsx
18
- import { ChoiceGroup } from '@tempoxyz/ds'
19
-
20
- export function Demo() {
21
- return (
22
- <ChoiceGroup.Root aria-label="Amount" defaultValue="50">
23
- <ChoiceGroup.Item value="20">$20</ChoiceGroup.Item>
24
- <ChoiceGroup.Item value="50">$50</ChoiceGroup.Item>
25
- <ChoiceGroup.Item value="100">$100</ChoiceGroup.Item>
26
- </ChoiceGroup.Root>
27
- )
28
- }
29
- ```
30
-
31
- [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/ChoiceGroup/Basic.tsx)
32
-
33
- ### Size
34
-
35
- Set `size` to `small`, `medium` (default), or `large`.
36
-
37
- ```tsx
38
- import { ChoiceGroup, style } from '@tempoxyz/ds'
39
-
40
- export function Demo() {
41
- return (
42
- <div {...styles.stack()}>
43
- {(['small', 'medium', 'large'] as const).map((size) => (
44
- <ChoiceGroup.Root aria-label={`Amount ${size}`} defaultValue="50" key={size} size={size}>
45
- <ChoiceGroup.Item value="20">$20</ChoiceGroup.Item>
46
- <ChoiceGroup.Item value="50">$50</ChoiceGroup.Item>
47
- <ChoiceGroup.Item value="100">$100</ChoiceGroup.Item>
48
- </ChoiceGroup.Root>
49
- ))}
50
- </div>
51
- )
52
- }
53
-
54
- namespace styles {
55
- export const stack = style({
56
- alignItems: 'flex-start',
57
- display: 'flex',
58
- flexDirection: 'column',
59
- gap: '16',
60
- })
61
- }
62
- ```
63
-
64
- [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/ChoiceGroup/Size.tsx)
65
-
66
- ### Variant
67
-
68
- Set `variant` to `default` or `chips`. `chips` renders a horizontally scrolling row of chips, with an optional `ChoiceGroup.ItemIcon`.
69
-
70
- ```tsx
71
- import { ChoiceGroup, style } from '@tempoxyz/ds'
72
- import { Coins, Ethereum, Globe } from '@tempoxyz/ds/icons'
73
-
74
- const networks = [
75
- { icon: <Coins />, label: 'Tempo' },
76
- { icon: <Ethereum />, label: 'Ethereum' },
77
- { icon: <Globe />, label: 'Base' },
78
- { icon: <Globe />, label: 'Arbitrum' },
79
- { icon: <Globe />, label: 'Optimism' },
80
- ]
81
-
82
- export function Demo() {
83
- return (
84
- <div {...styles.stack()}>
85
- {(['small', 'medium', 'large'] as const).map((size) => (
86
- <ChoiceGroup.Root
87
- aria-label={`Network ${size}`}
88
- defaultValue="Tempo"
89
- key={size}
90
- size={size}
91
- variant="chips"
92
- >
93
- {networks.map((network) => (
94
- <ChoiceGroup.Item key={network.label} value={network.label}>
95
- <ChoiceGroup.ItemIcon>{network.icon}</ChoiceGroup.ItemIcon>
96
- {network.label}
97
- </ChoiceGroup.Item>
98
- ))}
99
- </ChoiceGroup.Root>
100
- ))}
101
- </div>
102
- )
103
- }
104
-
105
- namespace styles {
106
- export const stack = style({
107
- alignItems: 'flex-start',
108
- display: 'flex',
109
- flexDirection: 'column',
110
- gap: '16',
111
- })
112
- }
113
- ```
114
-
115
- [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/ChoiceGroup/Variant.tsx)
116
-
117
- ### Field
118
-
119
- Wrap the group in a `Field.Root`. The `Field.Label` names the group, and a `Field.Description` adds a hint below it.
120
-
121
- ```tsx
122
- import { ChoiceGroup, Field, style } from '@tempoxyz/ds'
123
- import { Coins, Ethereum, Globe } from '@tempoxyz/ds/icons'
124
-
125
- const networks = [
126
- { icon: <Coins />, label: 'Tempo' },
127
- { icon: <Ethereum />, label: 'Ethereum' },
128
- { icon: <Globe />, label: 'Base' },
129
- ]
130
-
131
- export function Demo() {
132
- return (
133
- <div {...styles.stack()}>
134
- <Field.Root>
135
- <Field.Label>Amount</Field.Label>
136
- <ChoiceGroup.Root defaultValue="50">
137
- <ChoiceGroup.Item value="20">$20</ChoiceGroup.Item>
138
- <ChoiceGroup.Item value="50">$50</ChoiceGroup.Item>
139
- <ChoiceGroup.Item value="100">$100</ChoiceGroup.Item>
140
- </ChoiceGroup.Root>
141
- <Field.Description>Charged to your saved card.</Field.Description>
142
- </Field.Root>
143
- <Field.Root>
144
- <Field.Label>Network</Field.Label>
145
- <ChoiceGroup.Root defaultValue="Tempo" variant="chips">
146
- {networks.map((network) => (
147
- <ChoiceGroup.Item key={network.label} value={network.label}>
148
- <ChoiceGroup.ItemIcon>{network.icon}</ChoiceGroup.ItemIcon>
149
- {network.label}
150
- </ChoiceGroup.Item>
151
- ))}
152
- </ChoiceGroup.Root>
153
- </Field.Root>
154
- </div>
155
- )
156
- }
157
-
158
- namespace styles {
159
- export const stack = style({
160
- display: 'flex',
161
- flexDirection: 'column',
162
- gap: '24',
163
- maxWidth: '320px !custom',
164
- })
165
- }
166
- ```
167
-
168
- [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/ChoiceGroup/Field.tsx)
169
-
170
- ### Disabled
171
-
172
- Set `disabled` on a `ChoiceGroup.Item` to make one option unavailable.
173
-
174
- ```tsx
175
- import { ChoiceGroup } from '@tempoxyz/ds'
176
-
177
- export function Demo() {
178
- return (
179
- <ChoiceGroup.Root aria-label="Amount" defaultValue="50">
180
- <ChoiceGroup.Item value="20">$20</ChoiceGroup.Item>
181
- <ChoiceGroup.Item value="50">$50</ChoiceGroup.Item>
182
- <ChoiceGroup.Item value="100">$100</ChoiceGroup.Item>
183
- <ChoiceGroup.Item disabled value="other">
184
- Other
185
- </ChoiceGroup.Item>
186
- </ChoiceGroup.Root>
187
- )
188
- }
189
- ```
190
-
191
- [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/ChoiceGroup/Disabled.tsx)
192
-
193
- ## Anatomy
194
-
195
- Import the component and assemble its parts.
196
-
197
- ```tsx
198
- import { ChoiceGroup } from '@tempoxyz/ds'
199
-
200
- <ChoiceGroup.Root>
201
- <ChoiceGroup.Item>
202
- <ChoiceGroup.ItemIcon />
203
- </ChoiceGroup.Item>
204
- </ChoiceGroup.Root>
205
- ```
206
-
207
- ## Guidelines
208
-
209
- ### When to Use
210
-
211
- * Switch between two to four short options that change a view, such as the 1H, 24H, 7D, and 30D range on a TPS chart.
212
- * Pick a preset value, such as $20, $50, or $100 on Add funds.
213
- * Filter by one option from a longer set with `variant="chips"`, such as the network for a deposit.
214
-
215
- ### When Not to Use
216
-
217
- * If options need longer labels or are submitted with a form, use [RadioGroup](radio-group.md).
218
- * Use [Select](select.md) for many options, or when space is limited.
219
- * Use [Tabs](tabs.md) to switch between panels, such as Overview, Activity, and Settings.
220
- * If each option needs an icon and a description, use [Choicebox](choicebox.md).
221
- * Use [Switch](switch.md) for an on or off setting, not On and Off segments.
222
- * Use [Button](button.md) for actions such as Send, Receive, and Swap.
223
-
224
- ### Keep Options Few and Short
225
-
226
- Use two to four options of one or two words each, at similar lengths. Items never wrap.
227
-
228
- **Do:** Use short, parallel labels that fit side by side.
229
-
230
- ```tsx
231
- /**
232
- * Do example for "Keep Options Few and Short" on the ChoiceGroup page.
233
- * Use short, parallel labels that fit side by side.
234
- * @module
235
- */
236
- import { ChoiceGroup } from '@tempoxyz/ds'
237
-
238
- /** Renders the static preview, which the guideline card shows inert. */
239
- export function Demo() {
240
- return (
241
- <ChoiceGroup.Root aria-label="Time range" defaultValue="24h">
242
- <ChoiceGroup.Item value="1h">1H</ChoiceGroup.Item>
243
- <ChoiceGroup.Item value="24h">24H</ChoiceGroup.Item>
244
- <ChoiceGroup.Item value="7d">7D</ChoiceGroup.Item>
245
- <ChoiceGroup.Item value="30d">30D</ChoiceGroup.Item>
246
- </ChoiceGroup.Root>
247
- )
248
- }
249
- ```
250
-
251
- **Don't:** Use phrases that overflow the control.
252
-
253
- ```tsx
254
- /**
255
- * Don't example for "Keep Options Few and Short" on the ChoiceGroup page.
256
- * Don't use phrases that overflow the control.
257
- * @module
258
- */
259
- import { ChoiceGroup } from '@tempoxyz/ds'
260
-
261
- /** Renders the static preview, which the guideline card shows inert. */
262
- export function Demo() {
263
- return (
264
- <ChoiceGroup.Root aria-label="Time range" defaultValue="24h">
265
- <ChoiceGroup.Item value="1h">Last hour</ChoiceGroup.Item>
266
- <ChoiceGroup.Item value="24h">Last 24 hours</ChoiceGroup.Item>
267
- <ChoiceGroup.Item value="7d">Last 7 days</ChoiceGroup.Item>
268
- <ChoiceGroup.Item value="30d">Last 30 days</ChoiceGroup.Item>
269
- </ChoiceGroup.Root>
270
- )
271
- }
272
- ```
273
-
274
- ### Always Keep One Option Selected
275
-
276
- The selection can't be cleared.
277
-
278
- **Do:** On first render, set `defaultValue`, or `value` with `onValueChange`, to the current mode.
279
-
280
- ```tsx
281
- /**
282
- * Do example for "Always Keep One Option Selected" on the ChoiceGroup page.
283
- * On first render, set `defaultValue`, or `value` with `onValueChange`, to the current mode.
284
- * @module
285
- */
286
- import { ChoiceGroup } from '@tempoxyz/ds'
287
-
288
- /** Renders the static preview, which the guideline card shows inert. */
289
- export function Demo() {
290
- return (
291
- <ChoiceGroup.Root aria-label="Amount" defaultValue="50">
292
- <ChoiceGroup.Item value="20">$20</ChoiceGroup.Item>
293
- <ChoiceGroup.Item value="50">$50</ChoiceGroup.Item>
294
- <ChoiceGroup.Item value="100">$100</ChoiceGroup.Item>
295
- </ChoiceGroup.Root>
296
- )
297
- }
298
- ```
299
-
300
- **Don't:** Render the group with no option selected.
301
-
302
- ```tsx
303
- /**
304
- * Don't example for "Always Keep One Option Selected" on the ChoiceGroup page.
305
- * Don't render the group with no option selected.
306
- * @module
307
- */
308
- import { ChoiceGroup } from '@tempoxyz/ds'
309
-
310
- /** Renders the static preview, which the guideline card shows inert. */
311
- export function Demo() {
312
- return (
313
- <ChoiceGroup.Root aria-label="Amount">
314
- <ChoiceGroup.Item value="20">$20</ChoiceGroup.Item>
315
- <ChoiceGroup.Item value="50">$50</ChoiceGroup.Item>
316
- <ChoiceGroup.Item value="100">$100</ChoiceGroup.Item>
317
- </ChoiceGroup.Root>
318
- )
319
- }
320
- ```
321
-
322
- ### Apply the Choice Immediately
323
-
324
- If the choice waits for a form submit, use [RadioGroup](radio-group.md).
325
-
326
- **Do:** Update the view when the selection changes, such as redrawing the chart for 7D.
327
-
328
- ```tsx
329
- /**
330
- * Do example for "Apply the Choice Immediately" on the ChoiceGroup page.
331
- * Update the view when the selection changes, such as redrawing the chart for 7D.
332
- * @module
333
- */
334
- import { ChoiceGroup } from '@tempoxyz/ds'
335
-
336
- /** Renders the static preview, which the guideline card shows inert. */
337
- export function Demo() {
338
- return (
339
- <ChoiceGroup.Root aria-label="Time range" defaultValue="24h" size="small">
340
- <ChoiceGroup.Item value="1h">1H</ChoiceGroup.Item>
341
- <ChoiceGroup.Item value="24h">24H</ChoiceGroup.Item>
342
- <ChoiceGroup.Item value="7d">7D</ChoiceGroup.Item>
343
- <ChoiceGroup.Item value="30d">30D</ChoiceGroup.Item>
344
- </ChoiceGroup.Root>
345
- )
346
- }
347
- ```
348
-
349
- **Don't:** Add an Apply button.
350
-
351
- ```tsx
352
- /** Don't example for "Apply the Choice Immediately" on the ChoiceGroup page. Don't add an Apply button. @module */
353
- import { Button, ChoiceGroup, style } from '@tempoxyz/ds'
354
-
355
- /** Renders the static preview, which the guideline card shows inert. */
356
- export function Demo() {
357
- return (
358
- <div {...styles.row()}>
359
- <ChoiceGroup.Root aria-label="Time range" defaultValue="24h" size="small">
360
- <ChoiceGroup.Item value="1h">1H</ChoiceGroup.Item>
361
- <ChoiceGroup.Item value="24h">24H</ChoiceGroup.Item>
362
- <ChoiceGroup.Item value="7d">7D</ChoiceGroup.Item>
363
- <ChoiceGroup.Item value="30d">30D</ChoiceGroup.Item>
364
- </ChoiceGroup.Root>
365
- <Button size="small" variant="secondary">
366
- Apply
367
- </Button>
368
- </div>
369
- )
370
- }
371
-
372
- namespace styles {
373
- export const row = style({ alignItems: 'center', display: 'flex', gap: '8' })
374
- }
375
- ```
376
-
377
- ### Choose a Variant by Option Count
378
-
379
- * **Few Short Options (default):** Two to four options in one track, marked by a sliding pill.
380
- * **Longer Filter Sets (chips):** A scrolling row of chips for options that outgrow the width, such as networks for a deposit.
381
-
382
- ### Match the Height of Nearby Controls
383
-
384
- `small`, `medium`, and `large` tracks are 32, 48, and 56px tall. A `medium` track fills its row and gives each item an equal width, as tall as [TextInput](text-input.md).
385
-
386
- **Do:** Use `small` in a dashboard toolbar beside a small [Select](select.md).
387
-
388
- ```tsx
389
- /**
390
- * Do example for "Match the Height of Nearby Controls" on the ChoiceGroup page.
391
- * Use `small` in a dashboard toolbar beside a small Select.
392
- * @module
393
- */
394
- import { ChoiceGroup, Select, style } from '@tempoxyz/ds'
395
-
396
- const items = { usdc: 'USDC', usdt: 'USDT' }
397
-
398
- /** Renders the static preview, which the guideline card shows inert. */
399
- export function Demo() {
400
- return (
401
- <div {...styles.toolbar()}>
402
- <ChoiceGroup.Root aria-label="Time range" defaultValue="24h" size="small">
403
- <ChoiceGroup.Item value="1h">1H</ChoiceGroup.Item>
404
- <ChoiceGroup.Item value="24h">24H</ChoiceGroup.Item>
405
- <ChoiceGroup.Item value="7d">7D</ChoiceGroup.Item>
406
- </ChoiceGroup.Root>
407
- <Select.Root aria-label="Asset" defaultValue="usdc" items={items}>
408
- <Select.Trigger {...styles.select()}>
409
- <Select.Value />
410
- <Select.Icon />
411
- </Select.Trigger>
412
- </Select.Root>
413
- </div>
414
- )
415
- }
416
-
417
- namespace styles {
418
- export const toolbar = style({ alignItems: 'center', display: 'flex', gap: '8' })
419
-
420
- export const select = style({ width: '7rem !custom' })
421
- }
422
- ```
423
-
424
- **Don't:** Mix sizes in one toolbar.
425
-
426
- ```tsx
427
- /**
428
- * Don't example for "Match the Height of Nearby Controls" on the ChoiceGroup page.
429
- * Don't mix sizes in one toolbar.
430
- * @module
431
- */
432
- import { ChoiceGroup, Select, style } from '@tempoxyz/ds'
433
-
434
- const items = { usdc: 'USDC', usdt: 'USDT' }
435
-
436
- /** Renders the static preview, which the guideline card shows inert. */
437
- export function Demo() {
438
- return (
439
- <div {...styles.toolbar()}>
440
- <ChoiceGroup.Root aria-label="Time range" defaultValue="24h" size="large">
441
- <ChoiceGroup.Item value="1h">1H</ChoiceGroup.Item>
442
- <ChoiceGroup.Item value="24h">24H</ChoiceGroup.Item>
443
- <ChoiceGroup.Item value="7d">7D</ChoiceGroup.Item>
444
- </ChoiceGroup.Root>
445
- <Select.Root aria-label="Asset" defaultValue="usdc" items={items}>
446
- <Select.Trigger {...styles.select()}>
447
- <Select.Value />
448
- <Select.Icon />
449
- </Select.Trigger>
450
- </Select.Root>
451
- </div>
452
- )
453
- }
454
-
455
- namespace styles {
456
- export const toolbar = style({ alignItems: 'center', display: 'flex', gap: '8' })
457
-
458
- export const select = style({ width: '7rem !custom' })
459
- }
460
- ```
461
-
462
- ## Content
463
-
464
- * Write labels as compact units, such as 1H and 7D, or as words. Use one style across all options, and don't mix 1 hour with 7D, or Ethereum with ETH.
465
- * Use numerals for numbers and amounts, such as $20 and 30D.
466
-
467
- ## Accessibility
468
-
469
- Follows the [WAI-ARIA radio group pattern](https://www.w3.org/WAI/ARIA/apg/patterns/radio/).
470
-
471
- ### Semantics
472
-
473
- * **ChoiceGroup.Root (radiogroup):** Groups the items as one set of choices.
474
- * **ChoiceGroup.Item (radio):** Named by its text. A hidden native radio beside it submits the value.
475
- * **Decoration (aria-hidden):** The sliding pill and item icons are hidden from screen readers.
476
- * **Selected (aria-checked):** The selected item sits on a pill or tinted chip, and its text darkens.
477
- * **Disabled Item (disabled):** Makes the option unavailable and dims it to 32% opacity.
478
- * **Target Size (28 to 48px):** Small items sit close to the WCAG 2.2 minimum. Avoid them for primary controls.
479
-
480
- ### Keyboard
481
-
482
- * **Move into the Group (Tab):** Moves focus onto the checked item. The group is one tab stop.
483
- * **Move out of the Group (Shift+Tab):** Moves focus out of the group.
484
- * **Select the Next Item (Right Arrow or Down Arrow):** Moves focus to the next item and selects it, wrapping at the end.
485
- * **Select the Previous Item (Left Arrow or Up Arrow):** Moves focus to the previous item and selects it, wrapping at the start.
486
-
487
- ### Motion
488
-
489
- Under `prefers-reduced-motion: reduce`, the pill moves without sliding and items don't scale when pressed.
490
-
491
- ### Your Responsibilities
492
-
493
- * **Name the Group (aria-labelledby):** Use a `Field.Label` in a `Field.Root`, `aria-label`, or a visible question such as "Amount".
494
- * **Give Every Item Text:** Item icons are hidden, so an icon-only item has no accessible name.
495
-
496
- ## Related
497
-
498
- [RadioGroup](radio-group.md)
499
-
500
- Use for one choice in a form.
501
-
502
- [Tabs](tabs.md)
503
-
504
- Use for switching between panels.
505
-
506
- [Select](select.md)
507
-
508
- Use for longer lists.
509
-
510
- [Choicebox](choicebox.md)
511
-
512
- Use for options with descriptions.
513
-
514
- [Dashboards](../patterns/dashboards.md)
515
-
516
- Covers filters above charts.