@tempoxyz/ds 0.3.14 → 0.3.16

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 (209) hide show
  1. package/dist/docs/AGENTS.md +75 -10
  2. package/dist/docs/arsenal.md +44 -0
  3. package/dist/docs/{marketing/introduction/getting-started.md → marketing.md} +32 -24
  4. package/dist/docs/product/components/actions.md +2110 -0
  5. package/dist/docs/product/components/blockchain.md +3969 -0
  6. package/dist/docs/product/components/data-display.md +5901 -0
  7. package/dist/docs/product/components/feedback-and-status.md +4138 -0
  8. package/dist/docs/product/components/forms-and-inputs.md +10543 -0
  9. package/dist/docs/product/components/layout.md +3339 -0
  10. package/dist/docs/product/components/navigation.md +2914 -0
  11. package/dist/docs/product/components/overlays.md +4917 -0
  12. package/dist/docs/product/components.md +125 -125
  13. package/dist/docs/product/foundations.md +4597 -0
  14. package/dist/docs/product/patterns.md +10110 -0
  15. package/dist/marketing/index.js.zyzz.json +1 -1
  16. package/dist/marketing/vars.d.ts +618 -758
  17. package/dist/marketing/vars.d.ts.map +1 -1
  18. package/dist/marketing/vars.js +8 -5
  19. package/dist/marketing/vars.js.map +1 -1
  20. package/dist/marketing/vars.js.zyzz.json +1 -1
  21. package/dist/marketing/zyzz.config.d.ts +3042 -3757
  22. package/dist/marketing/zyzz.config.d.ts.map +1 -1
  23. package/dist/marketing/zyzz.config.js +1 -1
  24. package/dist/marketing/zyzz.config.js.map +1 -1
  25. package/dist/marketing/zyzz.config.js.zyzz.json +1 -1
  26. package/dist/mobile/components/Button.d.ts +115 -15
  27. package/dist/mobile/components/Button.d.ts.map +1 -1
  28. package/dist/mobile/components/Button.js +85 -14
  29. package/dist/mobile/components/Button.js.map +1 -1
  30. package/dist/mobile/components/IconButton.d.ts +129 -40
  31. package/dist/mobile/components/IconButton.d.ts.map +1 -1
  32. package/dist/mobile/components/IconButton.js +97 -28
  33. package/dist/mobile/components/IconButton.js.map +1 -1
  34. package/dist/mobile/components/TextInput.d.ts +132 -11
  35. package/dist/mobile/components/TextInput.d.ts.map +1 -1
  36. package/dist/mobile/components/TextInput.js +115 -14
  37. package/dist/mobile/components/TextInput.js.map +1 -1
  38. package/dist/mobile/index.d.ts +1 -0
  39. package/dist/mobile/index.d.ts.map +1 -1
  40. package/dist/mobile/index.js +1 -0
  41. package/dist/mobile/index.js.map +1 -1
  42. package/dist/mobile/vars.d.ts +103 -0
  43. package/dist/mobile/vars.d.ts.map +1 -1
  44. package/dist/mobile/vars.js +74 -0
  45. package/dist/mobile/vars.js.map +1 -1
  46. package/dist/mobile/zyzz.config.d.ts +408 -0
  47. package/dist/mobile/zyzz.config.d.ts.map +1 -1
  48. package/dist/web/components/AddressCard.js.zyzz.json +1 -1
  49. package/dist/web/components/Amount.css +1 -1
  50. package/dist/web/components/Amount.d.ts +9 -0
  51. package/dist/web/components/Amount.d.ts.map +1 -1
  52. package/dist/web/components/Amount.js +8 -5
  53. package/dist/web/components/Amount.js.map +1 -1
  54. package/dist/web/components/Amount.js.zyzz.json +1 -1
  55. package/dist/web/components/CopyButton.d.ts +6 -0
  56. package/dist/web/components/CopyButton.d.ts.map +1 -1
  57. package/dist/web/components/CopyButton.js +4 -1
  58. package/dist/web/components/CopyButton.js.map +1 -1
  59. package/dist/web/components/CopyButton.js.zyzz.json +1 -1
  60. package/dist/web/components/Hex.css +1 -1
  61. package/dist/web/components/Hex.d.ts +84 -3
  62. package/dist/web/components/Hex.d.ts.map +1 -1
  63. package/dist/web/components/Hex.js +20 -13
  64. package/dist/web/components/Hex.js.map +1 -1
  65. package/dist/web/components/Hex.js.zyzz.json +1 -1
  66. package/dist/web/components/Progress.css +1 -1
  67. package/dist/web/components/Progress.d.ts +12 -2
  68. package/dist/web/components/Progress.d.ts.map +1 -1
  69. package/dist/web/components/Progress.js +9 -5
  70. package/dist/web/components/Progress.js.map +1 -1
  71. package/dist/web/components/Progress.js.zyzz.json +1 -1
  72. package/dist/web/components/SecretValue.js.zyzz.json +1 -1
  73. package/dist/web/components/SidebarMenu.d.ts +4 -4
  74. package/dist/web/components/SidebarMenu.js +6 -6
  75. package/dist/web/components/SidebarMenu.js.map +1 -1
  76. package/dist/web/components/Snippet.js.zyzz.json +1 -1
  77. package/dist/web/index.js.zyzz.json +1 -1
  78. package/package.json +1 -1
  79. package/src/marketing/README.md +1 -1
  80. package/src/marketing/vars.ts +526 -604
  81. package/src/marketing/zyzz.config.ts +5 -4
  82. package/src/mobile/README.md +19 -6
  83. package/src/mobile/components/Button.tsx +94 -17
  84. package/src/mobile/components/IconButton.tsx +122 -30
  85. package/src/mobile/components/TextInput.tsx +139 -24
  86. package/src/mobile/index.ts +1 -0
  87. package/src/mobile/vars.ts +74 -0
  88. package/src/web/components/Amount.tsx +37 -3
  89. package/src/web/components/CopyButton.tsx +8 -0
  90. package/src/web/components/Hex.tsx +79 -13
  91. package/src/web/components/Progress.tsx +8 -2
  92. package/src/web/components/SidebarMenu.tsx +6 -6
  93. package/dist/docs/index.md +0 -145
  94. package/dist/docs/product/components/accordion.md +0 -489
  95. package/dist/docs/product/components/address-card.md +0 -147
  96. package/dist/docs/product/components/agent-logo.md +0 -194
  97. package/dist/docs/product/components/alert-dialog.md +0 -631
  98. package/dist/docs/product/components/alert.md +0 -448
  99. package/dist/docs/product/components/amount-input.md +0 -305
  100. package/dist/docs/product/components/amount.md +0 -794
  101. package/dist/docs/product/components/app-shell.md +0 -559
  102. package/dist/docs/product/components/asset-chip.md +0 -294
  103. package/dist/docs/product/components/autocomplete.md +0 -620
  104. package/dist/docs/product/components/avatar.md +0 -321
  105. package/dist/docs/product/components/badge.md +0 -339
  106. package/dist/docs/product/components/badged-logo.md +0 -116
  107. package/dist/docs/product/components/banner.md +0 -379
  108. package/dist/docs/product/components/bar-chart.md +0 -208
  109. package/dist/docs/product/components/breadcrumbs.md +0 -380
  110. package/dist/docs/product/components/button-group.md +0 -286
  111. package/dist/docs/product/components/button.md +0 -650
  112. package/dist/docs/product/components/calendar.md +0 -375
  113. package/dist/docs/product/components/callout.md +0 -96
  114. package/dist/docs/product/components/checkbox-group.md +0 -521
  115. package/dist/docs/product/components/checkbox.md +0 -467
  116. package/dist/docs/product/components/choice-group.md +0 -516
  117. package/dist/docs/product/components/choicebox.md +0 -641
  118. package/dist/docs/product/components/code.md +0 -100
  119. package/dist/docs/product/components/combobox.md +0 -939
  120. package/dist/docs/product/components/container.md +0 -257
  121. package/dist/docs/product/components/copy-button.md +0 -642
  122. package/dist/docs/product/components/date-picker.md +0 -514
  123. package/dist/docs/product/components/dialog.md +0 -1332
  124. package/dist/docs/product/components/drawer.md +0 -966
  125. package/dist/docs/product/components/empty.md +0 -340
  126. package/dist/docs/product/components/field.md +0 -570
  127. package/dist/docs/product/components/fieldset.md +0 -398
  128. package/dist/docs/product/components/frame.md +0 -434
  129. package/dist/docs/product/components/gauge.md +0 -299
  130. package/dist/docs/product/components/get-started-visual.md +0 -117
  131. package/dist/docs/product/components/grid.md +0 -288
  132. package/dist/docs/product/components/hero-visual.md +0 -155
  133. package/dist/docs/product/components/hex.md +0 -487
  134. package/dist/docs/product/components/icon-tile.md +0 -292
  135. package/dist/docs/product/components/identicon.md +0 -371
  136. package/dist/docs/product/components/inline.md +0 -233
  137. package/dist/docs/product/components/inset.md +0 -225
  138. package/dist/docs/product/components/kbd.md +0 -423
  139. package/dist/docs/product/components/list-group.md +0 -981
  140. package/dist/docs/product/components/loading-dots.md +0 -237
  141. package/dist/docs/product/components/menu.md +0 -934
  142. package/dist/docs/product/components/native-select.md +0 -204
  143. package/dist/docs/product/components/network-logo.md +0 -248
  144. package/dist/docs/product/components/number-field.md +0 -543
  145. package/dist/docs/product/components/otp-field.md +0 -616
  146. package/dist/docs/product/components/pagination.md +0 -516
  147. package/dist/docs/product/components/popover.md +0 -544
  148. package/dist/docs/product/components/progress.md +0 -388
  149. package/dist/docs/product/components/qr.md +0 -314
  150. package/dist/docs/product/components/radio-group.md +0 -528
  151. package/dist/docs/product/components/secret-value.md +0 -406
  152. package/dist/docs/product/components/select.md +0 -751
  153. package/dist/docs/product/components/separator.md +0 -379
  154. package/dist/docs/product/components/sidebar-menu.md +0 -922
  155. package/dist/docs/product/components/skeleton.md +0 -517
  156. package/dist/docs/product/components/slider.md +0 -539
  157. package/dist/docs/product/components/snippet.md +0 -424
  158. package/dist/docs/product/components/spinner.md +0 -216
  159. package/dist/docs/product/components/split-bar.md +0 -139
  160. package/dist/docs/product/components/split-button.md +0 -464
  161. package/dist/docs/product/components/stack.md +0 -299
  162. package/dist/docs/product/components/status-chip.md +0 -226
  163. package/dist/docs/product/components/status-indicator.md +0 -119
  164. package/dist/docs/product/components/status-row.md +0 -174
  165. package/dist/docs/product/components/stepper.md +0 -451
  166. package/dist/docs/product/components/success-hero.md +0 -157
  167. package/dist/docs/product/components/surface.md +0 -639
  168. package/dist/docs/product/components/switch.md +0 -472
  169. package/dist/docs/product/components/table.md +0 -968
  170. package/dist/docs/product/components/tabs.md +0 -627
  171. package/dist/docs/product/components/tempo-logo.md +0 -185
  172. package/dist/docs/product/components/text-input.md +0 -624
  173. package/dist/docs/product/components/textarea.md +0 -352
  174. package/dist/docs/product/components/toast.md +0 -535
  175. package/dist/docs/product/components/token-logo.md +0 -371
  176. package/dist/docs/product/components/token.md +0 -247
  177. package/dist/docs/product/components/tooltip.md +0 -490
  178. package/dist/docs/product/components/verification-code.md +0 -116
  179. package/dist/docs/product/components/visual.md +0 -249
  180. package/dist/docs/product/foundations/accessibility.md +0 -377
  181. package/dist/docs/product/foundations/agents.md +0 -159
  182. package/dist/docs/product/foundations/color.md +0 -522
  183. package/dist/docs/product/foundations/content/tone.md +0 -194
  184. package/dist/docs/product/foundations/content/voice.md +0 -194
  185. package/dist/docs/product/foundations/content/writing-style.md +0 -406
  186. package/dist/docs/product/foundations/iconography.md +0 -282
  187. package/dist/docs/product/foundations/intent.md +0 -360
  188. package/dist/docs/product/foundations/layout.md +0 -508
  189. package/dist/docs/product/foundations/linter.md +0 -523
  190. package/dist/docs/product/foundations/motion.md +0 -151
  191. package/dist/docs/product/foundations/radius-and-padding.md +0 -86
  192. package/dist/docs/product/foundations/typography.md +0 -331
  193. package/dist/docs/product/introduction/faq.md +0 -133
  194. package/dist/docs/product/introduction/getting-started.md +0 -377
  195. package/dist/docs/product/patterns/blockchain-values.md +0 -709
  196. package/dist/docs/product/patterns/dashboards.md +0 -638
  197. package/dist/docs/product/patterns/destructive-actions.md +0 -626
  198. package/dist/docs/product/patterns/empty-states.md +0 -612
  199. package/dist/docs/product/patterns/errors-and-validation.md +0 -808
  200. package/dist/docs/product/patterns/feedback-and-status.md +0 -518
  201. package/dist/docs/product/patterns/forms.md +0 -679
  202. package/dist/docs/product/patterns/loading.md +0 -630
  203. package/dist/docs/product/patterns/navigation.md +0 -397
  204. package/dist/docs/product/patterns/payments.md +0 -765
  205. package/dist/docs/product/patterns/responsive-layout.md +0 -997
  206. package/dist/docs/product/patterns/tables-and-lists.md +0 -1170
  207. package/dist/docs/product/products/tempo-console.md +0 -671
  208. package/dist/docs/product/products/tempo-performance.md +0 -435
  209. package/dist/docs/product/products/tempo-wallet.md +0 -438
@@ -0,0 +1,2110 @@
1
+ # Actions
2
+
3
+ Each component section states its guidance first, then its Examples and Use Cases. Read a section up to its Examples heading before you use the component, then read the examples it needs.
4
+
5
+ ## Contents
6
+
7
+ Controls that start an action or copy a value.
8
+
9
+ - [Button](#button): Triggers an action, such as submitting a form or sending a payment.
10
+ - [ButtonGroup](#buttongroup): Lays out the actions at the foot of a dialog or focused flow.
11
+ - [CopyButton](#copybutton): Copies a value to the clipboard and confirms the copy.
12
+ - [SplitButton](#splitbutton): Pairs a primary action with a menu of alternatives.
13
+
14
+ ## Button
15
+
16
+ Triggers an action, such as submitting a form or sending a payment.
17
+
18
+ [View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Button.tsx)
19
+
20
+ Figma: [Button](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=1186-3148), [Icon Button](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=1186-3395), [Text Button](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5601-90)
21
+
22
+ ### Overview
23
+
24
+ A native `<button>` for actions. `Button.Link` renders the same styles for navigation.
25
+
26
+ ### Anatomy
27
+
28
+ Import the component and assemble its parts.
29
+
30
+ ```tsx
31
+ import { Button } from '@tempoxyz/ds'
32
+
33
+ <Button />
34
+ <Button.Link />
35
+ ```
36
+
37
+ ### Guidelines
38
+
39
+ #### When to Use
40
+
41
+ * Start an action in the current view, such as Send payment, Save changes, or Open settings.
42
+ * Submit a form. Set `type="submit"` on the form's main button.
43
+ * Use `Button.Link` when navigation needs a button's weight, such as Create account in an empty state.
44
+
45
+ #### When Not to Use
46
+
47
+ * Use a text link for navigation inside sentences, lists, and tables.
48
+ * Use [CopyButton](#copybutton) to copy a value, and [SplitButton](#splitbutton) for a main action with related alternatives.
49
+ * Use [Tabs](navigation.md#tabs) or [ChoiceGroup](forms-and-inputs.md#choicegroup) to switch views, and [Switch](forms-and-inputs.md#switch) to turn a setting on or off.
50
+ * If a section has more than three secondary actions, put them in a [Menu](overlays.md#menu) behind an icon button.
51
+
52
+ #### Choose a Variant by Emphasis
53
+
54
+ * **Main Action (primary):** The main action of a view, dialog, or section, such as Send payment. Use one per section.
55
+ * **Supporting Actions (secondary):** Supporting actions beside a primary action, or actions of equal weight.
56
+ * **Low-Emphasis Actions (tertiary):** Dense areas, such as toolbars, table rows, and inline Cancel actions.
57
+
58
+ A destructive action takes the variant of its place in the flow, and its label names the outcome, such as Revoke key. Confirm it with an [AlertDialog](overlays.md#alertdialog), whose confirming button takes `danger`. See [Destructive Actions](../patterns.md#destructive-actions) and [Payments](../patterns.md#payments).
59
+
60
+ #### Use One Primary Action
61
+
62
+ Give other actions `secondary` or `tertiary`, even if they matter. [Forms](../patterns.md#submitting) sets the order of the actions.
63
+
64
+ **Do:** Pair one `primary` action with `secondary` alternatives.
65
+
66
+ ```tsx
67
+ /**
68
+ * Do example for "Use One Primary Action" on the Button page.
69
+ * Pair one `primary` action with `secondary` alternatives.
70
+ * @module
71
+ */
72
+ import { Button, style } from '@tempoxyz/ds'
73
+
74
+ /** Renders the static preview, which the guideline card shows inert. */
75
+ export function Demo() {
76
+ return (
77
+ <div {...styles.row()}>
78
+ <Button variant="secondary">Cancel</Button>
79
+ <Button>Send payment</Button>
80
+ </div>
81
+ )
82
+ }
83
+
84
+ namespace styles {
85
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
86
+ }
87
+ ```
88
+
89
+ **Don't:** Give several actions in one section the `primary` variant.
90
+
91
+ ```tsx
92
+ /**
93
+ * Don't example for "Use One Primary Action" on the Button page.
94
+ * Don't give several actions in one section the `primary` variant.
95
+ * @module
96
+ */
97
+ import { Button, style } from '@tempoxyz/ds'
98
+
99
+ /** Renders the static preview, which the guideline card shows inert. */
100
+ export function Demo() {
101
+ return (
102
+ <div {...styles.row()}>
103
+ <Button>Send</Button>
104
+ <Button>Deposit</Button>
105
+ <Button>Swap</Button>
106
+ </div>
107
+ )
108
+ }
109
+
110
+ namespace styles {
111
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
112
+ }
113
+ ```
114
+
115
+ #### Match Size to Context
116
+
117
+ * **Row Actions (xsmall):** A pill for an action inside a row or field, such as Copy or Edit. Never the main action.
118
+ * **Dense Layouts (small):** Tables, toolbars, cards, and icon buttons inside fields and rows, such as Export in a toolbar.
119
+ * **Default (medium):** Forms, page actions, and actions inside a dialog body, such as Copy address.
120
+ * **Dialog Footers (large):** Every action in a dialog footer, and the final step of a focused flow, such as Confirm send.
121
+
122
+ Lay out the actions in a dialog footer with a [ButtonGroup](#buttongroup).
123
+
124
+ #### Show Progress With Loading
125
+
126
+ **Do:** Set `loading` on the button that started the action.
127
+
128
+ ```tsx
129
+ /**
130
+ * Do example for "Show Progress With Loading" on the Button page.
131
+ * Set `loading` on the button that started the action.
132
+ * @module
133
+ */
134
+ import { Button } from '@tempoxyz/ds'
135
+
136
+ /** Renders the static preview, which the guideline card shows inert. */
137
+ export function Demo() {
138
+ return <Button loading>Send payment</Button>
139
+ }
140
+ ```
141
+
142
+ **Don't:** Disable the button and place a separate [Spinner](feedback-and-status.md#spinner) beside it.
143
+
144
+ ```tsx
145
+ /**
146
+ * Don't example for "Show Progress With Loading" on the Button page.
147
+ * Don't disable the button and place a separate Spinner beside it.
148
+ * @module
149
+ */
150
+ import { Button, Spinner, style } from '@tempoxyz/ds'
151
+
152
+ /** Renders the static preview, which the guideline card shows inert. */
153
+ export function Demo() {
154
+ return (
155
+ <div {...styles.row()}>
156
+ <Button disabled>Send payment</Button>
157
+ <Spinner aria-label="Loading" />
158
+ </div>
159
+ )
160
+ }
161
+
162
+ namespace styles {
163
+ export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
164
+ }
165
+ ```
166
+
167
+ #### Avoid Disabled Buttons
168
+
169
+ Keep a button enabled when you can, and show validation errors after a press. If a button must stay disabled:
170
+
171
+ * Explain why in nearby text.
172
+ * Set `focusableWhenDisabled` so keyboard users can reach it.
173
+ * Don't rely on a [Tooltip](overlays.md#tooltip). Many readers can't open it on a disabled button.
174
+
175
+ **Do:** Explain in nearby text why the button is unavailable.
176
+
177
+ ```tsx
178
+ /**
179
+ * Do example for "Avoid Disabled Buttons" on the Button page.
180
+ * Explain in nearby text why the button is unavailable.
181
+ * @module
182
+ */
183
+ import { Button, style } from '@tempoxyz/ds'
184
+
185
+ /** Renders the static preview, which the guideline card shows inert. */
186
+ export function Demo() {
187
+ return (
188
+ <div {...styles.stack()}>
189
+ <Button disabled focusableWhenDisabled>
190
+ Send payment
191
+ </Button>
192
+ <p {...styles.hint()}>Add a recipient address to send.</p>
193
+ </div>
194
+ )
195
+ }
196
+
197
+ namespace styles {
198
+ export const hint = style({
199
+ color: 'content.secondary',
200
+ margin: '0 !custom',
201
+ typography: 'body.b3',
202
+ })
203
+
204
+ export const stack = style({
205
+ alignItems: 'flex-start',
206
+ display: 'flex',
207
+ flexDirection: 'column',
208
+ rowGap: '8',
209
+ })
210
+ }
211
+ ```
212
+
213
+ **Don't:** Disable a button without saying what is missing.
214
+
215
+ ```tsx
216
+ /**
217
+ * Don't example for "Avoid Disabled Buttons" on the Button page.
218
+ * Don't disable a button without saying what is missing.
219
+ * @module
220
+ */
221
+ import { Button, style } from '@tempoxyz/ds'
222
+
223
+ /** Renders the static preview, which the guideline card shows inert. */
224
+ export function Demo() {
225
+ return (
226
+ <div {...styles.stack()}>
227
+ <Button disabled>Send payment</Button>
228
+ </div>
229
+ )
230
+ }
231
+
232
+ namespace styles {
233
+ export const stack = style({
234
+ alignItems: 'flex-start',
235
+ display: 'flex',
236
+ flexDirection: 'column',
237
+ rowGap: '8',
238
+ })
239
+ }
240
+ ```
241
+
242
+ #### Use Icons to Reinforce the Label
243
+
244
+ Place an icon before the label if it aids recognition, such as a plus for Add. An icon-only button (`shape="icon"`) needs a [Tooltip](overlays.md#tooltip) with its `aria-label` text. Use it only for familiar actions, such as Close or Copy.
245
+
246
+ **Do:** Add an icon only where it aids recognition.
247
+
248
+ ```tsx
249
+ /**
250
+ * Do example for "Use Icons to Reinforce the Label" on the Button page.
251
+ * Add an icon only where it aids recognition.
252
+ * @module
253
+ */
254
+ import { Button, style } from '@tempoxyz/ds'
255
+ import { Plus } from '@tempoxyz/ds/icons'
256
+
257
+ /** Renders the static preview, which the guideline card shows inert. */
258
+ export function Demo() {
259
+ return (
260
+ <div {...styles.row()}>
261
+ <Button size="small" variant="secondary">
262
+ Export
263
+ </Button>
264
+ <Button size="small" variant="secondary">
265
+ Rotate key
266
+ </Button>
267
+ <Button size="small">
268
+ <Plus />
269
+ Add key
270
+ </Button>
271
+ </div>
272
+ )
273
+ }
274
+
275
+ namespace styles {
276
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '8' })
277
+ }
278
+ ```
279
+
280
+ **Don't:** Add icons to every button in a group.
281
+
282
+ ```tsx
283
+ /**
284
+ * Don't example for "Use Icons to Reinforce the Label" on the Button page.
285
+ * Don't add icons to every button in a group.
286
+ * @module
287
+ */
288
+ import { Button, style } from '@tempoxyz/ds'
289
+ import { Export, Plus, Refresh } from '@tempoxyz/ds/icons'
290
+
291
+ /** Renders the static preview, which the guideline card shows inert. */
292
+ export function Demo() {
293
+ return (
294
+ <div {...styles.row()}>
295
+ <Button size="small" variant="secondary">
296
+ <Export />
297
+ Export
298
+ </Button>
299
+ <Button size="small" variant="secondary">
300
+ <Refresh />
301
+ Rotate key
302
+ </Button>
303
+ <Button size="small">
304
+ <Plus />
305
+ Add key
306
+ </Button>
307
+ </div>
308
+ )
309
+ }
310
+
311
+ namespace styles {
312
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '8' })
313
+ }
314
+ ```
315
+
316
+ ### Content
317
+
318
+ #### Start With a Verb
319
+
320
+ Name the action and its object, such as Send payment or Create key.
321
+
322
+ **Do:** Repeat the action on each button, such as Revoke key and Keep key.
323
+
324
+ ```tsx
325
+ /**
326
+ * Do example for "Start With a Verb" on the Button page.
327
+ * Repeat the action on each button, such as Revoke key and Keep key.
328
+ * @module
329
+ */
330
+ import { Button, style } from '@tempoxyz/ds'
331
+
332
+ /** Renders the static preview, which the guideline card shows inert. */
333
+ export function Demo() {
334
+ return (
335
+ <div {...styles.row()}>
336
+ <Button variant="secondary">Keep key</Button>
337
+ <Button>Revoke key</Button>
338
+ </div>
339
+ )
340
+ }
341
+
342
+ namespace styles {
343
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
344
+ }
345
+ ```
346
+
347
+ **Don't:** Use generic labels such as Yes, No, OK, or Submit.
348
+
349
+ ```tsx
350
+ /**
351
+ * Don't example for "Start With a Verb" on the Button page.
352
+ * Don't use generic labels such as Yes, No, OK, or Submit.
353
+ * @module
354
+ */
355
+ import { Button, style } from '@tempoxyz/ds'
356
+
357
+ /** Renders the static preview, which the guideline card shows inert. */
358
+ export function Demo() {
359
+ return (
360
+ <div {...styles.row()}>
361
+ <Button variant="secondary">No</Button>
362
+ <Button>Yes</Button>
363
+ </div>
364
+ )
365
+ }
366
+
367
+ namespace styles {
368
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
369
+ }
370
+ ```
371
+
372
+ #### Describe the Outcome, Not the Control
373
+
374
+ Write Continue to review, not Click here. Screen readers list buttons out of context, so each label must make sense alone.
375
+
376
+ ### Accessibility
377
+
378
+ `Button` renders a native `<button type="button">`, and `Button.Link` a native `<a>`. Both follow the [WAI-ARIA button pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/). See [Accessibility](../foundations.md#accessibility) for the baseline.
379
+
380
+ #### Semantics
381
+
382
+ * **Button (button):** Enter and Space activate it. Name an icon-only button with `aria-label`.
383
+ * **Button.Link (link):** Announced as a link and listed among the page's links. A modifier click opens a new tab.
384
+ * **Disabled:** Removes the button from the tab order, so keyboards skip it. Explain the reason in nearby text.
385
+ * **Focusable When Disabled (aria-disabled):** Keeps a disabled button in the tab order. It ignores every key except Tab.
386
+ * **Loading (aria-busy):** Disables the button and labels its spinner "Loading" for screen readers.
387
+ * **Icons (aria-hidden):** Hidden from assistive technology, so the button's text or label names it.
388
+
389
+ #### Keyboard
390
+
391
+ * **Move to the Button (Tab):** Focuses the button, skipping disabled ones.
392
+ * **Activate the Button (Enter or Space):** Activates the button.
393
+ * **Follow a Link (Enter):** Follows a `Button.Link`.
394
+
395
+ #### Your Responsibilities
396
+
397
+ * **Name Icon-Only Buttons (aria-label):** An icon-only button has no visible text. Name the action, such as "Copy address", not "Copy icon".
398
+ * **Announce Loading Results:** Loading announces only the busy state. Announce the outcome with a [Toast](feedback-and-status.md#toast) or an [Alert](feedback-and-status.md#alert).
399
+ * **Use Links for Navigation (Button.Link):** Use it for navigation, not a button with a click handler that changes the page.
400
+
401
+ ### Related
402
+
403
+ [ButtonGroup](#buttongroup)
404
+
405
+ Use for the actions at the foot of a dialog.
406
+
407
+ [SplitButton](#splitbutton)
408
+
409
+ Use for a main action with alternatives.
410
+
411
+ [CopyButton](#copybutton)
412
+
413
+ Use for copying a value.
414
+
415
+ [AlertDialog](overlays.md#alertdialog)
416
+
417
+ Use for confirming an action.
418
+
419
+ [Forms](../patterns.md#forms)
420
+
421
+ Covers placing submit and cancel actions.
422
+
423
+ [Destructive Actions](../patterns.md#destructive-actions)
424
+
425
+ Covers deleting and revoking.
426
+
427
+ ### Examples
428
+
429
+ #### Basic
430
+
431
+ ```tsx
432
+ import { Button } from '@tempoxyz/ds'
433
+
434
+ export function Demo() {
435
+ return <Button>Continue</Button>
436
+ }
437
+ ```
438
+
439
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Button/Basic.tsx)
440
+
441
+ #### Variant
442
+
443
+ Set `variant` to `primary` (default), `secondary`, `tertiary`, `danger`, or `text`. A `tertiary` button has no fill until hover.
444
+
445
+ ```tsx
446
+ import { Button, style } from '@tempoxyz/ds'
447
+
448
+ export function Demo() {
449
+ return (
450
+ <div {...styles.row()}>
451
+ {(['primary', 'secondary', 'tertiary', 'danger'] as const).map((variant) => (
452
+ <Button key={variant} variant={variant}>
453
+ Continue
454
+ </Button>
455
+ ))}
456
+ </div>
457
+ )
458
+ }
459
+
460
+ namespace styles {
461
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
462
+ }
463
+ ```
464
+
465
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Button/Variant.tsx)
466
+
467
+ #### Text
468
+
469
+ Set `variant="text"` for a low-emphasis action in running content, such as See more. It renders the secondary label and a trailing 12px icon without a fill or padding, and ignores `size`.
470
+
471
+ ```tsx
472
+ import { Button } from '@tempoxyz/ds'
473
+ import { ChevronRight } from '@tempoxyz/ds/icons'
474
+
475
+ export function Demo() {
476
+ return (
477
+ <Button variant="text">
478
+ See more
479
+ <ChevronRight />
480
+ </Button>
481
+ )
482
+ }
483
+ ```
484
+
485
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Button/Text.tsx)
486
+
487
+ #### Inverse
488
+
489
+ Set `appearance="inverse"` on an inverse surface, such as a dark banner on a light page. The surface turns light in dark mode, and the button colors flip with it.
490
+
491
+ ```tsx
492
+ /** Demonstrates the inverse appearance of each Button variant on an inverse surface. @module */
493
+ import { Button, style } from '@tempoxyz/ds'
494
+
495
+ export function Demo() {
496
+ return (
497
+ <div {...styles.surface()}>
498
+ {(['primary', 'secondary', 'tertiary'] as const).map((variant) => (
499
+ <Button appearance="inverse" key={variant} variant={variant}>
500
+ Continue
501
+ </Button>
502
+ ))}
503
+ </div>
504
+ )
505
+ }
506
+
507
+ namespace styles {
508
+ export const surface = style({
509
+ alignItems: 'center',
510
+ backgroundColor: 'inverse.background.primary',
511
+ borderRadius: 'sm',
512
+ display: 'flex',
513
+ flexWrap: 'wrap',
514
+ gap: '12',
515
+ padding: '16',
516
+ })
517
+ }
518
+ ```
519
+
520
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Button/Inverse.tsx)
521
+
522
+ #### Overlay
523
+
524
+ Set `appearance="overlay"` over an image or video. The `secondary` fill is a translucent gray, and the `secondary` and `tertiary` labels stay white in both color schemes.
525
+
526
+ ```tsx
527
+ /** Demonstrates the overlay appearance of each Button variant over an image. @module */
528
+ import { Button, style } from '@tempoxyz/ds'
529
+
530
+ export function Demo() {
531
+ return (
532
+ <div {...styles.image()}>
533
+ {(['primary', 'secondary', 'tertiary'] as const).map((variant) => (
534
+ <Button appearance="overlay" key={variant} variant={variant}>
535
+ Continue
536
+ </Button>
537
+ ))}
538
+ </div>
539
+ )
540
+ }
541
+
542
+ namespace styles {
543
+ // A mid-tone gradient stands in for a photo, so the labels stay legible in both color schemes.
544
+ export const image = style({
545
+ alignItems: 'center',
546
+ backgroundImage: 'linear-gradient(135deg, #6b7f99, #a3866a) !custom',
547
+ borderRadius: 'sm',
548
+ display: 'flex',
549
+ flexWrap: 'wrap',
550
+ gap: '12',
551
+ padding: '16',
552
+ })
553
+ }
554
+ ```
555
+
556
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Button/Overlay.tsx)
557
+
558
+ #### Size
559
+
560
+ Set `size` to `xsmall`, `small`, `medium` (default), or `large`. Heights step from 24px to 48px. `large` and `medium` take the `sm` corner radius, `small` takes `xs`, and `xsmall` renders a pill.
561
+
562
+ ```tsx
563
+ import { Button, style } from '@tempoxyz/ds'
564
+
565
+ export function Demo() {
566
+ return (
567
+ <div {...styles.row()}>
568
+ {(['xsmall', 'small', 'medium', 'large'] as const).map((size) => (
569
+ <Button key={size} size={size}>
570
+ Continue
571
+ </Button>
572
+ ))}
573
+ </div>
574
+ )
575
+ }
576
+
577
+ namespace styles {
578
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
579
+ }
580
+ ```
581
+
582
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Button/Size.tsx)
583
+
584
+ #### Shape
585
+
586
+ Set `shape="icon"` for a round button that holds only an icon. The icon renders at 16px, and at 20px on a large button. Give the button an `aria-label`.
587
+
588
+ ```tsx
589
+ import { Button, style } from '@tempoxyz/ds'
590
+ import { Plus as Add } from '@tempoxyz/ds/icons'
591
+
592
+ export function Demo() {
593
+ return (
594
+ <div {...styles.row()}>
595
+ <Button>
596
+ <Add />
597
+ Add funds
598
+ </Button>
599
+ {(['primary', 'secondary', 'tertiary'] as const).map((variant) => (
600
+ <Button aria-label="Add" key={variant} shape="icon" variant={variant}>
601
+ <Add />
602
+ </Button>
603
+ ))}
604
+ </div>
605
+ )
606
+ }
607
+
608
+ namespace styles {
609
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
610
+ }
611
+ ```
612
+
613
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Button/Shape.tsx)
614
+
615
+ #### Loading
616
+
617
+ Set `loading` to disable the button and mark it busy. The label stays visible, with a spinner centered in the leading space before it. An icon-only button shows only the centered spinner.
618
+
619
+ ```tsx
620
+ import { Button, style } from '@tempoxyz/ds'
621
+
622
+ export function Demo() {
623
+ return (
624
+ <div {...styles.row()}>
625
+ {(['primary', 'secondary', 'tertiary'] as const).map((variant) => (
626
+ <Button key={variant} loading variant={variant}>
627
+ Loading
628
+ </Button>
629
+ ))}
630
+ </div>
631
+ )
632
+ }
633
+
634
+ namespace styles {
635
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
636
+ }
637
+ ```
638
+
639
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Button/Loading.tsx)
640
+
641
+ #### Disabled
642
+
643
+ ```tsx
644
+ import { Button, style } from '@tempoxyz/ds'
645
+
646
+ export function Demo() {
647
+ return (
648
+ <div {...styles.row()}>
649
+ {(['primary', 'secondary', 'tertiary'] as const).map((variant) => (
650
+ <Button disabled key={variant} variant={variant}>
651
+ Disabled
652
+ </Button>
653
+ ))}
654
+ </div>
655
+ )
656
+ }
657
+
658
+ namespace styles {
659
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
660
+ }
661
+ ```
662
+
663
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Button/Disabled.tsx)
664
+
665
+ ## ButtonGroup
666
+
667
+ Lays out the actions at the foot of a dialog or focused flow.
668
+
669
+ [View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/ButtonGroup.tsx)
670
+
671
+ Figma: [Button Group](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=1269-1089)
672
+
673
+ ### Overview
674
+
675
+ A button group places [Buttons](#button) side by side at equal widths, or stacks them at full width.
676
+
677
+ ### Anatomy
678
+
679
+ Import the component and assemble its parts.
680
+
681
+ ```tsx
682
+ import { Button, ButtonGroup } from '@tempoxyz/ds'
683
+
684
+ <ButtonGroup>
685
+ <Button />
686
+ </ButtonGroup>
687
+ ```
688
+
689
+ ### Guidelines
690
+
691
+ #### When to Use
692
+
693
+ * Close a dialog with two actions of equal weight, such as Cancel and Confirm.
694
+ * Stack a main action above a dismiss action in an intro or announcement, such as Get started and Not now.
695
+
696
+ #### When Not to Use
697
+
698
+ * Use a [SplitButton](#splitbutton) for a main action with related alternatives.
699
+ * Use an [Inline](layout.md#inline) row for actions at their natural width, such as a toolbar.
700
+ * Use a [Menu](overlays.md#menu) for more than three actions.
701
+
702
+ #### Put the Primary Action Last
703
+
704
+ Place the `primary` action on the right of a pair. Keep the source order the same as the visual order, so focus reaches the main action last.
705
+
706
+ **Do:** Put the `secondary` action first and the `primary` action last.
707
+
708
+ ```tsx
709
+ /**
710
+ * Do example for "Put the Primary Action Last" on the ButtonGroup page.
711
+ * Put the `secondary` action first and the `primary` action last.
712
+ * @module
713
+ */
714
+ import { Button, ButtonGroup, style } from '@tempoxyz/ds'
715
+
716
+ /** Renders the static preview, which the guideline card shows inert. */
717
+ export function Demo() {
718
+ return (
719
+ <ButtonGroup {...styles.group()}>
720
+ <Button size="large" variant="secondary">
721
+ Cancel
722
+ </Button>
723
+ <Button size="large">Confirm</Button>
724
+ </ButtonGroup>
725
+ )
726
+ }
727
+
728
+ namespace styles {
729
+ export const group = style({ maxWidth: '320', width: '100% !custom' })
730
+ }
731
+ ```
732
+
733
+ **Don't:** Put the `primary` action on the left of a pair.
734
+
735
+ ```tsx
736
+ /**
737
+ * Don't example for "Put the Primary Action Last" on the ButtonGroup page.
738
+ * Don't put the `primary` action on the left of a pair.
739
+ * @module
740
+ */
741
+ import { Button, ButtonGroup, style } from '@tempoxyz/ds'
742
+
743
+ /** Renders the static preview, which the guideline card shows inert. */
744
+ export function Demo() {
745
+ return (
746
+ <ButtonGroup {...styles.group()}>
747
+ <Button size="large">Confirm</Button>
748
+ <Button size="large" variant="secondary">
749
+ Cancel
750
+ </Button>
751
+ </ButtonGroup>
752
+ )
753
+ }
754
+
755
+ namespace styles {
756
+ export const group = style({ maxWidth: '320', width: '100% !custom' })
757
+ }
758
+ ```
759
+
760
+ #### Keep Every Button the Same Size
761
+
762
+ Give every button in a dialog footer the `large` size. In a stack, the `tertiary` dismiss action keeps that size.
763
+
764
+ **Do:** Give the dismiss action the same `large` size as the `primary` action.
765
+
766
+ ```tsx
767
+ /**
768
+ * Do example for "Keep Every Button the Same Size" on the ButtonGroup page.
769
+ * Give the dismiss action the same `large` size as the `primary` action.
770
+ * @module
771
+ */
772
+ import { Button, ButtonGroup, style } from '@tempoxyz/ds'
773
+
774
+ /** Renders the static preview, which the guideline card shows inert. */
775
+ export function Demo() {
776
+ return (
777
+ <ButtonGroup orientation="vertical" {...styles.group()}>
778
+ <Button size="large">Get started</Button>
779
+ <Button size="large" variant="tertiary">
780
+ Not now
781
+ </Button>
782
+ </ButtonGroup>
783
+ )
784
+ }
785
+
786
+ namespace styles {
787
+ export const group = style({ maxWidth: '320', width: '100% !custom' })
788
+ }
789
+ ```
790
+
791
+ **Don't:** Shrink the dismiss action below the `primary` action.
792
+
793
+ ```tsx
794
+ /**
795
+ * Don't example for "Keep Every Button the Same Size" on the ButtonGroup page.
796
+ * Don't shrink the dismiss action below the `primary` action.
797
+ * @module
798
+ */
799
+ import { Button, ButtonGroup, style } from '@tempoxyz/ds'
800
+
801
+ /** Renders the static preview, which the guideline card shows inert. */
802
+ export function Demo() {
803
+ return (
804
+ <ButtonGroup orientation="vertical" {...styles.group()}>
805
+ <Button size="large">Get started</Button>
806
+ <Button size="small" variant="tertiary">
807
+ Not now
808
+ </Button>
809
+ </ButtonGroup>
810
+ )
811
+ }
812
+
813
+ namespace styles {
814
+ export const group = style({ maxWidth: '320', width: '100% !custom' })
815
+ }
816
+ ```
817
+
818
+ ### Content
819
+
820
+ #### Name the Destructive Action
821
+
822
+ If the action destroys data or removes access, name what it does on the `primary` button, such as Revoke all.
823
+
824
+ **Do:** Name both outcomes, such as Keep keys and Revoke all.
825
+
826
+ ```tsx
827
+ /**
828
+ * Do example for "Name the Destructive Action" on the ButtonGroup page.
829
+ * Name both outcomes, such as Keep keys and Revoke all.
830
+ * @module
831
+ */
832
+ import { Button, ButtonGroup, style } from '@tempoxyz/ds'
833
+
834
+ /** Renders the static preview, which the guideline card shows inert. */
835
+ export function Demo() {
836
+ return (
837
+ <ButtonGroup {...styles.group()}>
838
+ <Button size="large" variant="secondary">
839
+ Keep keys
840
+ </Button>
841
+ <Button size="large">Revoke all</Button>
842
+ </ButtonGroup>
843
+ )
844
+ }
845
+
846
+ namespace styles {
847
+ export const group = style({ maxWidth: '320', width: '100% !custom' })
848
+ }
849
+ ```
850
+
851
+ **Don't:** Label a destructive action OK.
852
+
853
+ ```tsx
854
+ /**
855
+ * Don't example for "Name the Destructive Action" on the ButtonGroup page.
856
+ * Don't label a destructive action OK.
857
+ * @module
858
+ */
859
+ import { Button, ButtonGroup, style } from '@tempoxyz/ds'
860
+
861
+ /** Renders the static preview, which the guideline card shows inert. */
862
+ export function Demo() {
863
+ return (
864
+ <ButtonGroup {...styles.group()}>
865
+ <Button size="large" variant="secondary">
866
+ Cancel
867
+ </Button>
868
+ <Button size="large">OK</Button>
869
+ </ButtonGroup>
870
+ )
871
+ }
872
+
873
+ namespace styles {
874
+ export const group = style({ maxWidth: '320', width: '100% !custom' })
875
+ }
876
+ ```
877
+
878
+ ### Accessibility
879
+
880
+ `ButtonGroup` renders a `div` with `role="group"` around native buttons. See [Accessibility](../foundations.md#accessibility) for the baseline.
881
+
882
+ * **Group (group):** Groups the actions. Name it with `aria-label` when the dialog title does not.
883
+ * **Focus Order (Tab):** Follows the source order, which matches the visual order in both orientations.
884
+ * **Target Size (48px):** Large buttons stretch to the full width, which leaves a wide target on touch screens.
885
+
886
+ ### Related
887
+
888
+ [Button](#button)
889
+
890
+ Use for each action in the group.
891
+
892
+ [Dialog](overlays.md#dialog)
893
+
894
+ Use for the focused task that the group closes.
895
+
896
+ [AlertDialog](overlays.md#alertdialog)
897
+
898
+ Use for confirming a destructive action.
899
+
900
+ ### Examples
901
+
902
+ #### Basic
903
+
904
+ ```tsx
905
+ import { Button, ButtonGroup, style } from '@tempoxyz/ds'
906
+
907
+ export const fill = true
908
+ export function Demo() {
909
+ return (
910
+ <ButtonGroup {...styles.group()}>
911
+ <Button size="large" variant="secondary">
912
+ Cancel
913
+ </Button>
914
+ <Button size="large">Confirm</Button>
915
+ </ButtonGroup>
916
+ )
917
+ }
918
+
919
+ namespace styles {
920
+ export const group = style({ maxWidth: '360', width: '100% !custom' })
921
+ }
922
+ ```
923
+
924
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/ButtonGroup/Basic.tsx)
925
+
926
+ #### Orientation
927
+
928
+ Set `orientation` to `horizontal` (default) or `vertical`. Both place the buttons 8px apart.
929
+
930
+ ```tsx
931
+ import { Button, ButtonGroup, style } from '@tempoxyz/ds'
932
+
933
+ export const fill = true
934
+ export function Demo() {
935
+ return (
936
+ <ButtonGroup orientation="vertical" {...styles.group()}>
937
+ <Button size="large">Get started</Button>
938
+ <Button size="large" variant="tertiary">
939
+ Not now
940
+ </Button>
941
+ </ButtonGroup>
942
+ )
943
+ }
944
+
945
+ namespace styles {
946
+ export const group = style({ maxWidth: '360', width: '100% !custom' })
947
+ }
948
+ ```
949
+
950
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/ButtonGroup/Orientation.tsx)
951
+
952
+ ## CopyButton
953
+
954
+ Copies a value to the clipboard and confirms the copy.
955
+
956
+ [View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/CopyButton.tsx)
957
+
958
+ ### Overview
959
+
960
+ A copy button is an icon-only button that writes a value to the clipboard and confirms the copy for two seconds.
961
+
962
+ ### Anatomy
963
+
964
+ Import the component and assemble its parts.
965
+
966
+ ```tsx
967
+ import { CopyButton } from '@tempoxyz/ds'
968
+
969
+ <CopyButton />
970
+ ```
971
+
972
+ ### Guidelines
973
+
974
+ #### When to Use
975
+
976
+ * Copy a value you'd otherwise select by hand, such as a webhook ID or an invite link.
977
+ * Add copying beside a value in your own layout, such as a table cell.
978
+
979
+ #### When Not to Use
980
+
981
+ * Use [Hex](blockchain.md#hex) with `copy` for addresses and transaction hashes. It truncates the middle and adds this button.
982
+ * Use [Snippet](data-display.md#snippet) for a command or code value.
983
+ * Use [SecretValue](blockchain.md#secretvalue) for API keys and other secrets that stay hidden until revealed.
984
+ * Use a [Button](#button) for other actions, such as Share or Download.
985
+
986
+ #### Place It Right After the Value
987
+
988
+ Put the button on the same line, immediately after the value. Give each value its own button.
989
+
990
+ **Do:** Place a copy button directly after each value.
991
+
992
+ ```tsx
993
+ /**
994
+ * Do example for "Place It Right After the Value" on the CopyButton page.
995
+ * Place a copy button directly after each value.
996
+ * @module
997
+ */
998
+ import { CopyButton, style } from '@tempoxyz/ds'
999
+
1000
+ /** Renders the static preview, which the guideline card shows inert. */
1001
+ export function Demo() {
1002
+ return (
1003
+ <div {...styles.rows()}>
1004
+ <div {...styles.row()}>
1005
+ <span {...styles.label()}>Webhook ID</span>
1006
+ <span {...styles.value()}>
1007
+ wh_51c8e20d
1008
+ <CopyButton aria-label="Copy webhook ID" value="wh_51c8e20d" />
1009
+ </span>
1010
+ </div>
1011
+ <div {...styles.row()}>
1012
+ <span {...styles.label()}>Key ID</span>
1013
+ <span {...styles.value()}>
1014
+ key_9f2c41a7
1015
+ <CopyButton aria-label="Copy key ID" value="key_9f2c41a7" />
1016
+ </span>
1017
+ </div>
1018
+ </div>
1019
+ )
1020
+ }
1021
+
1022
+ namespace styles {
1023
+ export const label = style({ color: 'content.secondary', typography: 'body.b2' })
1024
+
1025
+ export const row = style({
1026
+ alignItems: 'center',
1027
+ display: 'flex',
1028
+ justifyContent: 'space-between',
1029
+ minHeight: '32',
1030
+ })
1031
+
1032
+ export const rows = style({
1033
+ display: 'flex',
1034
+ flexDirection: 'column',
1035
+ rowGap: '8',
1036
+ width: '16rem !custom',
1037
+ })
1038
+
1039
+ export const value = style({
1040
+ alignItems: 'center',
1041
+ color: 'content.primary',
1042
+ columnGap: '4',
1043
+ display: 'flex',
1044
+ typography: 'mono.m1',
1045
+ })
1046
+ }
1047
+ ```
1048
+
1049
+ **Don't:** Place one copy button away from the values, where its target is unclear.
1050
+
1051
+ ```tsx
1052
+ /**
1053
+ * Don't example for "Place It Right After the Value" on the CopyButton page.
1054
+ * Don't place one copy button away from the values, where its target is unclear.
1055
+ * @module
1056
+ */
1057
+ import { CopyButton, style } from '@tempoxyz/ds'
1058
+
1059
+ /** Renders the static preview, which the guideline card shows inert. */
1060
+ export function Demo() {
1061
+ return (
1062
+ <div {...styles.rows()}>
1063
+ <div {...styles.header()}>
1064
+ <span {...styles.title()}>Webhook</span>
1065
+ <CopyButton aria-label="Copy" value="wh_51c8e20d" />
1066
+ </div>
1067
+ <div {...styles.row()}>
1068
+ <span {...styles.label()}>Webhook ID</span>
1069
+ <span {...styles.value()}>wh_51c8e20d</span>
1070
+ </div>
1071
+ <div {...styles.row()}>
1072
+ <span {...styles.label()}>Key ID</span>
1073
+ <span {...styles.value()}>key_9f2c41a7</span>
1074
+ </div>
1075
+ </div>
1076
+ )
1077
+ }
1078
+
1079
+ namespace styles {
1080
+ export const header = style({
1081
+ alignItems: 'center',
1082
+ display: 'flex',
1083
+ justifyContent: 'space-between',
1084
+ marginBottom: '4',
1085
+ })
1086
+
1087
+ export const label = style({ color: 'content.secondary', typography: 'body.b2' })
1088
+
1089
+ export const row = style({
1090
+ alignItems: 'center',
1091
+ display: 'flex',
1092
+ justifyContent: 'space-between',
1093
+ minHeight: '32',
1094
+ })
1095
+
1096
+ export const rows = style({
1097
+ display: 'flex',
1098
+ flexDirection: 'column',
1099
+ rowGap: '8',
1100
+ width: '16rem !custom',
1101
+ })
1102
+
1103
+ export const title = style({ color: 'content.primary', typography: 'body.b1Strong' })
1104
+
1105
+ export const value = style({ color: 'content.primary', typography: 'mono.m1' })
1106
+ }
1107
+ ```
1108
+
1109
+ #### Copy the Full Value
1110
+
1111
+ Pass the complete value to `value`, even when the screen shows a shortened form.
1112
+
1113
+ **Do:** Copy the complete value behind a shortened display.
1114
+
1115
+ ```tsx
1116
+ /**
1117
+ * Do example for "Copy the Full Value" on the CopyButton page.
1118
+ * Copy the complete value behind a shortened display.
1119
+ * @module
1120
+ */
1121
+ import { CopyButton, style } from '@tempoxyz/ds'
1122
+
1123
+ const url = 'https://hooks.tempo.xyz/v1/payments/wh_51c8e20d'
1124
+
1125
+ /** Renders the static preview, which the guideline card shows inert. */
1126
+ export function Demo() {
1127
+ return (
1128
+ <div {...styles.stack()}>
1129
+ <span {...styles.value()}>
1130
+ hooks.tempo.xyz/…/wh_51c8e20d
1131
+ <CopyButton aria-label="Copy webhook URL" copied value={url} />
1132
+ </span>
1133
+ <div {...styles.clipboard()}>
1134
+ <span {...styles.label()}>Clipboard</span>
1135
+ <span {...styles.copied()}>{url}</span>
1136
+ </div>
1137
+ </div>
1138
+ )
1139
+ }
1140
+
1141
+ namespace styles {
1142
+ export const clipboard = style({
1143
+ backgroundColor: 'container.regular',
1144
+ borderRadius: '2xs',
1145
+ display: 'flex',
1146
+ flexDirection: 'column',
1147
+ paddingBlock: '8',
1148
+ paddingInline: '12',
1149
+ rowGap: '2px !custom',
1150
+ })
1151
+
1152
+ export const copied = style({ color: 'content.primary', typography: 'mono.m1' })
1153
+
1154
+ export const label = style({ color: 'content.secondary', typography: 'body.b3' })
1155
+
1156
+ export const stack = style({
1157
+ display: 'flex',
1158
+ flexDirection: 'column',
1159
+ rowGap: '8',
1160
+ width: '17rem !custom',
1161
+ })
1162
+
1163
+ export const value = style({
1164
+ alignItems: 'center',
1165
+ color: 'content.primary',
1166
+ columnGap: '4',
1167
+ display: 'flex',
1168
+ typography: 'mono.m1',
1169
+ })
1170
+ }
1171
+ ```
1172
+
1173
+ **Don't:** Copy the shortened text that the screen shows.
1174
+
1175
+ ```tsx
1176
+ /**
1177
+ * Don't example for "Copy the Full Value" on the CopyButton page.
1178
+ * Don't copy the shortened text that the screen shows.
1179
+ * @module
1180
+ */
1181
+ import { CopyButton, style } from '@tempoxyz/ds'
1182
+
1183
+ const display = 'hooks.tempo.xyz/…/wh_51c8e20d'
1184
+
1185
+ /** Renders the static preview, which the guideline card shows inert. */
1186
+ export function Demo() {
1187
+ return (
1188
+ <div {...styles.stack()}>
1189
+ <span {...styles.value()}>
1190
+ {display}
1191
+ <CopyButton aria-label="Copy webhook URL" copied value={display} />
1192
+ </span>
1193
+ <div {...styles.clipboard()}>
1194
+ <span {...styles.label()}>Clipboard</span>
1195
+ <span {...styles.copied()}>{display}</span>
1196
+ </div>
1197
+ </div>
1198
+ )
1199
+ }
1200
+
1201
+ namespace styles {
1202
+ export const clipboard = style({
1203
+ backgroundColor: 'container.regular',
1204
+ borderRadius: '2xs',
1205
+ display: 'flex',
1206
+ flexDirection: 'column',
1207
+ paddingBlock: '8',
1208
+ paddingInline: '12',
1209
+ rowGap: '2px !custom',
1210
+ })
1211
+
1212
+ export const copied = style({ color: 'content.primary', typography: 'mono.m1' })
1213
+
1214
+ export const label = style({ color: 'content.secondary', typography: 'body.b3' })
1215
+
1216
+ export const stack = style({
1217
+ display: 'flex',
1218
+ flexDirection: 'column',
1219
+ rowGap: '8',
1220
+ width: '17rem !custom',
1221
+ })
1222
+
1223
+ export const value = style({
1224
+ alignItems: 'center',
1225
+ color: 'content.primary',
1226
+ columnGap: '4',
1227
+ display: 'flex',
1228
+ typography: 'mono.m1',
1229
+ })
1230
+ }
1231
+ ```
1232
+
1233
+ #### Keep the Built-In Confirmation
1234
+
1235
+ After a copy, the icon turns into a check for two seconds and screen readers announce Copied. If the clipboard refuses the write, the button shows no confirmation and calls `onCopyError` instead of `onCopy`, so keep the value selectable as text.
1236
+
1237
+ **Do:** Let the check icon confirm the copy.
1238
+
1239
+ ```tsx
1240
+ /**
1241
+ * Do example for "Keep the Built-In Confirmation" on the CopyButton page.
1242
+ * Let the check icon confirm the copy.
1243
+ * @module
1244
+ */
1245
+ import { CopyButton, style } from '@tempoxyz/ds'
1246
+
1247
+ /** Renders the static preview, which the guideline card shows inert. */
1248
+ export function Demo() {
1249
+ return (
1250
+ <div {...styles.stack()}>
1251
+ <div {...styles.row()}>
1252
+ <span {...styles.label()}>Webhook ID</span>
1253
+ <span {...styles.value()}>
1254
+ wh_51c8e20d
1255
+ <CopyButton aria-label="Copy webhook ID" copied value="wh_51c8e20d" />
1256
+ </span>
1257
+ </div>
1258
+ </div>
1259
+ )
1260
+ }
1261
+
1262
+ namespace styles {
1263
+ export const label = style({ color: 'content.secondary', typography: 'body.b2' })
1264
+
1265
+ export const row = style({
1266
+ alignItems: 'center',
1267
+ display: 'flex',
1268
+ justifyContent: 'space-between',
1269
+ minHeight: '32',
1270
+ })
1271
+
1272
+ export const stack = style({
1273
+ display: 'flex',
1274
+ flexDirection: 'column',
1275
+ rowGap: '16',
1276
+ width: '16rem !custom',
1277
+ })
1278
+
1279
+ export const value = style({
1280
+ alignItems: 'center',
1281
+ color: 'content.primary',
1282
+ columnGap: '4',
1283
+ display: 'flex',
1284
+ typography: 'mono.m1',
1285
+ })
1286
+ }
1287
+ ```
1288
+
1289
+ **Don't:** Add a [Toast](feedback-and-status.md#toast) or text such as Copied to clipboard.
1290
+
1291
+ ```tsx
1292
+ /**
1293
+ * Don't example for "Keep the Built-In Confirmation" on the CopyButton page.
1294
+ * Don't add a Toast or text such as Copied to clipboard.
1295
+ * @module
1296
+ */
1297
+ import { CopyButton, style } from '@tempoxyz/ds'
1298
+ import { CheckCircle } from '@tempoxyz/ds/icons'
1299
+
1300
+ // Toasts render in a portal, so this preview draws one in place with the toast's styles.
1301
+ /** Renders the static preview, which the guideline card shows inert. */
1302
+ export function Demo() {
1303
+ return (
1304
+ <div {...styles.stack()}>
1305
+ <div {...styles.row()}>
1306
+ <span {...styles.label()}>Webhook ID</span>
1307
+ <span {...styles.value()}>
1308
+ wh_51c8e20d
1309
+ <CopyButton aria-label="Copy webhook ID" copied value="wh_51c8e20d" />
1310
+ </span>
1311
+ </div>
1312
+ <div {...styles.toast()}>
1313
+ <CheckCircle {...styles.icon()} />
1314
+ <span {...styles.title()}>Copied to clipboard</span>
1315
+ </div>
1316
+ </div>
1317
+ )
1318
+ }
1319
+
1320
+ namespace styles {
1321
+ export const icon = style({ color: 'content.positive', flexShrink: '0 !custom', fontSize: '20' })
1322
+
1323
+ export const label = style({ color: 'content.secondary', typography: 'body.b2' })
1324
+
1325
+ export const row = style({
1326
+ alignItems: 'center',
1327
+ display: 'flex',
1328
+ justifyContent: 'space-between',
1329
+ minHeight: '32',
1330
+ })
1331
+
1332
+ export const stack = style({
1333
+ display: 'flex',
1334
+ flexDirection: 'column',
1335
+ rowGap: '16',
1336
+ width: '16rem !custom',
1337
+ })
1338
+
1339
+ export const title = style({ color: 'content.primary', typography: 'body.b2Strong' })
1340
+
1341
+ export const toast = style({
1342
+ alignItems: 'center',
1343
+ backgroundColor: 'background.elevated',
1344
+ borderRadius: 'sm',
1345
+ boxShadow: 'regular',
1346
+ boxSizing: 'border-box',
1347
+ columnGap: '12',
1348
+ display: 'flex',
1349
+ paddingBlock: '16',
1350
+ paddingInline: '20',
1351
+ })
1352
+
1353
+ export const value = style({
1354
+ alignItems: 'center',
1355
+ color: 'content.primary',
1356
+ columnGap: '4',
1357
+ display: 'flex',
1358
+ typography: 'mono.m1',
1359
+ })
1360
+ }
1361
+ ```
1362
+
1363
+ #### Choose a Variant by Context
1364
+
1365
+ * **Text (default):** Inline values in rows, tables, and cards.
1366
+ * **Secondary (secondary):** A standalone value you mainly copy, such as an invite link.
1367
+
1368
+ Keep `small` beside body text. Use `medium` or `large` in touch layouts, or beside a large value or a control of that size.
1369
+
1370
+ #### Let a Clickable Row Copy
1371
+
1372
+ If a whole row copies on press, handle the copy in the row and pass `copied` to the button. The button shows the confirmation without a second copy. [Snippet](data-display.md#snippet) and [SecretValue](blockchain.md#secretvalue) work this way.
1373
+
1374
+ **Do:** Pass `copied` so the button confirms the row's copy.
1375
+
1376
+ ```tsx
1377
+ /**
1378
+ * Do example for "Let a Clickable Row Copy" on the CopyButton page.
1379
+ * Pass `copied` so the button confirms the row's copy.
1380
+ * @module
1381
+ */
1382
+ import { CopyButton, style } from '@tempoxyz/ds'
1383
+
1384
+ /** Renders the static preview, which the guideline card shows inert. */
1385
+ export function Demo() {
1386
+ return (
1387
+ <div {...styles.row()}>
1388
+ <span {...styles.label()}>Invite link</span>
1389
+ <span {...styles.value()}>
1390
+ tempo.xyz/invite/7kq2
1391
+ <CopyButton aria-label="Copy invite link" copied value="https://tempo.xyz/invite/7kq2" />
1392
+ </span>
1393
+ </div>
1394
+ )
1395
+ }
1396
+
1397
+ namespace styles {
1398
+ export const label = style({ color: 'content.secondary', typography: 'body.b2' })
1399
+
1400
+ // The pressed row draws its hover background, since the preview is inert.
1401
+ export const row = style({
1402
+ alignItems: 'center',
1403
+ backgroundColor: 'container.regular',
1404
+ borderRadius: 'xs',
1405
+ boxSizing: 'border-box',
1406
+ display: 'flex',
1407
+ justifyContent: 'space-between',
1408
+ minHeight: '40',
1409
+ paddingInline: '12',
1410
+ width: '17rem !custom',
1411
+ })
1412
+
1413
+ export const value = style({
1414
+ alignItems: 'center',
1415
+ color: 'content.primary',
1416
+ columnGap: '4',
1417
+ display: 'flex',
1418
+ typography: 'mono.m1',
1419
+ })
1420
+ }
1421
+ ```
1422
+
1423
+ **Don't:** Leave the button unconfirmed after the row copies.
1424
+
1425
+ ```tsx
1426
+ /**
1427
+ * Don't example for "Let a Clickable Row Copy" on the CopyButton page.
1428
+ * Don't leave the button unconfirmed after the row copies.
1429
+ * @module
1430
+ */
1431
+ import { CopyButton, style } from '@tempoxyz/ds'
1432
+
1433
+ /** Renders the static preview, which the guideline card shows inert. */
1434
+ export function Demo() {
1435
+ return (
1436
+ <div {...styles.row()}>
1437
+ <span {...styles.label()}>Invite link</span>
1438
+ <span {...styles.value()}>
1439
+ tempo.xyz/invite/7kq2
1440
+ <CopyButton aria-label="Copy invite link" value="https://tempo.xyz/invite/7kq2" />
1441
+ </span>
1442
+ </div>
1443
+ )
1444
+ }
1445
+
1446
+ namespace styles {
1447
+ export const label = style({ color: 'content.secondary', typography: 'body.b2' })
1448
+
1449
+ // The pressed row draws its hover background, since the preview is inert.
1450
+ export const row = style({
1451
+ alignItems: 'center',
1452
+ backgroundColor: 'container.regular',
1453
+ borderRadius: 'xs',
1454
+ boxSizing: 'border-box',
1455
+ display: 'flex',
1456
+ justifyContent: 'space-between',
1457
+ minHeight: '40',
1458
+ paddingInline: '12',
1459
+ width: '17rem !custom',
1460
+ })
1461
+
1462
+ export const value = style({
1463
+ alignItems: 'center',
1464
+ color: 'content.primary',
1465
+ columnGap: '4',
1466
+ display: 'flex',
1467
+ typography: 'mono.m1',
1468
+ })
1469
+ }
1470
+ ```
1471
+
1472
+ ### Accessibility
1473
+
1474
+ A copy button renders an icon-only [Button](#button) with a visually hidden status message. It follows the [WAI-ARIA Authoring Practices button pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/).
1475
+
1476
+ #### Semantics
1477
+
1478
+ * **Button (button):** A native button. Enter and Space copy, and it joins the tab order.
1479
+ * **Name (aria-label):** Defaults to "Copy" and the value. Shows on hover, not on focus or touch.
1480
+ * **Copied State (2s):** After a copy, the name changes to "Copied", then returns.
1481
+ * **Status Region (status):** A polite live region holds the confirmation text.
1482
+ * **Disabled (disabled):** Removes the button from the tab order unless you set `focusableWhenDisabled`.
1483
+ * **Clipboard Fallback (execCommand):** Copies where the Clipboard API is unavailable, such as insecure contexts and some iframes.
1484
+
1485
+ #### Keyboard
1486
+
1487
+ * **Move Focus to the Button (Tab):** Moves focus to the button.
1488
+ * **Copy the Value (Enter or Space):** Copies the value.
1489
+
1490
+ #### Your Responsibilities
1491
+
1492
+ * **Name What It Copies (aria-label):** Name the value, such as "Copy address". A raw address reads poorly.
1493
+ * **Announce Parent Failures (copied):** If a parent copies on its own click, announce failures from that parent.
1494
+ * **Recover From Failures (onCopyError):** If the clipboard refuses the write, say so and keep the value selectable.
1495
+
1496
+ ### Related
1497
+
1498
+ [Hex](blockchain.md#hex)
1499
+
1500
+ Use for addresses and hashes with copying built in.
1501
+
1502
+ [Snippet](data-display.md#snippet)
1503
+
1504
+ Use for commands and code.
1505
+
1506
+ [SecretValue](blockchain.md#secretvalue)
1507
+
1508
+ Use for API keys and secrets.
1509
+
1510
+ [Button](#button)
1511
+
1512
+ Use for other icon-only actions.
1513
+
1514
+ [Blockchain Values](../patterns.md#blockchain-values)
1515
+
1516
+ Covers showing addresses, hashes, and amounts.
1517
+
1518
+ ### Examples
1519
+
1520
+ #### Basic
1521
+
1522
+ ```tsx
1523
+ import { CopyButton } from '@tempoxyz/ds'
1524
+
1525
+ export function Demo() {
1526
+ return <CopyButton value="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" />
1527
+ }
1528
+ ```
1529
+
1530
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/CopyButton/Basic.tsx)
1531
+
1532
+ #### Size
1533
+
1534
+ Set `size` to `small` (default), `medium`, or `large`.
1535
+
1536
+ ```tsx
1537
+ import { CopyButton, style } from '@tempoxyz/ds'
1538
+
1539
+ const address = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'
1540
+
1541
+ export function Demo() {
1542
+ return (
1543
+ <div {...styles.row()}>
1544
+ {(['small', 'medium', 'large'] as const).map((size) => (
1545
+ <CopyButton key={size} size={size} value={address} />
1546
+ ))}
1547
+ </div>
1548
+ )
1549
+ }
1550
+
1551
+ namespace styles {
1552
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
1553
+ }
1554
+ ```
1555
+
1556
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/CopyButton/Size.tsx)
1557
+
1558
+ #### Variant
1559
+
1560
+ Set `variant` to any [Button](#button) variant, such as `tertiary` (default) or `secondary`.
1561
+
1562
+ ```tsx
1563
+ import { CopyButton, style } from '@tempoxyz/ds'
1564
+
1565
+ const address = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'
1566
+
1567
+ export function Demo() {
1568
+ return (
1569
+ <div {...styles.row()}>
1570
+ <CopyButton value={address} />
1571
+ <CopyButton value={address} variant="secondary" />
1572
+ <CopyButton size="medium" value={address} variant="secondary" />
1573
+ </div>
1574
+ )
1575
+ }
1576
+
1577
+ namespace styles {
1578
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
1579
+ }
1580
+ ```
1581
+
1582
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/CopyButton/Variant.tsx)
1583
+
1584
+ #### Disabled
1585
+
1586
+ ```tsx
1587
+ import { CopyButton } from '@tempoxyz/ds'
1588
+
1589
+ export function Demo() {
1590
+ return <CopyButton disabled value="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" />
1591
+ }
1592
+ ```
1593
+
1594
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/CopyButton/Disabled.tsx)
1595
+
1596
+ #### Copy Error
1597
+
1598
+ Pass `onCopyError` to show a recovery when the clipboard refuses the write. The button keeps its copy icon and name.
1599
+
1600
+ ```tsx
1601
+ /**
1602
+ * CopyButton demo for the Copy Error example: a recovery message after a refused write.
1603
+ * @module
1604
+ */
1605
+ import { CopyButton, style } from '@tempoxyz/ds'
1606
+ import { useState } from 'react'
1607
+
1608
+ const link = 'https://tempo.xyz/invite/example'
1609
+
1610
+ /** Renders a selectable value whose copy button reports a refused write. */
1611
+ export function Demo() {
1612
+ const [failed, setFailed] = useState(false)
1613
+
1614
+ return (
1615
+ <div {...styles.stack()}>
1616
+ <span {...styles.row()}>
1617
+ <span {...styles.value()}>{link}</span>
1618
+ <CopyButton
1619
+ aria-label="Copy invite link"
1620
+ onCopy={() => setFailed(false)}
1621
+ onCopyError={() => setFailed(true)}
1622
+ value={link}
1623
+ />
1624
+ </span>
1625
+ {failed && (
1626
+ <span role="alert" {...styles.error()}>
1627
+ Couldn’t copy. Select the link and copy it.
1628
+ </span>
1629
+ )}
1630
+ </div>
1631
+ )
1632
+ }
1633
+
1634
+ namespace styles {
1635
+ export const error = style({ color: 'content.negative', typography: 'body.b2' })
1636
+
1637
+ export const row = style({ alignItems: 'center', columnGap: '4', display: 'flex' })
1638
+
1639
+ export const stack = style({ display: 'grid', gap: '8', justifyItems: 'start' })
1640
+
1641
+ export const value = style({ color: 'content.primary', typography: 'mono.m1' })
1642
+ }
1643
+ ```
1644
+
1645
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/CopyButton/Error.tsx)
1646
+
1647
+ ## SplitButton
1648
+
1649
+ Pairs a primary action with a menu of alternatives.
1650
+
1651
+ [View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/SplitButton.tsx)
1652
+
1653
+ ### Overview
1654
+
1655
+ A split button places the most common action beside a trigger that opens a menu of alternatives.
1656
+
1657
+ ### Anatomy
1658
+
1659
+ Import the component and assemble its parts.
1660
+
1661
+ ```tsx
1662
+ import { Menu, SplitButton } from '@tempoxyz/ds'
1663
+
1664
+ <SplitButton.Root>
1665
+ <SplitButton.Action />
1666
+ <Menu.Root>
1667
+ <SplitButton.Trigger />
1668
+ <Menu.Popup />
1669
+ </Menu.Root>
1670
+ </SplitButton.Root>
1671
+ ```
1672
+
1673
+ ### Guidelines
1674
+
1675
+ #### When to Use
1676
+
1677
+ * Offer a main action with a few variations, such as Export CSV with Export JSON and Schedule export.
1678
+ * Keep the common choice one press away, such as Create key with Create test key.
1679
+
1680
+ #### When Not to Use
1681
+
1682
+ * Use a [Button](#button) with a [Menu](overlays.md#menu) when no option is the clear default.
1683
+ * Use two [Buttons](#button) when both actions matter equally.
1684
+ * Use [Select](forms-and-inputs.md#select) or [ChoiceGroup](forms-and-inputs.md#choicegroup) to choose a value or mode, not to run an action.
1685
+ * Use a separate [Button](#button) for destructive actions, confirmed with an [AlertDialog](overlays.md#alertdialog).
1686
+
1687
+ #### Make the Action the Common Choice
1688
+
1689
+ `SplitButton.Action` runs without opening the menu, so give it the option most people pick. If people often open the menu first, move the popular option into the action, or use a [Menu](overlays.md#menu) button.
1690
+
1691
+ **Do:** Put the option most people pick on the action.
1692
+
1693
+ ```tsx
1694
+ /**
1695
+ * Do example for "Make the Action the Common Choice" on the SplitButton page.
1696
+ * Put the option most people pick on the action.
1697
+ * @module
1698
+ */
1699
+ import { Menu, SplitButton, style } from '@tempoxyz/ds'
1700
+
1701
+ /** Renders the static preview, which the guideline card shows inert. */
1702
+ export function Demo() {
1703
+ return (
1704
+ <div {...styles.stack()}>
1705
+ <SplitButton.Root aria-label="Keys">
1706
+ <SplitButton.Action>Create key</SplitButton.Action>
1707
+ <Menu.Root>
1708
+ <SplitButton.Trigger aria-label="More key options" />
1709
+ </Menu.Root>
1710
+ </SplitButton.Root>
1711
+ <div {...styles.popup()}>
1712
+ <div {...styles.item()}>Create test key</div>
1713
+ <div {...styles.item()}>Import key</div>
1714
+ </div>
1715
+ </div>
1716
+ )
1717
+ }
1718
+
1719
+ namespace styles {
1720
+ export const item = style({
1721
+ alignItems: 'center',
1722
+ borderRadius: 'xs',
1723
+ color: 'content.primary',
1724
+ display: 'flex',
1725
+ minHeight: '40',
1726
+ paddingInline: '12',
1727
+ typography: 'body.b2Strong',
1728
+ })
1729
+
1730
+ export const popup = style({
1731
+ backgroundColor: 'background.elevated',
1732
+ borderRadius: 'sm',
1733
+ boxShadow: 'regular',
1734
+ boxSizing: 'border-box',
1735
+ minWidth: '14rem !custom',
1736
+ padding: '12',
1737
+ })
1738
+
1739
+ export const stack = style({
1740
+ alignItems: 'flex-end',
1741
+ display: 'flex',
1742
+ flexDirection: 'column',
1743
+ rowGap: '4',
1744
+ })
1745
+ }
1746
+ ```
1747
+
1748
+ **Don't:** Put a rare option on the action and the common one in the menu.
1749
+
1750
+ ```tsx
1751
+ /**
1752
+ * Don't example for "Make the Action the Common Choice" on the SplitButton page.
1753
+ * Don't put a rare option on the action and the common one in the menu.
1754
+ * @module
1755
+ */
1756
+ import { Menu, SplitButton, style } from '@tempoxyz/ds'
1757
+
1758
+ /** Renders the static preview, which the guideline card shows inert. */
1759
+ export function Demo() {
1760
+ return (
1761
+ <div {...styles.stack()}>
1762
+ <SplitButton.Root aria-label="Keys">
1763
+ <SplitButton.Action>Import key</SplitButton.Action>
1764
+ <Menu.Root>
1765
+ <SplitButton.Trigger aria-label="More key options" />
1766
+ </Menu.Root>
1767
+ </SplitButton.Root>
1768
+ <div {...styles.popup()}>
1769
+ <div {...styles.item()}>Create key</div>
1770
+ <div {...styles.item()}>Create test key</div>
1771
+ </div>
1772
+ </div>
1773
+ )
1774
+ }
1775
+
1776
+ namespace styles {
1777
+ export const item = style({
1778
+ alignItems: 'center',
1779
+ borderRadius: 'xs',
1780
+ color: 'content.primary',
1781
+ display: 'flex',
1782
+ minHeight: '40',
1783
+ paddingInline: '12',
1784
+ typography: 'body.b2Strong',
1785
+ })
1786
+
1787
+ export const popup = style({
1788
+ backgroundColor: 'background.elevated',
1789
+ borderRadius: 'sm',
1790
+ boxShadow: 'regular',
1791
+ boxSizing: 'border-box',
1792
+ minWidth: '14rem !custom',
1793
+ padding: '12',
1794
+ })
1795
+
1796
+ export const stack = style({
1797
+ alignItems: 'flex-end',
1798
+ display: 'flex',
1799
+ flexDirection: 'column',
1800
+ rowGap: '4',
1801
+ })
1802
+ }
1803
+ ```
1804
+
1805
+ #### Keep Alternatives Related
1806
+
1807
+ Make every menu item a variation of the action, such as a different format or timing, and use two to five of them. Put unrelated commands, or a longer list, in a [Menu](overlays.md#menu).
1808
+
1809
+ **Do:** Fill the menu with variations of the main action.
1810
+
1811
+ ```tsx
1812
+ /**
1813
+ * Do example for "Keep Alternatives Related" on the SplitButton page.
1814
+ * Fill the menu with variations of the main action.
1815
+ * @module
1816
+ */
1817
+ import { Menu, SplitButton, style } from '@tempoxyz/ds'
1818
+
1819
+ /** Renders the static preview, which the guideline card shows inert. */
1820
+ export function Demo() {
1821
+ return (
1822
+ <div {...styles.stack()}>
1823
+ <SplitButton.Root aria-label="Export" variant="secondary">
1824
+ <SplitButton.Action>Export CSV</SplitButton.Action>
1825
+ <Menu.Root>
1826
+ <SplitButton.Trigger aria-label="More export options" />
1827
+ </Menu.Root>
1828
+ </SplitButton.Root>
1829
+ <div {...styles.popup()}>
1830
+ <div {...styles.item()}>Export JSON</div>
1831
+ <div {...styles.item()}>Schedule export</div>
1832
+ </div>
1833
+ </div>
1834
+ )
1835
+ }
1836
+
1837
+ namespace styles {
1838
+ export const item = style({
1839
+ alignItems: 'center',
1840
+ borderRadius: 'xs',
1841
+ color: 'content.primary',
1842
+ display: 'flex',
1843
+ minHeight: '40',
1844
+ paddingInline: '12',
1845
+ typography: 'body.b2Strong',
1846
+ })
1847
+
1848
+ export const popup = style({
1849
+ backgroundColor: 'background.elevated',
1850
+ borderRadius: 'sm',
1851
+ boxShadow: 'regular',
1852
+ boxSizing: 'border-box',
1853
+ minWidth: '14rem !custom',
1854
+ padding: '12',
1855
+ })
1856
+
1857
+ export const stack = style({
1858
+ alignItems: 'flex-end',
1859
+ display: 'flex',
1860
+ flexDirection: 'column',
1861
+ rowGap: '4',
1862
+ })
1863
+ }
1864
+ ```
1865
+
1866
+ **Don't:** Collect unrelated or destructive commands behind the trigger.
1867
+
1868
+ ```tsx
1869
+ /**
1870
+ * Don't example for "Keep Alternatives Related" on the SplitButton page.
1871
+ * Don't collect unrelated or destructive commands behind the trigger.
1872
+ * @module
1873
+ */
1874
+ import { Menu, SplitButton, style, variants } from '@tempoxyz/ds'
1875
+
1876
+ /** Renders the static preview, which the guideline card shows inert. */
1877
+ export function Demo() {
1878
+ return (
1879
+ <div {...styles.stack()}>
1880
+ <SplitButton.Root aria-label="Export" variant="secondary">
1881
+ <SplitButton.Action>Export CSV</SplitButton.Action>
1882
+ <Menu.Root>
1883
+ <SplitButton.Trigger aria-label="More options" />
1884
+ </Menu.Root>
1885
+ </SplitButton.Root>
1886
+ <div {...styles.popup()}>
1887
+ <div {...styles.item()}>Rename dashboard</div>
1888
+ <div {...styles.item()}>Share</div>
1889
+ <div {...styles.item({ intent: 'negative' })}>Delete dashboard</div>
1890
+ </div>
1891
+ </div>
1892
+ )
1893
+ }
1894
+
1895
+ namespace styles {
1896
+ export const item = variants({
1897
+ base: {
1898
+ alignItems: 'center',
1899
+ borderRadius: 'xs',
1900
+ color: 'content.primary',
1901
+ display: 'flex',
1902
+ minHeight: '40',
1903
+ paddingInline: '12',
1904
+ typography: 'body.b2Strong',
1905
+ },
1906
+ defaultVariants: { intent: 'default' },
1907
+ variants: {
1908
+ intent: {
1909
+ default: {},
1910
+ negative: { color: 'content.negative' },
1911
+ },
1912
+ },
1913
+ })
1914
+
1915
+ export const popup = style({
1916
+ backgroundColor: 'background.elevated',
1917
+ borderRadius: 'sm',
1918
+ boxShadow: 'regular',
1919
+ boxSizing: 'border-box',
1920
+ minWidth: '14rem !custom',
1921
+ padding: '12',
1922
+ })
1923
+
1924
+ export const stack = style({
1925
+ alignItems: 'flex-end',
1926
+ display: 'flex',
1927
+ flexDirection: 'column',
1928
+ rowGap: '4',
1929
+ })
1930
+ }
1931
+ ```
1932
+
1933
+ #### Match the Buttons Around It
1934
+
1935
+ Set `variant` and `size` on `SplitButton.Root`, and both buttons follow. A split button counts toward the one `primary` action per section, so use `secondary` when the view already has one. Use `small` in toolbars and table headers.
1936
+
1937
+ **Do:** Match the size of nearby buttons, and leave `primary` to the main action.
1938
+
1939
+ ```tsx
1940
+ /**
1941
+ * Do example for "Match the Buttons Around It" on the SplitButton page.
1942
+ * Match the size of nearby buttons, and leave `primary` to the main action.
1943
+ * @module
1944
+ */
1945
+ import { Button, Menu, SplitButton, style } from '@tempoxyz/ds'
1946
+
1947
+ /** Renders the static preview, which the guideline card shows inert. */
1948
+ export function Demo() {
1949
+ return (
1950
+ <div {...styles.row()}>
1951
+ <SplitButton.Root aria-label="Export" size="small" variant="secondary">
1952
+ <SplitButton.Action>Export CSV</SplitButton.Action>
1953
+ <Menu.Root>
1954
+ <SplitButton.Trigger aria-label="More export options" />
1955
+ </Menu.Root>
1956
+ </SplitButton.Root>
1957
+ <Button size="small">Send payment</Button>
1958
+ </div>
1959
+ )
1960
+ }
1961
+
1962
+ namespace styles {
1963
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '8' })
1964
+ }
1965
+ ```
1966
+
1967
+ **Don't:** Add a second `primary` action, or a size that differs from its neighbors.
1968
+
1969
+ ```tsx
1970
+ /**
1971
+ * Don't example for "Match the Buttons Around It" on the SplitButton page.
1972
+ * Don't add a second `primary` action, or a size that differs from its neighbors.
1973
+ * @module
1974
+ */
1975
+ import { Button, Menu, SplitButton, style } from '@tempoxyz/ds'
1976
+
1977
+ /** Renders the static preview, which the guideline card shows inert. */
1978
+ export function Demo() {
1979
+ return (
1980
+ <div {...styles.row()}>
1981
+ <SplitButton.Root aria-label="Export">
1982
+ <SplitButton.Action>Export CSV</SplitButton.Action>
1983
+ <Menu.Root>
1984
+ <SplitButton.Trigger aria-label="More export options" />
1985
+ </Menu.Root>
1986
+ </SplitButton.Root>
1987
+ <Button size="small">Send payment</Button>
1988
+ </div>
1989
+ )
1990
+ }
1991
+
1992
+ namespace styles {
1993
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '8' })
1994
+ }
1995
+ ```
1996
+
1997
+ ### Content
1998
+
1999
+ #### Name the Action and Its Object
2000
+
2001
+ Label `SplitButton.Action` with a verb and an object, such as Export CSV. A bare Export hides which variation runs.
2002
+
2003
+ #### Make Each Item Stand Alone
2004
+
2005
+ Repeat the verb in each menu item, such as Export JSON, not JSON, so each item reads as a complete action.
2006
+
2007
+ ### Accessibility
2008
+
2009
+ `SplitButton` renders a group with a primary [Button](#button) and a menu trigger. The trigger follows the [WAI-ARIA menu button pattern](https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/).
2010
+
2011
+ #### Semantics
2012
+
2013
+ * **SplitButton.Root (group):** Holds both buttons, named by its `aria-label`.
2014
+ * **SplitButton.Action (button):** The primary action, as a native button.
2015
+ * **SplitButton.Trigger (aria-haspopup):** A native button that announces its menu and open state.
2016
+ * **Menu (menu):** Named by the trigger. Items are announced as menu items.
2017
+ * **Chevron (reduced motion):** Rotates while the menu is open. Flips without animation under reduced motion.
2018
+
2019
+ #### Keyboard
2020
+
2021
+ * **Move Between Buttons (Tab):** Moves focus to the action, then to the trigger.
2022
+ * **Run the Action (Enter or Space):** On the action, runs the primary action.
2023
+ * **Open to the First Item (Enter, Space, or Down Arrow):** Opens the menu and focuses the first item.
2024
+ * **Open to the Last Item (Up Arrow):** Opens the menu and focuses the last item.
2025
+ * **Move Between Items (Down Arrow and Up Arrow):** Move between items, and wrap at the ends.
2026
+ * **Jump to the Ends (Home and End):** Move to the first and last item.
2027
+ * **Activate an Item (Enter):** Activates the focused item and closes the menu.
2028
+ * **Close the Menu (Escape):** Closes the menu.
2029
+
2030
+ #### Your Responsibilities
2031
+
2032
+ * **Name the Group (aria-label):** Name the root, such as "Save", so the pair reads as one group.
2033
+ * **Name the Trigger (aria-label):** Name the alternatives, such as "More save options". The chevron is the trigger's only content.
2034
+ * **Keep Actions Reachable:** If the primary action fails or is disabled, keep every menu action reachable another way.
2035
+
2036
+ ### Related
2037
+
2038
+ [Button](#button)
2039
+
2040
+ Use for single actions.
2041
+
2042
+ [Menu](overlays.md#menu)
2043
+
2044
+ Use for lists of actions without a default.
2045
+
2046
+ [AlertDialog](overlays.md#alertdialog)
2047
+
2048
+ Use for confirming destructive actions.
2049
+
2050
+ [Forms](../patterns.md#forms)
2051
+
2052
+ Covers placing actions.
2053
+
2054
+ ### Examples
2055
+
2056
+ #### Basic
2057
+
2058
+ ```tsx
2059
+ import { Menu, SplitButton } from '@tempoxyz/ds'
2060
+
2061
+ export function Demo() {
2062
+ return (
2063
+ <SplitButton.Root aria-label="Save">
2064
+ <SplitButton.Action>Save</SplitButton.Action>
2065
+ <Menu.Root>
2066
+ <SplitButton.Trigger aria-label="More save options" />
2067
+ <Menu.Popup align="end">
2068
+ <Menu.Item>Save as draft</Menu.Item>
2069
+ <Menu.Item>Save and close</Menu.Item>
2070
+ </Menu.Popup>
2071
+ </Menu.Root>
2072
+ </SplitButton.Root>
2073
+ )
2074
+ }
2075
+ ```
2076
+
2077
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/SplitButton/Basic.tsx)
2078
+
2079
+ #### Variant
2080
+
2081
+ Set `variant` on `SplitButton.Root` to `primary` (default), `secondary`, or `tertiary`.
2082
+
2083
+ ```tsx
2084
+ import { Menu, SplitButton, style } from '@tempoxyz/ds'
2085
+
2086
+ export function Demo() {
2087
+ return (
2088
+ <div {...styles.row()}>
2089
+ {(['primary', 'secondary', 'tertiary'] as const).map((variant) => (
2090
+ <SplitButton.Root key={variant} variant={variant}>
2091
+ <SplitButton.Action>Save</SplitButton.Action>
2092
+ <Menu.Root>
2093
+ <SplitButton.Trigger aria-label="More save options" />
2094
+ <Menu.Popup align="end">
2095
+ <Menu.Item>Save as draft</Menu.Item>
2096
+ <Menu.Item>Save and close</Menu.Item>
2097
+ </Menu.Popup>
2098
+ </Menu.Root>
2099
+ </SplitButton.Root>
2100
+ ))}
2101
+ </div>
2102
+ )
2103
+ }
2104
+
2105
+ namespace styles {
2106
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
2107
+ }
2108
+ ```
2109
+
2110
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/SplitButton/Variant.tsx)