@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,4917 @@
1
+ # Overlays
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
+ Popups that open above the page from a trigger.
8
+
9
+ - [AlertDialog](#alertdialog): Asks you to confirm a critical action before it happens.
10
+ - [Dialog](#dialog): Opens a modal popup over the page.
11
+ - [Drawer](#drawer): Slides a modal panel in from an edge of the viewport.
12
+ - [Menu](#menu): Opens a list of actions from a button.
13
+ - [Popover](#popover): Opens a non-modal popup anchored to a trigger.
14
+ - [Tooltip](#tooltip): Shows a short label for a control on hover or focus.
15
+
16
+ ## AlertDialog
17
+
18
+ Asks you to confirm a critical action before it happens.
19
+
20
+ [View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/AlertDialog.tsx)
21
+
22
+ ### Overview
23
+
24
+ A modal confirmation that blocks the page until the user decides. It never closes on an outside press. It takes the parts and the `small` size of a [Dialog](#dialog). Reserve it for decisions that need an explicit answer.
25
+
26
+ ### Anatomy
27
+
28
+ Import the component and assemble its parts.
29
+
30
+ ```tsx
31
+ import { AlertDialog, ButtonGroup } from '@tempoxyz/ds'
32
+
33
+ <AlertDialog.Root>
34
+ <AlertDialog.Trigger />
35
+ <AlertDialog.Popup>
36
+ <AlertDialog.Header>
37
+ <AlertDialog.Title />
38
+ <AlertDialog.Description />
39
+ </AlertDialog.Header>
40
+ <AlertDialog.Body />
41
+ <ButtonGroup>
42
+ <AlertDialog.Close />
43
+ </ButtonGroup>
44
+ </AlertDialog.Popup>
45
+ </AlertDialog.Root>
46
+ ```
47
+
48
+ ### Guidelines
49
+
50
+ #### When to Use
51
+
52
+ * Confirm an action you can't undo, such as Revoke key, Delete webhook, or Remove passkey.
53
+ * Ask before discarding unsaved work, such as Discard changes? on a settings page with edits.
54
+
55
+ #### When Not to Use
56
+
57
+ * Use a [Dialog](#dialog) for a task with fields, or to review a payment before sending it.
58
+ * For reversible actions, such as archiving an address, act at once and offer Undo in a [Toast](feedback-and-status.md#toast). The toast dismisses itself, so keep another way to restore the item.
59
+ * Use an [Alert](feedback-and-status.md#alert) or [Banner](feedback-and-status.md#banner) for a warning that needs no decision.
60
+ * Use a [Toast](feedback-and-status.md#toast) to report that an action finished.
61
+
62
+ #### Focus the Safe Action
63
+
64
+ Opening focuses the first tabbable element in the popup. Place Cancel first in the DOM, or pass its ref to `initialFocus` on `AlertDialog.Popup`, so an Enter press right after opening cancels.
65
+
66
+ **Do:** Start focus on Cancel.
67
+
68
+ ```tsx
69
+ /** Do example for "Focus the Safe Action" on the AlertDialog page: start focus on Cancel. @module */
70
+ import { Button, style } from '@tempoxyz/ds'
71
+ import { Focus } from '../../../components/mdx/Access.js'
72
+
73
+ /** Renders the static preview, which the guideline card shows inert. */
74
+ export function Demo() {
75
+ return (
76
+ <div {...styles.popup()}>
77
+ <span {...styles.title()}>Delete this webhook?</span>
78
+ <p {...styles.description()}>
79
+ Payment events stop reaching api.acme.com/hooks. You can’t undo this.
80
+ </p>
81
+ <div {...styles.actions()}>
82
+ <Focus>
83
+ <Button size="small" variant="secondary">
84
+ Cancel
85
+ </Button>
86
+ </Focus>
87
+ <Button size="small">Delete webhook</Button>
88
+ </div>
89
+ </div>
90
+ )
91
+ }
92
+
93
+ namespace styles {
94
+ export const actions = style({
95
+ alignItems: 'center',
96
+ columnGap: '8',
97
+ display: 'flex',
98
+ justifyContent: 'flex-end',
99
+ marginTop: '16',
100
+ })
101
+
102
+ export const description = style({
103
+ color: 'content.secondary',
104
+ margin: '0 !custom',
105
+ typography: 'body.b2',
106
+ })
107
+
108
+ export const popup = style({
109
+ backgroundColor: 'background.elevated',
110
+ borderRadius: 'sm',
111
+ boxShadow: 'regular',
112
+ boxSizing: 'border-box',
113
+ display: 'flex',
114
+ flexDirection: 'column',
115
+ padding: '24',
116
+ rowGap: '8',
117
+ width: '17rem !custom',
118
+ })
119
+
120
+ export const title = style({ color: 'content.primary', typography: 'heading.h3' })
121
+ }
122
+ ```
123
+
124
+ **Don't:** Start focus on the destructive action, where one Enter press confirms it.
125
+
126
+ ```tsx
127
+ /**
128
+ * Don't example for "Focus the Safe Action" on the AlertDialog page.
129
+ * Don't start focus on the destructive action, where one Enter press confirms it.
130
+ * @module
131
+ */
132
+ import { Button, style } from '@tempoxyz/ds'
133
+ import { Focus } from '../../../components/mdx/Access.js'
134
+
135
+ /** Renders the static preview, which the guideline card shows inert. */
136
+ export function Demo() {
137
+ return (
138
+ <div {...styles.popup()}>
139
+ <span {...styles.title()}>Delete this webhook?</span>
140
+ <p {...styles.description()}>
141
+ Payment events stop reaching api.acme.com/hooks. You can’t undo this.
142
+ </p>
143
+ <div {...styles.actions()}>
144
+ <Button size="small" variant="secondary">
145
+ Cancel
146
+ </Button>
147
+ <Focus>
148
+ <Button size="small">Delete webhook</Button>
149
+ </Focus>
150
+ </div>
151
+ </div>
152
+ )
153
+ }
154
+
155
+ namespace styles {
156
+ export const actions = style({
157
+ alignItems: 'center',
158
+ columnGap: '8',
159
+ display: 'flex',
160
+ justifyContent: 'flex-end',
161
+ marginTop: '16',
162
+ })
163
+
164
+ export const description = style({
165
+ color: 'content.secondary',
166
+ margin: '0 !custom',
167
+ typography: 'body.b2',
168
+ })
169
+
170
+ export const popup = style({
171
+ backgroundColor: 'background.elevated',
172
+ borderRadius: 'sm',
173
+ boxShadow: 'regular',
174
+ boxSizing: 'border-box',
175
+ display: 'flex',
176
+ flexDirection: 'column',
177
+ padding: '24',
178
+ rowGap: '8',
179
+ width: '17rem !custom',
180
+ })
181
+
182
+ export const title = style({ color: 'content.primary', typography: 'heading.h3' })
183
+ }
184
+ ```
185
+
186
+ #### Always Offer Cancel
187
+
188
+ Only Escape, `closeButton` and `AlertDialog.Close` close the dialog, so render a Cancel button with `AlertDialog.Close`.
189
+
190
+ **Do:** Pair the confirm button with Cancel.
191
+
192
+ ```tsx
193
+ /** Do example for "Always Offer Cancel" on the AlertDialog page: pair the confirm button with Cancel. @module */
194
+ import { Button, style } from '@tempoxyz/ds'
195
+
196
+ /** Renders the static preview, which the guideline card shows inert. */
197
+ export function Demo() {
198
+ return (
199
+ <div {...styles.popup()}>
200
+ <span {...styles.title()}>Revoke this API key?</span>
201
+ <p {...styles.description()}>
202
+ Apps that use the Production server key stop working immediately. You can’t undo this.
203
+ </p>
204
+ <div {...styles.actions()}>
205
+ <Button size="small" variant="secondary">
206
+ Cancel
207
+ </Button>
208
+ <Button size="small">Revoke key</Button>
209
+ </div>
210
+ </div>
211
+ )
212
+ }
213
+
214
+ namespace styles {
215
+ export const actions = style({
216
+ columnGap: '8',
217
+ display: 'flex',
218
+ justifyContent: 'flex-end',
219
+ marginTop: '16',
220
+ })
221
+
222
+ export const description = style({
223
+ color: 'content.secondary',
224
+ margin: '0 !custom',
225
+ typography: 'body.b2',
226
+ })
227
+
228
+ export const popup = style({
229
+ backgroundColor: 'background.elevated',
230
+ borderRadius: 'sm',
231
+ boxShadow: 'regular',
232
+ boxSizing: 'border-box',
233
+ display: 'flex',
234
+ flexDirection: 'column',
235
+ padding: '24',
236
+ rowGap: '8',
237
+ width: '17rem !custom',
238
+ })
239
+
240
+ export const title = style({ color: 'content.primary', typography: 'heading.h3' })
241
+ }
242
+ ```
243
+
244
+ **Don't:** Render the confirm button alone. An outside press doesn't close the dialog.
245
+
246
+ ```tsx
247
+ /**
248
+ * Don't example for "Always Offer Cancel" on the AlertDialog page.
249
+ * Don't render the confirm button alone. An outside press doesn't close the dialog.
250
+ * @module
251
+ */
252
+ import { Button, style } from '@tempoxyz/ds'
253
+
254
+ /** Renders the static preview, which the guideline card shows inert. */
255
+ export function Demo() {
256
+ return (
257
+ <div {...styles.popup()}>
258
+ <span {...styles.title()}>Revoke this API key?</span>
259
+ <p {...styles.description()}>
260
+ Apps that use the Production server key stop working immediately. You can’t undo this.
261
+ </p>
262
+ <div {...styles.actions()}>
263
+ <Button size="small">Revoke key</Button>
264
+ </div>
265
+ </div>
266
+ )
267
+ }
268
+
269
+ namespace styles {
270
+ export const actions = style({
271
+ alignItems: 'center',
272
+ columnGap: '8',
273
+ display: 'flex',
274
+ justifyContent: 'flex-end',
275
+ marginTop: '16',
276
+ })
277
+
278
+ export const description = style({
279
+ color: 'content.secondary',
280
+ margin: '0 !custom',
281
+ typography: 'body.b2',
282
+ })
283
+
284
+ export const popup = style({
285
+ backgroundColor: 'background.elevated',
286
+ borderRadius: 'sm',
287
+ boxShadow: 'regular',
288
+ boxSizing: 'border-box',
289
+ display: 'flex',
290
+ flexDirection: 'column',
291
+ padding: '24',
292
+ rowGap: '8',
293
+ width: '17rem !custom',
294
+ })
295
+
296
+ export const title = style({ color: 'content.primary', typography: 'heading.h3' })
297
+ }
298
+ ```
299
+
300
+ #### Show Progress on the Confirm Button
301
+
302
+ If the action waits on the network, such as revoking a key:
303
+
304
+ 1. Render the confirm button without `AlertDialog.Close`, and control `open` on `AlertDialog.Root`.
305
+ 2. Set `loading` while the request runs.
306
+ 3. Close the dialog on success. Show any error inside the dialog.
307
+
308
+ **Do:** Set `loading` on the confirm button and keep the dialog open.
309
+
310
+ ```tsx
311
+ /**
312
+ * Do example for "Show Progress on the Confirm Button" on the AlertDialog page.
313
+ * Set `loading` on the confirm button and keep the dialog open.
314
+ * @module
315
+ */
316
+ import { Button, style } from '@tempoxyz/ds'
317
+
318
+ /** Renders the static preview, which the guideline card shows inert. */
319
+ export function Demo() {
320
+ return (
321
+ <div {...styles.popup()}>
322
+ <span {...styles.title()}>Revoke this API key?</span>
323
+ <p {...styles.description()}>
324
+ Apps that use the Production server key stop working immediately. You can’t undo this.
325
+ </p>
326
+ <div {...styles.actions()}>
327
+ <Button size="small" variant="secondary">
328
+ Cancel
329
+ </Button>
330
+ <Button size="small" loading>
331
+ Revoke key
332
+ </Button>
333
+ </div>
334
+ </div>
335
+ )
336
+ }
337
+
338
+ namespace styles {
339
+ export const actions = style({
340
+ alignItems: 'center',
341
+ columnGap: '8',
342
+ display: 'flex',
343
+ justifyContent: 'flex-end',
344
+ marginTop: '16',
345
+ })
346
+
347
+ export const description = style({
348
+ color: 'content.secondary',
349
+ margin: '0 !custom',
350
+ typography: 'body.b2',
351
+ })
352
+
353
+ export const popup = style({
354
+ backgroundColor: 'background.elevated',
355
+ borderRadius: 'sm',
356
+ boxShadow: 'regular',
357
+ boxSizing: 'border-box',
358
+ display: 'flex',
359
+ flexDirection: 'column',
360
+ padding: '24',
361
+ rowGap: '8',
362
+ width: '17rem !custom',
363
+ })
364
+
365
+ export const title = style({ color: 'content.primary', typography: 'heading.h3' })
366
+ }
367
+ ```
368
+
369
+ **Don't:** Add a separate spinner and leave the buttons active.
370
+
371
+ ```tsx
372
+ /**
373
+ * Don't example for "Show Progress on the Confirm Button" on the AlertDialog page.
374
+ * Don't add a separate spinner and leave the buttons active.
375
+ * @module
376
+ */
377
+ import { Button, Spinner, style } from '@tempoxyz/ds'
378
+
379
+ /** Renders the static preview, which the guideline card shows inert. */
380
+ export function Demo() {
381
+ return (
382
+ <div {...styles.popup()}>
383
+ <span {...styles.title()}>Revoke this API key?</span>
384
+ <p {...styles.description()}>
385
+ Apps that use the Production server key stop working immediately. You can’t undo this.
386
+ </p>
387
+ <div {...styles.actions()}>
388
+ <Spinner aria-label="Revoking key" />
389
+ <Button size="small" variant="secondary">
390
+ Cancel
391
+ </Button>
392
+ <Button size="small">Revoke key</Button>
393
+ </div>
394
+ </div>
395
+ )
396
+ }
397
+
398
+ namespace styles {
399
+ export const actions = style({
400
+ alignItems: 'center',
401
+ columnGap: '8',
402
+ display: 'flex',
403
+ justifyContent: 'flex-end',
404
+ marginTop: '16',
405
+ })
406
+
407
+ export const description = style({
408
+ color: 'content.secondary',
409
+ margin: '0 !custom',
410
+ typography: 'body.b2',
411
+ })
412
+
413
+ export const popup = style({
414
+ backgroundColor: 'background.elevated',
415
+ borderRadius: 'sm',
416
+ boxShadow: 'regular',
417
+ boxSizing: 'border-box',
418
+ display: 'flex',
419
+ flexDirection: 'column',
420
+ padding: '24',
421
+ rowGap: '8',
422
+ width: '17rem !custom',
423
+ })
424
+
425
+ export const title = style({ color: 'content.primary', typography: 'heading.h3' })
426
+ }
427
+ ```
428
+
429
+ ### Content
430
+
431
+ #### Ask a Specific Question
432
+
433
+ Write the title as one question that names the action and its object, such as Revoke this API key?
434
+
435
+ #### State the Consequence
436
+
437
+ Always include an `AlertDialog.Description`. Say what stops working, then whether it can be recovered, without repeating the title.
438
+
439
+ #### Repeat the Action Verb on the Confirm Button
440
+
441
+ Label the confirm button with the verb from the trigger and title, such as Revoke key after Revoke this API key?
442
+
443
+ **Do:** Repeat the action's verb on the confirm button, such as Revoke key.
444
+
445
+ ```tsx
446
+ /** Do example for "Always Offer Cancel" on the AlertDialog page: pair the confirm button with Cancel. @module */
447
+ import { Button, style } from '@tempoxyz/ds'
448
+
449
+ /** Renders the static preview, which the guideline card shows inert. */
450
+ export function Demo() {
451
+ return (
452
+ <div {...styles.popup()}>
453
+ <span {...styles.title()}>Revoke this API key?</span>
454
+ <p {...styles.description()}>
455
+ Apps that use the Production server key stop working immediately. You can’t undo this.
456
+ </p>
457
+ <div {...styles.actions()}>
458
+ <Button size="small" variant="secondary">
459
+ Cancel
460
+ </Button>
461
+ <Button size="small">Revoke key</Button>
462
+ </div>
463
+ </div>
464
+ )
465
+ }
466
+
467
+ namespace styles {
468
+ export const actions = style({
469
+ columnGap: '8',
470
+ display: 'flex',
471
+ justifyContent: 'flex-end',
472
+ marginTop: '16',
473
+ })
474
+
475
+ export const description = style({
476
+ color: 'content.secondary',
477
+ margin: '0 !custom',
478
+ typography: 'body.b2',
479
+ })
480
+
481
+ export const popup = style({
482
+ backgroundColor: 'background.elevated',
483
+ borderRadius: 'sm',
484
+ boxShadow: 'regular',
485
+ boxSizing: 'border-box',
486
+ display: 'flex',
487
+ flexDirection: 'column',
488
+ padding: '24',
489
+ rowGap: '8',
490
+ width: '17rem !custom',
491
+ })
492
+
493
+ export const title = style({ color: 'content.primary', typography: 'heading.h3' })
494
+ }
495
+ ```
496
+
497
+ **Don't:** Ask Are you sure? or label the confirm button OK.
498
+
499
+ ```tsx
500
+ /**
501
+ * Don't example for "Repeat the Action Verb on the Confirm Button" on the AlertDialog page.
502
+ * Don't ask Are you sure? or label the confirm button OK.
503
+ * @module
504
+ */
505
+ import { Button, style } from '@tempoxyz/ds'
506
+
507
+ /** Renders the static preview, which the guideline card shows inert. */
508
+ export function Demo() {
509
+ return (
510
+ <div {...styles.popup()}>
511
+ <span {...styles.title()}>Are you sure?</span>
512
+ <p {...styles.description()}>This action cannot be undone.</p>
513
+ <div {...styles.actions()}>
514
+ <Button size="small" variant="secondary">
515
+ Cancel
516
+ </Button>
517
+ <Button size="small">OK</Button>
518
+ </div>
519
+ </div>
520
+ )
521
+ }
522
+
523
+ namespace styles {
524
+ export const actions = style({
525
+ columnGap: '8',
526
+ display: 'flex',
527
+ justifyContent: 'flex-end',
528
+ marginTop: '16',
529
+ })
530
+
531
+ export const description = style({
532
+ color: 'content.secondary',
533
+ margin: '0 !custom',
534
+ typography: 'body.b2',
535
+ })
536
+
537
+ export const popup = style({
538
+ backgroundColor: 'background.elevated',
539
+ borderRadius: 'sm',
540
+ boxShadow: 'regular',
541
+ boxSizing: 'border-box',
542
+ display: 'flex',
543
+ flexDirection: 'column',
544
+ padding: '24',
545
+ rowGap: '8',
546
+ width: '17rem !custom',
547
+ })
548
+
549
+ export const title = style({ color: 'content.primary', typography: 'heading.h3' })
550
+ }
551
+ ```
552
+
553
+ #### Avoid Two Cancels
554
+
555
+ If the action cancels something, such as a scheduled payment, label the pair Keep payment and Cancel payment. A plain Cancel beside Cancel payment is ambiguous.
556
+
557
+ ### Accessibility
558
+
559
+ Follows the [WAI-ARIA alert dialog pattern](https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/).
560
+
561
+ #### Semantics
562
+
563
+ * **AlertDialog.Trigger (button):** Announces the dialog and whether it is open.
564
+ * **AlertDialog.Popup (alertdialog):** The dialog is always modal.
565
+ * **AlertDialog.Title (h2):** Names the popup. Include it in every alert dialog.
566
+ * **AlertDialog.Description (aria-describedby):** Describes the popup. Include it in every alert dialog.
567
+ * **Page Behind (inert):** The page behind ignores input and stops scrolling.
568
+ * **Reduced Motion (prefers-reduced-motion):** The dialog fades in and out without scaling or sliding.
569
+
570
+ #### Keyboard
571
+
572
+ * **Open or Activate (Enter or Space):** Opens the dialog from the trigger, and activates the focused action.
573
+ * **Move to the Next Action (Tab):** Moves focus to the next action, wrapping from the last to the first.
574
+ * **Move to the Previous Action (Shift+Tab):** Moves focus to the previous action, wrapping from the first to the last.
575
+ * **Close the Alert Dialog (Escape):** Closes the dialog and returns focus to the trigger that opened it.
576
+
577
+ #### Focus
578
+
579
+ * **Opening:** Focuses the first tabbable element, or the popup on touch. Pass `initialFocus` to start on Cancel.
580
+ * **Trapping:** Focus stays inside the popup while it is open, and Tab never leaves it.
581
+ * **Outside Press:** Does not close the popup. Only Escape, `closeButton` or `AlertDialog.Close` closes it.
582
+ * **Closing:** Focus returns to the trigger. Pass `finalFocus` when the trigger is gone, such as after deleting its row.
583
+
584
+ #### Your Responsibilities
585
+
586
+ * **Render a Title and Description:** Always render both in `AlertDialog.Header`. Without them, the popup has no name or description.
587
+
588
+ ### Related
589
+
590
+ [Dialog](#dialog)
591
+
592
+ Use for focused tasks with fields.
593
+
594
+ [Button](actions.md#button)
595
+
596
+ Use for each action in the footer.
597
+
598
+ [ButtonGroup](actions.md#buttongroup)
599
+
600
+ Use for the Cancel and confirm actions.
601
+
602
+ [Menu](#menu)
603
+
604
+ Use for opening a confirmation from a destructive item.
605
+
606
+ [Toast](feedback-and-status.md#toast)
607
+
608
+ Use for Undo after reversible actions.
609
+
610
+ [Destructive Actions](../patterns.md#destructive-actions)
611
+
612
+ Covers deleting and revoking.
613
+
614
+ ### Examples
615
+
616
+ #### Basic
617
+
618
+ ```tsx
619
+ import { AlertDialog, Button, ButtonGroup } from '@tempoxyz/ds'
620
+
621
+ export function Demo() {
622
+ return (
623
+ <AlertDialog.Root>
624
+ <AlertDialog.Trigger render={<Button />}>Delete key</AlertDialog.Trigger>
625
+ <AlertDialog.Popup>
626
+ <AlertDialog.Header>
627
+ <AlertDialog.Title>Delete this key?</AlertDialog.Title>
628
+ <AlertDialog.Description>
629
+ Apps that use this key stop working immediately. You cannot undo this.
630
+ </AlertDialog.Description>
631
+ </AlertDialog.Header>
632
+ <ButtonGroup>
633
+ <AlertDialog.Close render={<Button size="large" variant="secondary" />}>
634
+ Cancel
635
+ </AlertDialog.Close>
636
+ <AlertDialog.Close render={<Button size="large" variant="danger" />}>
637
+ Delete key
638
+ </AlertDialog.Close>
639
+ </ButtonGroup>
640
+ </AlertDialog.Popup>
641
+ </AlertDialog.Root>
642
+ )
643
+ }
644
+ ```
645
+
646
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/AlertDialog/Basic.tsx)
647
+
648
+ ## Dialog
649
+
650
+ Opens a modal popup over the page.
651
+
652
+ [View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Dialog.tsx)
653
+
654
+ Figma: [Modal/Header](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-1876) (`Dialog.Header`), [Modal/Wallet Modal](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-1902) (`Dialog.Popup`)
655
+
656
+ ### Overview
657
+
658
+ A dialog is a modal popup over a dimmed backdrop. It stacks a header, a body and a footer of actions at one of three sizes. It traps focus and returns it to the trigger on close.
659
+
660
+ ### Anatomy
661
+
662
+ Import the component and assemble its parts.
663
+
664
+ ```tsx
665
+ import { ButtonGroup, Dialog } from '@tempoxyz/ds'
666
+
667
+ <Dialog.Root>
668
+ <Dialog.Trigger />
669
+ <Dialog.Popup>
670
+ <Dialog.Header>
671
+ <Dialog.Nav>
672
+ <Dialog.Back />
673
+ </Dialog.Nav>
674
+ <Dialog.Title />
675
+ <Dialog.Description />
676
+ </Dialog.Header>
677
+ <Dialog.Body />
678
+ <ButtonGroup>
679
+ <Dialog.Close />
680
+ </ButtonGroup>
681
+ </Dialog.Popup>
682
+ </Dialog.Root>
683
+ ```
684
+
685
+ ### Guidelines
686
+
687
+ #### When to Use
688
+
689
+ * Complete a short task in place, such as Rename wallet.
690
+ * Walk through a short flow one step at a time, such as Send or Add a passkey.
691
+ * Review details before you commit, such as a payment before Send.
692
+ * Show something to read before you continue, such as a new API key that appears once.
693
+
694
+ #### When Not to Use
695
+
696
+ * Use an [AlertDialog](#alertdialog) to confirm a destructive or irreversible action.
697
+ * Use a [Drawer](#drawer) for long forms, filters, or record details.
698
+ * Use a [Popover](#popover) for a sentence or one setting anchored to its trigger.
699
+ * Use a page for content that still scrolls at the `large` size.
700
+ * Use a [Toast](feedback-and-status.md#toast) to confirm that an action finished.
701
+
702
+ See [Choosing a Component](../components.md#popups) to compare overlays.
703
+
704
+ #### Pick the Size From the Content
705
+
706
+ Start at `medium`. Choose the size from what the dialog holds, not from how important it is.
707
+
708
+ * **One Decision (small):** One decision or outcome, with no fields.
709
+ * **One Task (medium):** Up to three fields, or one list.
710
+ * **Side-by-Side Review (large):** Several groups to read before you sign.
711
+
712
+ #### Keep One Size per Flow
713
+
714
+ Every step of a flow keeps the size of its first step. Swap the header and body for the next step instead of opening another dialog. Past 420px the body scrolls while the header and footer stay. If the body still scrolls at `large`, move the content to a page.
715
+
716
+ **Do:** Keep one task and one primary action in the dialog.
717
+
718
+ ```tsx
719
+ /**
720
+ * Do example for "Keep One Task per Dialog" on the Dialog page.
721
+ * Keep one task and one primary action in the dialog.
722
+ * @module
723
+ */
724
+ import { Button, Field, style, TextInput } from '@tempoxyz/ds'
725
+
726
+ /** Renders the static preview, which the guideline card shows inert. */
727
+ export function Demo() {
728
+ return (
729
+ <div {...styles.frame()}>
730
+ <div {...styles.popup()}>
731
+ <span {...styles.title()}>Rename wallet</span>
732
+ <Field.Root>
733
+ <Field.Label>Name</Field.Label>
734
+ <TextInput.Group>
735
+ <TextInput.Control defaultValue="Main wallet" />
736
+ </TextInput.Group>
737
+ </Field.Root>
738
+ <div {...styles.actions()}>
739
+ <Button size="small" variant="secondary">
740
+ Cancel
741
+ </Button>
742
+ <Button size="small">Save name</Button>
743
+ </div>
744
+ </div>
745
+ </div>
746
+ )
747
+ }
748
+
749
+ namespace styles {
750
+ export const actions = style({
751
+ columnGap: '8',
752
+ display: 'flex',
753
+ justifyContent: 'flex-end',
754
+ marginTop: '8',
755
+ })
756
+
757
+ export const frame = style({
758
+ height: '15rem !custom',
759
+ position: 'relative',
760
+ width: '19rem !custom',
761
+ })
762
+
763
+ export const popup = style({
764
+ backgroundColor: 'background.elevated',
765
+ borderRadius: 'sm',
766
+ boxShadow: 'regular',
767
+ boxSizing: 'border-box',
768
+ display: 'flex',
769
+ flexDirection: 'column',
770
+ left: '0',
771
+ padding: '24',
772
+ position: 'absolute',
773
+ rowGap: '12',
774
+ top: '0',
775
+ width: '17rem !custom',
776
+ })
777
+
778
+ export const title = style({ color: 'content.primary', typography: 'heading.h3' })
779
+ }
780
+ ```
781
+
782
+ **Don't:** Open a dialog from a dialog.
783
+
784
+ ```tsx
785
+ /** Don't example for "Keep One Task per Dialog" on the Dialog page. Don't open a dialog from a dialog. @module */
786
+ import { Button, Field, style, TextInput } from '@tempoxyz/ds'
787
+ import { Safe, Savings, Wallet } from '@tempoxyz/ds/icons'
788
+
789
+ /** Renders the static preview, which the guideline card shows inert. */
790
+ export function Demo() {
791
+ return (
792
+ <div {...styles.frame()}>
793
+ <div {...styles.popup()}>
794
+ <span {...styles.title()}>Rename wallet</span>
795
+ <Field.Root>
796
+ <Field.Label>Name</Field.Label>
797
+ <TextInput.Group>
798
+ <TextInput.Control defaultValue="Main wallet" />
799
+ </TextInput.Group>
800
+ </Field.Root>
801
+ <div {...styles.actions()}>
802
+ <Button size="small" variant="secondary">
803
+ Cancel
804
+ </Button>
805
+ <Button size="small">Save name</Button>
806
+ </div>
807
+ </div>
808
+ <div {...styles.stacked()}>
809
+ <span {...styles.title()}>Choose an icon</span>
810
+ <div {...styles.icons()}>
811
+ <Button aria-label="Wallet" shape="icon" size="small" variant="secondary">
812
+ <Wallet />
813
+ </Button>
814
+ <Button aria-label="Safe" shape="icon" size="small" variant="secondary">
815
+ <Safe />
816
+ </Button>
817
+ <Button aria-label="Savings" shape="icon" size="small" variant="secondary">
818
+ <Savings />
819
+ </Button>
820
+ </div>
821
+ <div {...styles.actions()}>
822
+ <Button size="small">Use icon</Button>
823
+ </div>
824
+ </div>
825
+ </div>
826
+ )
827
+ }
828
+
829
+ namespace styles {
830
+ export const actions = style({
831
+ columnGap: '8',
832
+ display: 'flex',
833
+ justifyContent: 'flex-end',
834
+ marginTop: '8',
835
+ })
836
+
837
+ export const frame = style({
838
+ height: '15rem !custom',
839
+ position: 'relative',
840
+ width: '19rem !custom',
841
+ })
842
+
843
+ export const icons = style({ columnGap: '8', display: 'flex' })
844
+
845
+ export const popup = style({
846
+ backgroundColor: 'background.elevated',
847
+ borderRadius: 'sm',
848
+ boxShadow: 'regular',
849
+ boxSizing: 'border-box',
850
+ display: 'flex',
851
+ flexDirection: 'column',
852
+ left: '0',
853
+ padding: '24',
854
+ position: 'absolute',
855
+ rowGap: '12',
856
+ top: '0',
857
+ width: '17rem !custom',
858
+ })
859
+
860
+ export const stacked = style({
861
+ backgroundColor: 'background.elevated',
862
+ borderRadius: 'sm',
863
+ bottom: '0',
864
+ boxShadow: 'regular',
865
+ boxSizing: 'border-box',
866
+ display: 'flex',
867
+ flexDirection: 'column',
868
+ padding: '20',
869
+ position: 'absolute',
870
+ right: '0',
871
+ rowGap: '12',
872
+ width: '13rem !custom',
873
+ })
874
+
875
+ export const title = style({ color: 'content.primary', typography: 'heading.h3' })
876
+ }
877
+ ```
878
+
879
+ #### Provide a Visible Way Out
880
+
881
+ Touch screens have no Escape key, and the backdrop doesn't look pressable. Set `closeButton` on `Dialog.Popup`, or add a `Dialog.Close` action such as Cancel. From step 2 of a flow, add a `Dialog.Back`.
882
+
883
+ **Do:** Offer a close button and a Cancel action beside the primary action.
884
+
885
+ ```tsx
886
+ /**
887
+ * Do example for "Provide a Visible Way Out" on the Dialog page.
888
+ * Offer a close button and a Cancel action beside the primary action.
889
+ * @module
890
+ */
891
+ import { Button, Field, style, TextInput } from '@tempoxyz/ds'
892
+ import { Close } from '@tempoxyz/ds/icons'
893
+
894
+ /** Renders the static preview, which the guideline card shows inert. */
895
+ export function Demo() {
896
+ return (
897
+ <div {...styles.popup()}>
898
+ <div {...styles.header()}>
899
+ <span {...styles.title()}>Rename wallet</span>
900
+ <Button aria-label="Close" shape="icon" size="small" variant="secondary">
901
+ <Close />
902
+ </Button>
903
+ </div>
904
+ <Field.Root>
905
+ <Field.Label>Name</Field.Label>
906
+ <TextInput.Group>
907
+ <TextInput.Control defaultValue="Main wallet" />
908
+ </TextInput.Group>
909
+ </Field.Root>
910
+ <div {...styles.actions()}>
911
+ <Button size="small" variant="secondary">
912
+ Cancel
913
+ </Button>
914
+ <Button size="small">Save name</Button>
915
+ </div>
916
+ </div>
917
+ )
918
+ }
919
+
920
+ namespace styles {
921
+ export const actions = style({
922
+ columnGap: '8',
923
+ display: 'flex',
924
+ justifyContent: 'flex-end',
925
+ marginTop: '8',
926
+ })
927
+
928
+ export const header = style({
929
+ alignItems: 'center',
930
+ columnGap: '12',
931
+ display: 'flex',
932
+ justifyContent: 'space-between',
933
+ })
934
+
935
+ export const popup = style({
936
+ backgroundColor: 'background.elevated',
937
+ borderRadius: 'sm',
938
+ boxShadow: 'regular',
939
+ boxSizing: 'border-box',
940
+ display: 'flex',
941
+ flexDirection: 'column',
942
+ padding: '24',
943
+ rowGap: '12',
944
+ width: '17rem !custom',
945
+ })
946
+
947
+ export const title = style({ color: 'content.primary', typography: 'heading.h3' })
948
+ }
949
+ ```
950
+
951
+ **Don't:** Make the primary action the only visible way out.
952
+
953
+ ```tsx
954
+ /**
955
+ * Don't example for "Provide a Visible Way Out" on the Dialog page.
956
+ * Don't make the primary action the only visible way out.
957
+ * @module
958
+ */
959
+ import { Button, Field, style, TextInput } from '@tempoxyz/ds'
960
+
961
+ /** Renders the static preview, which the guideline card shows inert. */
962
+ export function Demo() {
963
+ return (
964
+ <div {...styles.popup()}>
965
+ <span {...styles.title()}>Rename wallet</span>
966
+ <Field.Root>
967
+ <Field.Label>Name</Field.Label>
968
+ <TextInput.Group>
969
+ <TextInput.Control defaultValue="Main wallet" />
970
+ </TextInput.Group>
971
+ </Field.Root>
972
+ <div {...styles.actions()}>
973
+ <Button size="small">Save name</Button>
974
+ </div>
975
+ </div>
976
+ )
977
+ }
978
+
979
+ namespace styles {
980
+ export const actions = style({ display: 'flex', justifyContent: 'flex-end', marginTop: '8' })
981
+
982
+ export const popup = style({
983
+ backgroundColor: 'background.elevated',
984
+ borderRadius: 'sm',
985
+ boxShadow: 'regular',
986
+ boxSizing: 'border-box',
987
+ display: 'flex',
988
+ flexDirection: 'column',
989
+ padding: '24',
990
+ rowGap: '12',
991
+ width: '17rem !custom',
992
+ })
993
+
994
+ export const title = style({ color: 'content.primary', typography: 'heading.h3' })
995
+ }
996
+ ```
997
+
998
+ #### Protect Unsaved Input
999
+
1000
+ A backdrop press closes the dialog. Escape and the close controls work in both cases.
1001
+
1002
+ * **Forms (disablePointerDismissal):** Set it on `Dialog.Root` so a stray backdrop press can't discard input.
1003
+ * **Content to Read (default):** Keep the default for content with no input, so a backdrop press closes the dialog.
1004
+
1005
+ ### Content
1006
+
1007
+ #### Title With the Task
1008
+
1009
+ Write a verb and an object, without end punctuation. Reuse the trigger's label, such as Rename wallet. Save questions for an [AlertDialog](#alertdialog).
1010
+
1011
+ #### Describe the Effect
1012
+
1013
+ In `Dialog.Description`, state what the task changes in one or two sentences, such as The name is only visible to you.
1014
+
1015
+ #### Repeat the Verb on the Primary Action
1016
+
1017
+ Label the primary action with the title's verb, such as Save name. Use Cancel to close without changes.
1018
+
1019
+ #### Write One Headline
1020
+
1021
+ Give each dialog one `Dialog.Title`. Name the groups in the body with a [ListGroup](data-display.md#listgroup) heading instead of a second headline.
1022
+
1023
+ ### Accessibility
1024
+
1025
+ A dialog follows the [WAI-ARIA Authoring Practices modal dialog pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/).
1026
+
1027
+ #### Semantics
1028
+
1029
+ * **Dialog.Trigger (button):** Announces the dialog and whether it is open.
1030
+ * **Dialog.Popup (dialog):** Modal by default.
1031
+ * **Dialog.Title (h2):** Names the dialog.
1032
+ * **Dialog.Description (p):** Describes the dialog.
1033
+ * **Dialog.Back (button):** A "Back" icon button, first in the focus order.
1034
+ * **Stepper (progressbar):** Name the flow with `aria-label` on the [Stepper](navigation.md#stepper).
1035
+ * **Close Button (closeButton):** A "Close" icon button, last in the focus order.
1036
+ * **Page Behind (inert):** Ignores pointer input and scroll while open.
1037
+
1038
+ #### Keyboard
1039
+
1040
+ * **Open or Activate (Enter or Space):** Opens the dialog, or activates the focused control.
1041
+ * **Move to the Next Element (Tab):** Moves to the next element, and wraps.
1042
+ * **Move to the Previous Element (Shift+Tab):** Moves to the previous element, and wraps.
1043
+ * **Close the Dialog (Escape):** Closes the dialog and returns focus to the trigger.
1044
+
1045
+ #### Focus
1046
+
1047
+ * **Opening (initialFocus):** Moves to the first tabbable element, or the popup on touch. Pass `initialFocus` to start elsewhere, such as the amount field.
1048
+ * **Trapping:** Tab and Shift+Tab wrap inside the dialog, so focus stays inside while it is open.
1049
+ * **Backdrop Press:** Closes the dialog. In a form, set `disablePointerDismissal` on `Dialog.Root` to keep it open.
1050
+ * **Closing (finalFocus):** Returns to the trigger. Pass `finalFocus` if the task removes the trigger.
1051
+
1052
+ #### Motion
1053
+
1054
+ Under reduced motion, the dialog fades in and out without scaling or sliding.
1055
+
1056
+ #### Your Responsibilities
1057
+
1058
+ * **Render a Title (Dialog.Title):** Without it, the dialog has no accessible name.
1059
+
1060
+ ### Related
1061
+
1062
+ [AlertDialog](#alertdialog)
1063
+
1064
+ Use for confirming destructive actions.
1065
+
1066
+ [ButtonGroup](actions.md#buttongroup)
1067
+
1068
+ Use for the actions in the footer.
1069
+
1070
+ [Drawer](#drawer)
1071
+
1072
+ Use for long forms and details panels.
1073
+
1074
+ [Popover](#popover)
1075
+
1076
+ Use for anchored, non-blocking content.
1077
+
1078
+ [Stepper](navigation.md#stepper)
1079
+
1080
+ Use for progress through the steps of a flow.
1081
+
1082
+ [Forms](../patterns.md#forms)
1083
+
1084
+ Covers laying out fields and actions.
1085
+
1086
+ [Payments](../patterns.md#payments)
1087
+
1088
+ Covers reviewing a payment before you send it.
1089
+
1090
+ ### Examples
1091
+
1092
+ #### Basic
1093
+
1094
+ Set `closeButton` on `Dialog.Popup` to add a visible close control.
1095
+
1096
+ ```tsx
1097
+ import { Button, ButtonGroup, Dialog, Field, TextInput } from '@tempoxyz/ds'
1098
+
1099
+ export function Demo() {
1100
+ return (
1101
+ <Dialog.Root>
1102
+ <Dialog.Trigger render={<Button variant="secondary" />}>Rename wallet</Dialog.Trigger>
1103
+ <Dialog.Popup closeButton>
1104
+ <Dialog.Header>
1105
+ <Dialog.Title>Rename wallet</Dialog.Title>
1106
+ <Dialog.Description>The name is only visible to you.</Dialog.Description>
1107
+ </Dialog.Header>
1108
+ <Dialog.Body>
1109
+ <Field.Root>
1110
+ <Field.Label>Name</Field.Label>
1111
+ <TextInput.Group>
1112
+ <TextInput.Control defaultValue="Main wallet" />
1113
+ </TextInput.Group>
1114
+ </Field.Root>
1115
+ </Dialog.Body>
1116
+ <ButtonGroup>
1117
+ <Dialog.Close render={<Button size="large" variant="secondary" />}>Cancel</Dialog.Close>
1118
+ <Dialog.Close render={<Button size="large" />}>Save name</Dialog.Close>
1119
+ </ButtonGroup>
1120
+ </Dialog.Popup>
1121
+ </Dialog.Root>
1122
+ )
1123
+ }
1124
+ ```
1125
+
1126
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/Basic.tsx)
1127
+
1128
+ #### Size
1129
+
1130
+ Set `size` on `Dialog.Popup` to `small`, `medium` (default) or `large`. The size sets the width, radius, padding and title size together.
1131
+
1132
+ ```tsx
1133
+ import { Button, ButtonGroup, Dialog, Inline } from '@tempoxyz/ds'
1134
+
1135
+ export function Demo() {
1136
+ return (
1137
+ <Inline gap="12" wrap>
1138
+ {(['small', 'medium', 'large'] as const).map((size) => (
1139
+ <Dialog.Root key={size}>
1140
+ <Dialog.Trigger render={<Button variant="secondary" />}>Open {size}</Dialog.Trigger>
1141
+ <Dialog.Popup closeButton size={size}>
1142
+ <Dialog.Header>
1143
+ <Dialog.Title>Send USDC</Dialog.Title>
1144
+ <Dialog.Description>Payments on Tempo settle in seconds.</Dialog.Description>
1145
+ </Dialog.Header>
1146
+ <ButtonGroup>
1147
+ <Dialog.Close render={<Button size="large" variant="secondary" />}>
1148
+ Cancel
1149
+ </Dialog.Close>
1150
+ <Button size="large">Continue</Button>
1151
+ </ButtonGroup>
1152
+ </Dialog.Popup>
1153
+ </Dialog.Root>
1154
+ ))}
1155
+ </Inline>
1156
+ )
1157
+ }
1158
+ ```
1159
+
1160
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/Size.tsx)
1161
+
1162
+ #### Header Layout
1163
+
1164
+ Set `layout` on `Dialog.Header` to `inline` (default), `stacked`, `centered` or `hero`. A `Dialog.Nav` holds `Dialog.Back` and a [Stepper](navigation.md#stepper) above the title.
1165
+
1166
+ ```tsx
1167
+ import { Button, ButtonGroup, Dialog, IconTile, Inline, Stepper } from '@tempoxyz/ds'
1168
+ import { Check } from '@tempoxyz/ds/icons'
1169
+
1170
+ export function Demo() {
1171
+ return (
1172
+ <Inline gap="12" wrap>
1173
+ <Dialog.Root>
1174
+ <Dialog.Trigger render={<Button variant="secondary" />}>Inline</Dialog.Trigger>
1175
+ <Dialog.Popup closeButton>
1176
+ <Dialog.Header layout="inline">
1177
+ <Dialog.Title>Send USDC</Dialog.Title>
1178
+ <Dialog.Description>Payments on Tempo settle in seconds.</Dialog.Description>
1179
+ </Dialog.Header>
1180
+ <ButtonGroup>
1181
+ <Button size="large">Review</Button>
1182
+ </ButtonGroup>
1183
+ </Dialog.Popup>
1184
+ </Dialog.Root>
1185
+ <Dialog.Root>
1186
+ <Dialog.Trigger render={<Button variant="secondary" />}>Stacked</Dialog.Trigger>
1187
+ <Dialog.Popup closeButton>
1188
+ <Dialog.Header layout="stacked">
1189
+ <Dialog.Nav>
1190
+ <Dialog.Back />
1191
+ <Stepper.Root aria-label="Send USDC" count={4} value={2} />
1192
+ </Dialog.Nav>
1193
+ <Dialog.Title>Choose a recipient</Dialog.Title>
1194
+ <Dialog.Description>Step 2 of 4</Dialog.Description>
1195
+ </Dialog.Header>
1196
+ <ButtonGroup>
1197
+ <Button size="large">Continue</Button>
1198
+ </ButtonGroup>
1199
+ </Dialog.Popup>
1200
+ </Dialog.Root>
1201
+ <Dialog.Root>
1202
+ <Dialog.Trigger render={<Button variant="secondary" />}>Centered</Dialog.Trigger>
1203
+ <Dialog.Popup closeButton size="small">
1204
+ <Dialog.Header layout="centered">
1205
+ <Dialog.Nav />
1206
+ <IconTile intent="positive">
1207
+ <Check />
1208
+ </IconTile>
1209
+ <Dialog.Title>Passkey ready</Dialog.Title>
1210
+ <Dialog.Description>You can approve payments with Touch ID.</Dialog.Description>
1211
+ </Dialog.Header>
1212
+ <ButtonGroup>
1213
+ <Dialog.Close render={<Button size="large" />}>Got it</Dialog.Close>
1214
+ </ButtonGroup>
1215
+ </Dialog.Popup>
1216
+ </Dialog.Root>
1217
+ </Inline>
1218
+ )
1219
+ }
1220
+ ```
1221
+
1222
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/Layout.tsx)
1223
+
1224
+ ### Use Cases
1225
+
1226
+ Each screen pairs a size and a header layout with parts from the library.
1227
+
1228
+ #### Confirmation
1229
+
1230
+ Confirms a destructive or irreversible action in an [AlertDialog](#alertdialog).
1231
+
1232
+ ```tsx
1233
+ import { Alert, AlertDialog, Button, ButtonGroup } from '@tempoxyz/ds'
1234
+
1235
+ export function Demo() {
1236
+ return (
1237
+ <AlertDialog.Root>
1238
+ <AlertDialog.Trigger render={<Button />}>Revoke all connections</AlertDialog.Trigger>
1239
+ <AlertDialog.Popup closeButton>
1240
+ <AlertDialog.Header>
1241
+ <AlertDialog.Title>Revoke all connections?</AlertDialog.Title>
1242
+ <AlertDialog.Description>
1243
+ Apps and agents lose access to Personal right away.
1244
+ </AlertDialog.Description>
1245
+ </AlertDialog.Header>
1246
+ <AlertDialog.Body>
1247
+ <Alert intent="negative">
1248
+ <Alert.Icon />
1249
+ <Alert.Content>
1250
+ <Alert.Title>Can’t be undone</Alert.Title>4 apps and 1 agent will be disconnected.
1251
+ </Alert.Content>
1252
+ </Alert>
1253
+ </AlertDialog.Body>
1254
+ <ButtonGroup>
1255
+ <AlertDialog.Close render={<Button size="large" variant="secondary" />}>
1256
+ Cancel
1257
+ </AlertDialog.Close>
1258
+ <AlertDialog.Close render={<Button size="large" />}>Revoke all</AlertDialog.Close>
1259
+ </ButtonGroup>
1260
+ </AlertDialog.Popup>
1261
+ </AlertDialog.Root>
1262
+ )
1263
+ }
1264
+ ```
1265
+
1266
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/Confirmation.tsx)
1267
+
1268
+ #### Acknowledgment
1269
+
1270
+ Reports that a change finished, with one way to move on.
1271
+
1272
+ ```tsx
1273
+ import { Button, ButtonGroup, Dialog, IconTile } from '@tempoxyz/ds'
1274
+ import { Check } from '@tempoxyz/ds/icons'
1275
+
1276
+ export function Demo() {
1277
+ return (
1278
+ <Dialog.Root>
1279
+ <Dialog.Trigger render={<Button variant="secondary" />}>Add passkey</Dialog.Trigger>
1280
+ <Dialog.Popup closeButton size="small">
1281
+ <Dialog.Header layout="centered">
1282
+ <Dialog.Nav />
1283
+ <IconTile intent="positive">
1284
+ <Check />
1285
+ </IconTile>
1286
+ <Dialog.Title>Passkey ready</Dialog.Title>
1287
+ <Dialog.Description>
1288
+ You can approve payments with Touch ID from now on.
1289
+ </Dialog.Description>
1290
+ </Dialog.Header>
1291
+ <ButtonGroup>
1292
+ <Dialog.Close render={<Button size="large" />}>Got it</Dialog.Close>
1293
+ </ButtonGroup>
1294
+ </Dialog.Popup>
1295
+ </Dialog.Root>
1296
+ )
1297
+ }
1298
+ ```
1299
+
1300
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/Acknowledgment.tsx)
1301
+
1302
+ #### Form
1303
+
1304
+ Collects what a task needs, such as an amount and a recipient, before a review.
1305
+
1306
+ ```tsx
1307
+ import {
1308
+ Alert,
1309
+ AmountInput,
1310
+ Button,
1311
+ ButtonGroup,
1312
+ Dialog,
1313
+ Field,
1314
+ TextInput,
1315
+ Token,
1316
+ } from '@tempoxyz/ds'
1317
+ import { Clipboard } from '@tempoxyz/ds/icons'
1318
+
1319
+ export function Demo() {
1320
+ return (
1321
+ <Dialog.Root>
1322
+ <Dialog.Trigger render={<Button variant="secondary" />}>Send USDC</Dialog.Trigger>
1323
+ <Dialog.Popup closeButton>
1324
+ <Dialog.Header>
1325
+ <Dialog.Title>Send USDC</Dialog.Title>
1326
+ <Dialog.Description>Payments on Tempo settle in seconds.</Dialog.Description>
1327
+ </Dialog.Header>
1328
+ <Dialog.Body>
1329
+ <TextInput.Group>
1330
+ <TextInput.Control aria-label="Recipient" placeholder="Address, email or contact" />
1331
+ <TextInput.Suffix>
1332
+ <Clipboard />
1333
+ </TextInput.Suffix>
1334
+ </TextInput.Group>
1335
+ <Field.Root>
1336
+ <AmountInput.Root defaultValue="120.00">
1337
+ <Field.Label>You send</Field.Label>
1338
+ <AmountInput.Control />
1339
+ <Token address="0x20c000000000000000000000b9537d11c60e8b50" symbol="USDC" />
1340
+ <Field.Description>Balance 2,480.32</Field.Description>
1341
+ </AmountInput.Root>
1342
+ </Field.Root>
1343
+ <Alert intent="warning">
1344
+ <Alert.Icon />
1345
+ <Alert.Content>
1346
+ <Alert.Title>First time sending here</Alert.Title>
1347
+ Check the first and last 4 characters with the recipient.
1348
+ </Alert.Content>
1349
+ </Alert>
1350
+ </Dialog.Body>
1351
+ <ButtonGroup>
1352
+ <Button size="large">Review</Button>
1353
+ </ButtonGroup>
1354
+ </Dialog.Popup>
1355
+ </Dialog.Root>
1356
+ )
1357
+ }
1358
+ ```
1359
+
1360
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/Form.tsx)
1361
+
1362
+ #### Onboarding
1363
+
1364
+ Introduces a feature and its benefits before setup.
1365
+
1366
+ ```tsx
1367
+ import { Button, ButtonGroup, Dialog, IconTile, ListGroup, Stepper, style } from '@tempoxyz/ds'
1368
+ import { Check, Passkey } from '@tempoxyz/ds/icons'
1369
+
1370
+ const benefits = [
1371
+ 'Never get locked out if you lose email access',
1372
+ 'Approve with your device, no codes',
1373
+ 'Stays on your device. Tempo never sees it',
1374
+ ]
1375
+
1376
+ export function Demo() {
1377
+ return (
1378
+ <Dialog.Root>
1379
+ <Dialog.Trigger render={<Button variant="secondary" />}>Set up a passkey</Dialog.Trigger>
1380
+ <Dialog.Popup closeButton>
1381
+ <Dialog.Header layout="centered">
1382
+ <Dialog.Nav>
1383
+ <Stepper.Root aria-label="Passkey setup" count={4} value={1} />
1384
+ </Dialog.Nav>
1385
+ <IconTile>
1386
+ <Passkey />
1387
+ </IconTile>
1388
+ <Dialog.Title>Add a passkey</Dialog.Title>
1389
+ <Dialog.Description>A second way in that never needs a code.</Dialog.Description>
1390
+ </Dialog.Header>
1391
+ <Dialog.Body>
1392
+ <ListGroup.Root variant="spaced">
1393
+ {benefits.map((benefit) => (
1394
+ <ListGroup.Row key={benefit}>
1395
+ <Check {...styles.check()} />
1396
+ {benefit}
1397
+ </ListGroup.Row>
1398
+ ))}
1399
+ </ListGroup.Root>
1400
+ </Dialog.Body>
1401
+ <ButtonGroup orientation="vertical">
1402
+ <Button size="large">Create passkey</Button>
1403
+ <Dialog.Close render={<Button size="large" variant="tertiary" />}>Not now</Dialog.Close>
1404
+ </ButtonGroup>
1405
+ </Dialog.Popup>
1406
+ </Dialog.Root>
1407
+ )
1408
+ }
1409
+
1410
+ namespace styles {
1411
+ export const check = style({ color: 'content.positive', flexShrink: '0 !custom', fontSize: '16' })
1412
+ }
1413
+ ```
1414
+
1415
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/Onboarding.tsx)
1416
+
1417
+ #### Picker
1418
+
1419
+ Searches a known set and closes on a row press, so it needs no footer.
1420
+
1421
+ ```tsx
1422
+ import { Avatar, Button, Dialog, ListGroup, TextInput } from '@tempoxyz/ds'
1423
+ import { Search, Wallet } from '@tempoxyz/ds/icons'
1424
+ import { useState } from 'react'
1425
+
1426
+ const recipients = [
1427
+ { detail: 'maya@studio.co', initials: 'MR', name: 'Maya Rao' },
1428
+ { detail: '0x5d21…7e9a', initials: 'AC', name: 'Acme Co.' },
1429
+ { detail: '0x19be…c044', initials: undefined, name: 'Savings wallet' },
1430
+ ]
1431
+
1432
+ export function Demo() {
1433
+ const [open, setOpen] = useState(false)
1434
+
1435
+ return (
1436
+ <Dialog.Root onOpenChange={setOpen} open={open}>
1437
+ <Dialog.Trigger render={<Button variant="secondary" />}>Choose a recipient</Dialog.Trigger>
1438
+ <Dialog.Popup closeButton>
1439
+ <Dialog.Header layout="stacked">
1440
+ <Dialog.Nav>
1441
+ <Dialog.Back onClick={() => setOpen(false)} />
1442
+ </Dialog.Nav>
1443
+ <Dialog.Title>Choose a recipient</Dialog.Title>
1444
+ </Dialog.Header>
1445
+ <Dialog.Body>
1446
+ <TextInput.Group>
1447
+ <TextInput.Prefix>
1448
+ <Search />
1449
+ </TextInput.Prefix>
1450
+ <TextInput.Control
1451
+ aria-label="Search recipients"
1452
+ placeholder="Name, email or address"
1453
+ />
1454
+ </TextInput.Group>
1455
+ <div>
1456
+ <ListGroup.Heading>Recent</ListGroup.Heading>
1457
+ <ListGroup.Root dividers={false}>
1458
+ {recipients.map((recipient) => (
1459
+ <ListGroup.Row
1460
+ action="navigation"
1461
+ key={recipient.name}
1462
+ onClick={() => setOpen(false)}
1463
+ >
1464
+ <Avatar size="32">
1465
+ <Avatar.Fallback>{recipient.initials ?? <Wallet />}</Avatar.Fallback>
1466
+ </Avatar>
1467
+ <ListGroup.Info>
1468
+ <ListGroup.Title>{recipient.name}</ListGroup.Title>
1469
+ <ListGroup.Description>{recipient.detail}</ListGroup.Description>
1470
+ </ListGroup.Info>
1471
+ </ListGroup.Row>
1472
+ ))}
1473
+ </ListGroup.Root>
1474
+ </div>
1475
+ </Dialog.Body>
1476
+ </Dialog.Popup>
1477
+ </Dialog.Root>
1478
+ )
1479
+ }
1480
+ ```
1481
+
1482
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/Picker.tsx)
1483
+
1484
+ #### Announcement
1485
+
1486
+ Shows a new feature once with a visual, and never blocks a task.
1487
+
1488
+ ```tsx
1489
+ import { Button, ButtonGroup, Dialog, style } from '@tempoxyz/ds'
1490
+
1491
+ export function Demo() {
1492
+ return (
1493
+ <Dialog.Root>
1494
+ <Dialog.Trigger render={<Button variant="secondary" />}>What’s new</Dialog.Trigger>
1495
+ <Dialog.Popup closeButton>
1496
+ <Dialog.Header>
1497
+ <Dialog.Title>Earn on idle USDC</Dialog.Title>
1498
+ <Dialog.Description>
1499
+ Choose a vault and an amount. Nothing moves until you do.
1500
+ </Dialog.Description>
1501
+ </Dialog.Header>
1502
+ <Dialog.Body>
1503
+ <div aria-hidden="true" {...styles.visual()} />
1504
+ </Dialog.Body>
1505
+ <ButtonGroup orientation="vertical">
1506
+ <Button size="large">See vaults</Button>
1507
+ <Dialog.Close render={<Button size="large" variant="tertiary" />}>Not now</Dialog.Close>
1508
+ </ButtonGroup>
1509
+ </Dialog.Popup>
1510
+ </Dialog.Root>
1511
+ )
1512
+ }
1513
+
1514
+ namespace styles {
1515
+ // Stands in for a 2:1 feature image.
1516
+ export const visual = style({
1517
+ aspectRatio: '2 !custom',
1518
+ backgroundImage: 'linear-gradient(#0a1217, #17384a) !custom',
1519
+ borderRadius: 'sm',
1520
+ flexShrink: '0 !custom',
1521
+ })
1522
+ }
1523
+ ```
1524
+
1525
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/Announcement.tsx)
1526
+
1527
+ #### Conversion
1528
+
1529
+ Moves value between networks or tokens and shows the route before a quote.
1530
+
1531
+ ```tsx
1532
+ import { AmountInput, Button, ButtonGroup, Dialog, Field, ListGroup, Token } from '@tempoxyz/ds'
1533
+
1534
+ const usdc = '0x20c000000000000000000000b9537d11c60e8b50'
1535
+
1536
+ export function Demo() {
1537
+ return (
1538
+ <Dialog.Root>
1539
+ <Dialog.Trigger render={<Button variant="secondary" />}>Move to Tempo</Dialog.Trigger>
1540
+ <Dialog.Popup closeButton>
1541
+ <Dialog.Header>
1542
+ <Dialog.Title>Move to Tempo</Dialog.Title>
1543
+ </Dialog.Header>
1544
+ <Dialog.Body>
1545
+ <Field.Root>
1546
+ <AmountInput.Root defaultValue="2500.00">
1547
+ <Field.Label>From · Ethereum</Field.Label>
1548
+ <AmountInput.Control />
1549
+ <Token address={usdc} symbol="USDC" />
1550
+ <Field.Description>Balance 4,120.00</Field.Description>
1551
+ </AmountInput.Root>
1552
+ </Field.Root>
1553
+ <Field.Root>
1554
+ <AmountInput.Root defaultValue="2500.00">
1555
+ <Field.Label>To · Tempo</Field.Label>
1556
+ <AmountInput.Control readOnly />
1557
+ <Token address={usdc} symbol="USDC" />
1558
+ <Field.Description>Arrives in ~2 min</Field.Description>
1559
+ </AmountInput.Root>
1560
+ </Field.Root>
1561
+ <ListGroup.Root variant="boxed">
1562
+ <ListGroup.Row>
1563
+ <ListGroup.Label>Rate</ListGroup.Label>1 USDC = 1 USDC
1564
+ </ListGroup.Row>
1565
+ <ListGroup.Row>
1566
+ <ListGroup.Label>Fee</ListGroup.Label>
1567
+ 0.42 USDC
1568
+ </ListGroup.Row>
1569
+ </ListGroup.Root>
1570
+ </Dialog.Body>
1571
+ <ButtonGroup>
1572
+ <Button size="large">View quote</Button>
1573
+ </ButtonGroup>
1574
+ </Dialog.Popup>
1575
+ </Dialog.Root>
1576
+ )
1577
+ }
1578
+ ```
1579
+
1580
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/Conversion.tsx)
1581
+
1582
+ #### Review
1583
+
1584
+ Lays out every asset, fee and key change before a signature, at the `large` size.
1585
+
1586
+ ```tsx
1587
+ import { Button, ButtonGroup, Dialog, ListGroup, Stepper } from '@tempoxyz/ds'
1588
+
1589
+ const groups = [
1590
+ {
1591
+ rows: [
1592
+ ['Amount', '120.00 USDC'],
1593
+ ['To', 'Maya Rao'],
1594
+ ],
1595
+ title: 'Assets out',
1596
+ },
1597
+ {
1598
+ rows: [
1599
+ ['Network fee', '0.001 USDC'],
1600
+ ['Paid in', 'USDC'],
1601
+ ],
1602
+ title: 'Fees',
1603
+ },
1604
+ {
1605
+ rows: [
1606
+ ['TokenLogo approvals', 'None'],
1607
+ ['Signers', 'No change'],
1608
+ ],
1609
+ title: 'Approvals and key changes',
1610
+ },
1611
+ ]
1612
+
1613
+ export function Demo() {
1614
+ return (
1615
+ <Dialog.Root>
1616
+ <Dialog.Trigger render={<Button variant="secondary" />}>Review send</Dialog.Trigger>
1617
+ <Dialog.Popup closeButton size="large">
1618
+ <Dialog.Header layout="stacked">
1619
+ <Dialog.Nav>
1620
+ <Dialog.Back />
1621
+ <Stepper.Root aria-label="Send USDC" count={4} value={3} />
1622
+ </Dialog.Nav>
1623
+ <Dialog.Title>Review send</Dialog.Title>
1624
+ <Dialog.Description>Check every line before you approve.</Dialog.Description>
1625
+ </Dialog.Header>
1626
+ <Dialog.Body>
1627
+ {groups.map((group) => (
1628
+ <div key={group.title}>
1629
+ <ListGroup.Heading>{group.title}</ListGroup.Heading>
1630
+ <ListGroup.Root variant="boxed">
1631
+ {group.rows.map(([label, value]) => (
1632
+ <ListGroup.Row key={label}>
1633
+ <ListGroup.Label>{label}</ListGroup.Label>
1634
+ {value}
1635
+ </ListGroup.Row>
1636
+ ))}
1637
+ </ListGroup.Root>
1638
+ </div>
1639
+ ))}
1640
+ </Dialog.Body>
1641
+ <ButtonGroup>
1642
+ <Button size="large">Confirm send</Button>
1643
+ </ButtonGroup>
1644
+ </Dialog.Popup>
1645
+ </Dialog.Root>
1646
+ )
1647
+ }
1648
+ ```
1649
+
1650
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/Review.tsx)
1651
+
1652
+ #### Progress
1653
+
1654
+ Holds the person in place while a signer or the network responds.
1655
+
1656
+ ```tsx
1657
+ import { Button, ButtonGroup, Dialog, Spinner, style } from '@tempoxyz/ds'
1658
+
1659
+ export function Demo() {
1660
+ return (
1661
+ <Dialog.Root>
1662
+ <Dialog.Trigger render={<Button variant="secondary" />}>Sign in</Dialog.Trigger>
1663
+ <Dialog.Popup closeButton size="small">
1664
+ <Dialog.Header layout="centered">
1665
+ <Dialog.Nav>
1666
+ <Dialog.Back />
1667
+ </Dialog.Nav>
1668
+ <Dialog.Title>Approve with your sign-in</Dialog.Title>
1669
+ <Dialog.Description>Check the prompt from your Privy signer.</Dialog.Description>
1670
+ </Dialog.Header>
1671
+ <Dialog.Body {...styles.center()}>
1672
+ <Spinner aria-label="Waiting for approval" />
1673
+ </Dialog.Body>
1674
+ <ButtonGroup>
1675
+ <Button disabled size="large">
1676
+ Waiting for approval
1677
+ </Button>
1678
+ </ButtonGroup>
1679
+ </Dialog.Popup>
1680
+ </Dialog.Root>
1681
+ )
1682
+ }
1683
+
1684
+ namespace styles {
1685
+ export const center = style({ alignItems: 'center' })
1686
+ }
1687
+ ```
1688
+
1689
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/Progress.tsx)
1690
+
1691
+ #### Success
1692
+
1693
+ Confirms a settled payment with a receipt and the next step.
1694
+
1695
+ ```tsx
1696
+ import { Button, ButtonGroup, Dialog, IconTile, ListGroup } from '@tempoxyz/ds'
1697
+ import { Check } from '@tempoxyz/ds/icons'
1698
+
1699
+ export function Demo() {
1700
+ return (
1701
+ <Dialog.Root>
1702
+ <Dialog.Trigger render={<Button variant="secondary" />}>Send $120.00</Dialog.Trigger>
1703
+ <Dialog.Popup closeButton size="small">
1704
+ <Dialog.Header layout="centered">
1705
+ <Dialog.Nav />
1706
+ <IconTile intent="positive">
1707
+ <Check />
1708
+ </IconTile>
1709
+ <Dialog.Title>$120.00 sent</Dialog.Title>
1710
+ <Dialog.Description>Maya Rao has it. Settled in seconds.</Dialog.Description>
1711
+ </Dialog.Header>
1712
+ <Dialog.Body>
1713
+ <ListGroup.Root variant="boxed">
1714
+ <ListGroup.Row>
1715
+ <ListGroup.Label>To</ListGroup.Label>
1716
+ Maya Rao
1717
+ </ListGroup.Row>
1718
+ <ListGroup.Row>
1719
+ <ListGroup.Label>Fee</ListGroup.Label>
1720
+ 0.001 USDC
1721
+ </ListGroup.Row>
1722
+ <ListGroup.Row>
1723
+ <ListGroup.Label>Transaction</ListGroup.Label>
1724
+ 0x6b1d…f20e
1725
+ </ListGroup.Row>
1726
+ </ListGroup.Root>
1727
+ </Dialog.Body>
1728
+ <ButtonGroup>
1729
+ <Dialog.Close render={<Button size="large" variant="secondary" />}>
1730
+ Send another
1731
+ </Dialog.Close>
1732
+ <Dialog.Close render={<Button size="large" />}>Done</Dialog.Close>
1733
+ </ButtonGroup>
1734
+ </Dialog.Popup>
1735
+ </Dialog.Root>
1736
+ )
1737
+ }
1738
+ ```
1739
+
1740
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/Success.tsx)
1741
+
1742
+ #### Account Ready
1743
+
1744
+ Confirms a new account and shows the details the person needs next.
1745
+
1746
+ ```tsx
1747
+ import { Button, ButtonGroup, Dialog, formatHex, ListGroup, style } from '@tempoxyz/ds'
1748
+
1749
+ const address = '0x7a3f2c1e9b4d5a6f7c8e9d0a1b2c3d4e5fb8e091c2'
1750
+
1751
+ export function Demo() {
1752
+ return (
1753
+ <Dialog.Root>
1754
+ <Dialog.Trigger render={<Button variant="secondary" />}>Create wallet</Dialog.Trigger>
1755
+ <Dialog.Popup closeButton>
1756
+ <Dialog.Header>
1757
+ <Dialog.Title>Account ready</Dialog.Title>
1758
+ <Dialog.Description>Wallet ready. Add a passkey as a backup.</Dialog.Description>
1759
+ </Dialog.Header>
1760
+ <Dialog.Body>
1761
+ <ListGroup.Root variant="boxed">
1762
+ <ListGroup.Row>
1763
+ <span aria-hidden="true" {...styles.art()} />
1764
+ <ListGroup.Info size="large">
1765
+ <ListGroup.Title>Tempo Wallet</ListGroup.Title>
1766
+ <ListGroup.Description>{formatHex(address, { min: 6 })}</ListGroup.Description>
1767
+ </ListGroup.Info>
1768
+ <Button
1769
+ aria-label="Copy wallet address"
1770
+ onClick={() => navigator.clipboard.writeText(address)}
1771
+ size="xsmall"
1772
+ variant="secondary"
1773
+ >
1774
+ Copy
1775
+ </Button>
1776
+ </ListGroup.Row>
1777
+ <ListGroup.Row>
1778
+ <ListGroup.Label>Network</ListGroup.Label>
1779
+ Tempo Mainnet
1780
+ </ListGroup.Row>
1781
+ <ListGroup.Row>
1782
+ <ListGroup.Label>Signed in as</ListGroup.Label>
1783
+ piri@tempo.xyz
1784
+ </ListGroup.Row>
1785
+ <ListGroup.Row>
1786
+ <ListGroup.Label>Signers</ListGroup.Label>1 · email
1787
+ </ListGroup.Row>
1788
+ </ListGroup.Root>
1789
+ </Dialog.Body>
1790
+ <ButtonGroup orientation="vertical">
1791
+ <Button size="large">Add a passkey</Button>
1792
+ <Dialog.Close render={<Button size="large" variant="tertiary" />}>
1793
+ Go to dashboard
1794
+ </Dialog.Close>
1795
+ </ButtonGroup>
1796
+ </Dialog.Popup>
1797
+ </Dialog.Root>
1798
+ )
1799
+ }
1800
+
1801
+ namespace styles {
1802
+ // Stands in for the wallet's artwork.
1803
+ export const art = style({
1804
+ backgroundImage: 'linear-gradient(#1f1a14, #eda866, #261f1a) !custom',
1805
+ borderRadius: 'xs',
1806
+ flexShrink: '0 !custom',
1807
+ height: '40',
1808
+ width: '40',
1809
+ })
1810
+ }
1811
+ ```
1812
+
1813
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/AccountReady.tsx)
1814
+
1815
+ #### Receive Networks
1816
+
1817
+ Picks the network to receive on before the address appears.
1818
+
1819
+ ```tsx
1820
+ import {
1821
+ AssetChip,
1822
+ Button,
1823
+ ButtonGroup,
1824
+ Dialog,
1825
+ Inline,
1826
+ ListGroup,
1827
+ NetworkLogo,
1828
+ } from '@tempoxyz/ds'
1829
+
1830
+ const networks = [
1831
+ { name: 'Base', network: 'base' },
1832
+ { name: 'Ethereum', network: 'ethereum' },
1833
+ { name: 'HyperEVM', network: 'hyperevm' },
1834
+ { name: 'Polygon', network: 'polygon' },
1835
+ { name: 'Solana', network: 'solana' },
1836
+ ] as const
1837
+
1838
+ export function Demo() {
1839
+ return (
1840
+ <Dialog.Root>
1841
+ <Dialog.Trigger render={<Button variant="secondary" />}>Receive</Dialog.Trigger>
1842
+ <Dialog.Popup closeButton>
1843
+ <Dialog.Header>
1844
+ <Dialog.Title>Receive crypto</Dialog.Title>
1845
+ <Dialog.Description>Send supported stablecoins to this address.</Dialog.Description>
1846
+ </Dialog.Header>
1847
+ <Dialog.Body>
1848
+ <ListGroup.Root dividers={false}>
1849
+ {networks.map((entry) => (
1850
+ <ListGroup.Row key={entry.network} onClick={() => {}}>
1851
+ <NetworkLogo network={entry.network} size="large" />
1852
+ <ListGroup.Info>
1853
+ <ListGroup.Title>{entry.name}</ListGroup.Title>
1854
+ <Inline gap="4">
1855
+ <AssetChip>USDC</AssetChip>
1856
+ <AssetChip>USDT</AssetChip>
1857
+ </Inline>
1858
+ </ListGroup.Info>
1859
+ </ListGroup.Row>
1860
+ ))}
1861
+ </ListGroup.Root>
1862
+ </Dialog.Body>
1863
+ <ButtonGroup>
1864
+ <Dialog.Close render={<Button size="large" />}>Done</Dialog.Close>
1865
+ </ButtonGroup>
1866
+ </Dialog.Popup>
1867
+ </Dialog.Root>
1868
+ )
1869
+ }
1870
+ ```
1871
+
1872
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/ReceiveNetworks.tsx)
1873
+
1874
+ #### Receive Address
1875
+
1876
+ Shows the address and its QR code for the chosen network, with a copy action.
1877
+
1878
+ ```tsx
1879
+ import { Button, ButtonGroup, Dialog, formatHex, ListGroup, Qr, style } from '@tempoxyz/ds'
1880
+
1881
+ const address = '0x7a3f2c1e9b4d5a6f7c8e9d0a1b2c3d4e6b8e91c2'
1882
+
1883
+ export function Demo() {
1884
+ return (
1885
+ <Dialog.Root>
1886
+ <Dialog.Trigger render={<Button variant="secondary" />}>Receive on Ethereum</Dialog.Trigger>
1887
+ <Dialog.Popup closeButton>
1888
+ <Dialog.Header layout="stacked">
1889
+ <Dialog.Nav>
1890
+ <Dialog.Back />
1891
+ </Dialog.Nav>
1892
+ <Dialog.Title>Receive crypto</Dialog.Title>
1893
+ <Dialog.Description>Send supported stablecoins to this address.</Dialog.Description>
1894
+ </Dialog.Header>
1895
+ <Dialog.Body>
1896
+ <Qr aria-label="Ethereum address QR code" size="small" value={address} {...styles.qr()} />
1897
+ <ListGroup.Root variant="boxed">
1898
+ <ListGroup.Row>
1899
+ <ListGroup.Info size="large">
1900
+ <ListGroup.Title>Your address</ListGroup.Title>
1901
+ <ListGroup.Description>{formatHex(address, { min: 12 })}</ListGroup.Description>
1902
+ </ListGroup.Info>
1903
+ <Button
1904
+ aria-label="Copy address"
1905
+ onClick={() => navigator.clipboard.writeText(address)}
1906
+ size="xsmall"
1907
+ variant="secondary"
1908
+ >
1909
+ Copy
1910
+ </Button>
1911
+ </ListGroup.Row>
1912
+ <ListGroup.Row>
1913
+ <ListGroup.Label>Network to send from</ListGroup.Label>
1914
+ Ethereum
1915
+ </ListGroup.Row>
1916
+ </ListGroup.Root>
1917
+ </Dialog.Body>
1918
+ <ButtonGroup>
1919
+ <Dialog.Close render={<Button size="large" />}>Done</Dialog.Close>
1920
+ </ButtonGroup>
1921
+ </Dialog.Popup>
1922
+ </Dialog.Root>
1923
+ )
1924
+ }
1925
+
1926
+ namespace styles {
1927
+ export const qr = style({ alignSelf: 'center' })
1928
+ }
1929
+ ```
1930
+
1931
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/ReceiveAddress.tsx)
1932
+
1933
+ #### Verify Code
1934
+
1935
+ Confirms an email or phone number with a one-time code.
1936
+
1937
+ ```tsx
1938
+ import { Button, ButtonGroup, Dialog, Field, TextInput } from '@tempoxyz/ds'
1939
+
1940
+ export function Demo() {
1941
+ return (
1942
+ <Dialog.Root>
1943
+ <Dialog.Trigger render={<Button variant="secondary" />}>Verify email</Dialog.Trigger>
1944
+ <Dialog.Popup closeButton>
1945
+ <Dialog.Header layout="stacked">
1946
+ <Dialog.Nav>
1947
+ <Dialog.Back />
1948
+ </Dialog.Nav>
1949
+ <Dialog.Title>Check your email</Dialog.Title>
1950
+ <Dialog.Description>
1951
+ Enter the 6-digit code we sent to you@example.com.
1952
+ </Dialog.Description>
1953
+ </Dialog.Header>
1954
+ <Dialog.Body>
1955
+ <Field.Root>
1956
+ <TextInput.Group>
1957
+ <TextInput.Control
1958
+ aria-label="Code"
1959
+ autoComplete="one-time-code"
1960
+ defaultValue="48291"
1961
+ inputMode="numeric"
1962
+ />
1963
+ </TextInput.Group>
1964
+ <Field.Description>Didn’t get it? Check spam. Resend in 0:30</Field.Description>
1965
+ </Field.Root>
1966
+ </Dialog.Body>
1967
+ <ButtonGroup orientation="vertical">
1968
+ <Button size="large">Continue</Button>
1969
+ <Dialog.Close render={<Button size="large" variant="tertiary" />}>
1970
+ Use a different email
1971
+ </Dialog.Close>
1972
+ </ButtonGroup>
1973
+ </Dialog.Popup>
1974
+ </Dialog.Root>
1975
+ )
1976
+ }
1977
+ ```
1978
+
1979
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Dialog/VerifyCode.tsx)
1980
+
1981
+ ## Drawer
1982
+
1983
+ Slides a modal panel in from an edge of the viewport.
1984
+
1985
+ [View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Drawer.tsx)
1986
+
1987
+ Figma: [Modal/Drawer](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-3740) (`Drawer.Popup`)
1988
+
1989
+ ### Overview
1990
+
1991
+ A drawer is a modal panel that slides in from a viewport edge. A swipe closes it.
1992
+
1993
+ ### Anatomy
1994
+
1995
+ Import the component and assemble its parts.
1996
+
1997
+ ```tsx
1998
+ import { Drawer } from '@tempoxyz/ds'
1999
+
2000
+ <Drawer.Root>
2001
+ <Drawer.Trigger />
2002
+ <Drawer.Popup>
2003
+ <Drawer.Content>
2004
+ <Drawer.Title />
2005
+ <Drawer.Description />
2006
+ <Drawer.Close />
2007
+ </Drawer.Content>
2008
+ </Drawer.Popup>
2009
+ </Drawer.Root>
2010
+ ```
2011
+
2012
+ ### Guidelines
2013
+
2014
+ #### When to Use
2015
+
2016
+ * Show a record's details beside its list, such as a payment from Activity.
2017
+ * Hold filters for a table or dashboard.
2018
+ * Show choices, a short form, or details as a bottom sheet on narrow screens.
2019
+
2020
+ #### When Not to Use
2021
+
2022
+ * Use a [Dialog](#dialog) for a short, focused task, such as Rename wallet.
2023
+ * Use an [AlertDialog](#alertdialog) to confirm a destructive action.
2024
+ * Use a [Popover](#popover) for content anchored to its trigger on wide screens.
2025
+ * Use [AppShell](layout.md#appshell) for navigation. Below 1024px, its sidebar already opens in a drawer.
2026
+ * Use a page for content you'd link to, such as a full transaction record.
2027
+
2028
+ #### Pick an Edge
2029
+
2030
+ `swipeDirection` on `Drawer.Root` sets the edge the drawer opens from and the swipe that closes it.
2031
+
2032
+ * **Bottom (down):** The default, for bottom sheets on narrow screens.
2033
+ * **Right Edge (right):** Details and filters beside a list on wide screens.
2034
+ * **Left Edge (left):** Rarely. Use the right edge across a product.
2035
+ * **Top (up):** Avoid. It covers the header and sits far from the thumb.
2036
+
2037
+ Below 640px, change a `right` drawer to `swipeDirection="down"`, to match a [Dialog](#dialog) at that width.
2038
+
2039
+ #### Give Drawers Content That Needs Room
2040
+
2041
+ Use a drawer for content taller than a dialog, such as a payment's full details. A two-button confirmation leaves the panel empty.
2042
+
2043
+ **Do:** Open record details in a `right` drawer beside the list they came from.
2044
+
2045
+ ```tsx
2046
+ /**
2047
+ * Do example for "Give Drawers Content That Needs Room" on the Drawer page.
2048
+ * Open record details in a `right` drawer beside the list they came from.
2049
+ * @module
2050
+ */
2051
+ import { style } from '@tempoxyz/ds'
2052
+
2053
+ const activity = [
2054
+ { amount: '−250.00', name: 'Alex' },
2055
+ { amount: '+1,200.00', name: 'Payroll' },
2056
+ { amount: '−18.40', name: 'Ramen Bar' },
2057
+ { amount: '−75.00', name: 'Sam' },
2058
+ ]
2059
+
2060
+ const details = [
2061
+ { label: 'Amount', value: '250.00 USDC' },
2062
+ { label: 'To', value: '0x3c44…93bc' },
2063
+ { label: 'Status', value: 'Confirmed' },
2064
+ ]
2065
+
2066
+ /** Renders the static preview, which the guideline card shows inert. */
2067
+ export function Demo() {
2068
+ return (
2069
+ <div {...styles.frame()}>
2070
+ <div {...styles.list()}>
2071
+ {activity.map((entry) => (
2072
+ <div key={entry.name} {...styles.row()}>
2073
+ <span>{entry.name}</span>
2074
+ <span>{entry.amount}</span>
2075
+ </div>
2076
+ ))}
2077
+ </div>
2078
+ <div {...styles.scrim()} />
2079
+ <div {...styles.panel()}>
2080
+ <span {...styles.title()}>Payment to Alex</span>
2081
+ {details.map((entry) => (
2082
+ <div key={entry.label} {...styles.detail()}>
2083
+ <span {...styles.label()}>{entry.label}</span>
2084
+ <span {...styles.value()}>{entry.value}</span>
2085
+ </div>
2086
+ ))}
2087
+ </div>
2088
+ </div>
2089
+ )
2090
+ }
2091
+
2092
+ namespace styles {
2093
+ export const detail = style({ display: 'flex', flexDirection: 'column', rowGap: '2px !custom' })
2094
+
2095
+ export const frame = style({
2096
+ backgroundColor: 'background.primary',
2097
+ borderColor: 'line.secondary',
2098
+ borderRadius: 'xs',
2099
+ borderStyle: 'solid',
2100
+ borderWidth: 'regular',
2101
+ boxSizing: 'border-box',
2102
+ height: '12rem !custom',
2103
+ overflow: 'hidden',
2104
+ position: 'relative',
2105
+ width: '18rem !custom',
2106
+ })
2107
+
2108
+ export const label = style({ color: 'content.secondary', typography: 'body.b3' })
2109
+
2110
+ export const list = style({
2111
+ display: 'flex',
2112
+ flexDirection: 'column',
2113
+ padding: '12',
2114
+ rowGap: '12',
2115
+ })
2116
+
2117
+ export const panel = style({
2118
+ backgroundColor: 'background.elevated',
2119
+ borderBottomLeftRadius: 'sm',
2120
+ borderTopLeftRadius: 'sm',
2121
+ boxSizing: 'border-box',
2122
+ display: 'flex',
2123
+ flexDirection: 'column',
2124
+ insetBlock: '0',
2125
+ insetInlineEnd: '0',
2126
+ padding: '16',
2127
+ position: 'absolute',
2128
+ rowGap: '12',
2129
+ width: '10.5rem !custom',
2130
+ })
2131
+
2132
+ export const row = style({
2133
+ color: 'content.primary',
2134
+ display: 'flex',
2135
+ justifyContent: 'space-between',
2136
+ typography: 'body.b3',
2137
+ })
2138
+
2139
+ export const scrim = style({
2140
+ backgroundColor: 'neutral.100',
2141
+ inset: '0',
2142
+ opacity: 'disabled',
2143
+ position: 'absolute',
2144
+ })
2145
+
2146
+ export const title = style({ color: 'content.primary', typography: 'body.b2Strong' })
2147
+
2148
+ export const value = style({ color: 'content.primary', typography: 'body.b3Strong' })
2149
+ }
2150
+ ```
2151
+
2152
+ **Don't:** Put a short confirmation in a drawer. Use an [AlertDialog](#alertdialog).
2153
+
2154
+ ```tsx
2155
+ /**
2156
+ * Don't example for "Give Drawers Content That Needs Room" on the Drawer page.
2157
+ * Don't put a short confirmation in a drawer. Use an AlertDialog.
2158
+ * @module
2159
+ */
2160
+ import { Button, style } from '@tempoxyz/ds'
2161
+
2162
+ const keys = ['Production server', 'Staging server', 'Local testing', 'CI pipeline']
2163
+
2164
+ /** Renders the static preview, which the guideline card shows inert. */
2165
+ export function Demo() {
2166
+ return (
2167
+ <div {...styles.frame()}>
2168
+ <div {...styles.list()}>
2169
+ {keys.map((key) => (
2170
+ <span key={key} {...styles.row()}>
2171
+ {key}
2172
+ </span>
2173
+ ))}
2174
+ </div>
2175
+ <div {...styles.scrim()} />
2176
+ <div {...styles.panel()}>
2177
+ <span {...styles.title()}>Revoke this API key?</span>
2178
+ <Button size="small">Revoke key</Button>
2179
+ <Button size="small" variant="secondary">
2180
+ Cancel
2181
+ </Button>
2182
+ </div>
2183
+ </div>
2184
+ )
2185
+ }
2186
+
2187
+ namespace styles {
2188
+ export const frame = style({
2189
+ backgroundColor: 'background.primary',
2190
+ borderColor: 'line.secondary',
2191
+ borderRadius: 'xs',
2192
+ borderStyle: 'solid',
2193
+ borderWidth: 'regular',
2194
+ boxSizing: 'border-box',
2195
+ height: '12rem !custom',
2196
+ overflow: 'hidden',
2197
+ position: 'relative',
2198
+ width: '18rem !custom',
2199
+ })
2200
+
2201
+ export const list = style({
2202
+ display: 'flex',
2203
+ flexDirection: 'column',
2204
+ padding: '12',
2205
+ rowGap: '12',
2206
+ })
2207
+
2208
+ export const panel = style({
2209
+ backgroundColor: 'background.elevated',
2210
+ borderBottomLeftRadius: 'sm',
2211
+ borderTopLeftRadius: 'sm',
2212
+ boxSizing: 'border-box',
2213
+ display: 'flex',
2214
+ flexDirection: 'column',
2215
+ insetBlock: '0',
2216
+ insetInlineEnd: '0',
2217
+ padding: '16',
2218
+ position: 'absolute',
2219
+ rowGap: '8',
2220
+ width: '10.5rem !custom',
2221
+ })
2222
+
2223
+ export const row = style({ color: 'content.primary', typography: 'body.b3' })
2224
+
2225
+ export const scrim = style({
2226
+ backgroundColor: 'neutral.100',
2227
+ inset: '0',
2228
+ opacity: 'disabled',
2229
+ position: 'absolute',
2230
+ })
2231
+
2232
+ export const title = style({
2233
+ color: 'content.primary',
2234
+ marginBottom: '8',
2235
+ typography: 'body.b2Strong',
2236
+ })
2237
+ }
2238
+ ```
2239
+
2240
+ #### Always Render a Close Control
2241
+
2242
+ Swipes aren't discoverable, and some people can't drag. Set `closeButton` on `Drawer.Popup`, or add a `Drawer.Close` action. A read-only details drawer needs no other action.
2243
+
2244
+ **Do:** Render a close button, even when a swipe closes the drawer.
2245
+
2246
+ ```tsx
2247
+ /**
2248
+ * Do example for "Always Render a Close Control" on the Drawer page.
2249
+ * Render a close button, even when a swipe closes the drawer.
2250
+ * @module
2251
+ */
2252
+ import { Button, style } from '@tempoxyz/ds'
2253
+ import { Close } from '@tempoxyz/ds/icons'
2254
+
2255
+ const activity = ['Alex', 'Payroll', 'Ramen Bar', 'Sam']
2256
+
2257
+ const details = [
2258
+ { label: 'Amount', value: '250.00 USDC' },
2259
+ { label: 'To', value: '0x3c44…93bc' },
2260
+ ]
2261
+
2262
+ /** Renders the static preview, which the guideline card shows inert. */
2263
+ export function Demo() {
2264
+ return (
2265
+ <div {...styles.frame()}>
2266
+ <div {...styles.list()}>
2267
+ {activity.map((name) => (
2268
+ <span key={name} {...styles.row()}>
2269
+ {name}
2270
+ </span>
2271
+ ))}
2272
+ </div>
2273
+ <div {...styles.scrim()} />
2274
+ <div {...styles.panel()}>
2275
+ <div {...styles.header()}>
2276
+ <span {...styles.title()}>Payment to Alex</span>
2277
+ <Button aria-label="Close" shape="icon" size="small" variant="tertiary">
2278
+ <Close />
2279
+ </Button>
2280
+ </div>
2281
+ {details.map((entry) => (
2282
+ <div key={entry.label} {...styles.detail()}>
2283
+ <span {...styles.label()}>{entry.label}</span>
2284
+ <span {...styles.value()}>{entry.value}</span>
2285
+ </div>
2286
+ ))}
2287
+ </div>
2288
+ </div>
2289
+ )
2290
+ }
2291
+
2292
+ namespace styles {
2293
+ export const detail = style({ display: 'flex', flexDirection: 'column', rowGap: '2px !custom' })
2294
+
2295
+ export const frame = style({
2296
+ backgroundColor: 'background.primary',
2297
+ borderColor: 'line.secondary',
2298
+ borderRadius: 'xs',
2299
+ borderStyle: 'solid',
2300
+ borderWidth: 'regular',
2301
+ boxSizing: 'border-box',
2302
+ height: '12rem !custom',
2303
+ overflow: 'hidden',
2304
+ position: 'relative',
2305
+ width: '18rem !custom',
2306
+ })
2307
+
2308
+ export const header = style({
2309
+ alignItems: 'center',
2310
+ columnGap: '4',
2311
+ display: 'flex',
2312
+ justifyContent: 'space-between',
2313
+ minHeight: '32',
2314
+ })
2315
+
2316
+ export const label = style({ color: 'content.secondary', typography: 'body.b3' })
2317
+
2318
+ export const list = style({
2319
+ display: 'flex',
2320
+ flexDirection: 'column',
2321
+ padding: '12',
2322
+ rowGap: '12',
2323
+ })
2324
+
2325
+ export const panel = style({
2326
+ backgroundColor: 'background.elevated',
2327
+ borderBottomLeftRadius: 'sm',
2328
+ borderTopLeftRadius: 'sm',
2329
+ boxSizing: 'border-box',
2330
+ display: 'flex',
2331
+ flexDirection: 'column',
2332
+ insetBlock: '0',
2333
+ insetInlineEnd: '0',
2334
+ padding: '16',
2335
+ position: 'absolute',
2336
+ rowGap: '12',
2337
+ width: '11rem !custom',
2338
+ })
2339
+
2340
+ export const row = style({ color: 'content.primary', typography: 'body.b3' })
2341
+
2342
+ export const scrim = style({
2343
+ backgroundColor: 'neutral.100',
2344
+ inset: '0',
2345
+ opacity: 'disabled',
2346
+ position: 'absolute',
2347
+ })
2348
+
2349
+ export const title = style({ color: 'content.primary', typography: 'body.b2Strong' })
2350
+
2351
+ export const value = style({ color: 'content.primary', typography: 'body.b3Strong' })
2352
+ }
2353
+ ```
2354
+
2355
+ **Don't:** Make a swipe or a backdrop press the only way out.
2356
+
2357
+ ```tsx
2358
+ /**
2359
+ * Don't example for "Always Render a Close Control" on the Drawer page.
2360
+ * Don't make a swipe or a backdrop press the only way out.
2361
+ * @module
2362
+ */
2363
+ import { style } from '@tempoxyz/ds'
2364
+
2365
+ const activity = ['Alex', 'Payroll', 'Ramen Bar', 'Sam']
2366
+
2367
+ const details = [
2368
+ { label: 'Amount', value: '250.00 USDC' },
2369
+ { label: 'To', value: '0x3c44…93bc' },
2370
+ ]
2371
+
2372
+ /** Renders the static preview, which the guideline card shows inert. */
2373
+ export function Demo() {
2374
+ return (
2375
+ <div {...styles.frame()}>
2376
+ <div {...styles.list()}>
2377
+ {activity.map((name) => (
2378
+ <span key={name} {...styles.row()}>
2379
+ {name}
2380
+ </span>
2381
+ ))}
2382
+ </div>
2383
+ <div {...styles.scrim()} />
2384
+ <div {...styles.panel()}>
2385
+ <div {...styles.header()}>
2386
+ <span {...styles.title()}>Payment to Alex</span>
2387
+ </div>
2388
+ {details.map((entry) => (
2389
+ <div key={entry.label} {...styles.detail()}>
2390
+ <span {...styles.label()}>{entry.label}</span>
2391
+ <span {...styles.value()}>{entry.value}</span>
2392
+ </div>
2393
+ ))}
2394
+ </div>
2395
+ </div>
2396
+ )
2397
+ }
2398
+
2399
+ namespace styles {
2400
+ export const detail = style({ display: 'flex', flexDirection: 'column', rowGap: '2px !custom' })
2401
+
2402
+ export const frame = style({
2403
+ backgroundColor: 'background.primary',
2404
+ borderColor: 'line.secondary',
2405
+ borderRadius: 'xs',
2406
+ borderStyle: 'solid',
2407
+ borderWidth: 'regular',
2408
+ boxSizing: 'border-box',
2409
+ height: '12rem !custom',
2410
+ overflow: 'hidden',
2411
+ position: 'relative',
2412
+ width: '18rem !custom',
2413
+ })
2414
+
2415
+ export const header = style({
2416
+ alignItems: 'center',
2417
+ columnGap: '4',
2418
+ display: 'flex',
2419
+ justifyContent: 'space-between',
2420
+ minHeight: '32',
2421
+ })
2422
+
2423
+ export const label = style({ color: 'content.secondary', typography: 'body.b3' })
2424
+
2425
+ export const list = style({
2426
+ display: 'flex',
2427
+ flexDirection: 'column',
2428
+ padding: '12',
2429
+ rowGap: '12',
2430
+ })
2431
+
2432
+ export const panel = style({
2433
+ backgroundColor: 'background.elevated',
2434
+ borderBottomLeftRadius: 'sm',
2435
+ borderTopLeftRadius: 'sm',
2436
+ boxSizing: 'border-box',
2437
+ display: 'flex',
2438
+ flexDirection: 'column',
2439
+ insetBlock: '0',
2440
+ insetInlineEnd: '0',
2441
+ padding: '16',
2442
+ position: 'absolute',
2443
+ rowGap: '12',
2444
+ width: '11rem !custom',
2445
+ })
2446
+
2447
+ export const row = style({ color: 'content.primary', typography: 'body.b3' })
2448
+
2449
+ export const scrim = style({
2450
+ backgroundColor: 'neutral.100',
2451
+ inset: '0',
2452
+ opacity: 'disabled',
2453
+ position: 'absolute',
2454
+ })
2455
+
2456
+ export const title = style({ color: 'content.primary', typography: 'body.b2Strong' })
2457
+
2458
+ export const value = style({ color: 'content.primary', typography: 'body.b3Strong' })
2459
+ }
2460
+ ```
2461
+
2462
+ #### Center the Body of a Bottom Sheet
2463
+
2464
+ A `down` drawer spans the viewport width. Wrap its body in `Drawer.Content` to center it at up to 32rem. Mouse and pen drags inside it select text and don't move the drawer.
2465
+
2466
+ **Do:** Center the body of a wide bottom sheet with `Drawer.Content`.
2467
+
2468
+ ```tsx
2469
+ /**
2470
+ * Do example for "Center the Body of a Bottom Sheet" on the Drawer page.
2471
+ * Center the body of a wide bottom sheet with `Drawer.Content`.
2472
+ * @module
2473
+ */
2474
+ import { Button, style } from '@tempoxyz/ds'
2475
+
2476
+ const details = [
2477
+ { label: 'Amount', value: '250.00 USDC' },
2478
+ { label: 'To', value: '0x3c44…93bc' },
2479
+ ]
2480
+
2481
+ /** Renders the static preview, which the guideline card shows inert. */
2482
+ export function Demo() {
2483
+ return (
2484
+ <div {...styles.frame()}>
2485
+ <div {...styles.scrim()} />
2486
+ <div {...styles.sheet()}>
2487
+ <div {...styles.content()}>
2488
+ <span {...styles.title()}>Payment to Alex</span>
2489
+ {details.map((entry) => (
2490
+ <div key={entry.label} {...styles.detail()}>
2491
+ <span {...styles.label()}>{entry.label}</span>
2492
+ <span {...styles.value()}>{entry.value}</span>
2493
+ </div>
2494
+ ))}
2495
+ <Button size="small" variant="secondary">
2496
+ Share receipt
2497
+ </Button>
2498
+ </div>
2499
+ </div>
2500
+ </div>
2501
+ )
2502
+ }
2503
+
2504
+ namespace styles {
2505
+ // Drawer.Content centers the body at up to 32rem, drawn here at the preview's scale.
2506
+ export const content = style({
2507
+ display: 'flex',
2508
+ flexDirection: 'column',
2509
+ marginInline: 'auto !custom',
2510
+ maxWidth: '11rem !custom',
2511
+ rowGap: '8',
2512
+ })
2513
+
2514
+ export const detail = style({
2515
+ display: 'flex',
2516
+ justifyContent: 'space-between',
2517
+ })
2518
+
2519
+ export const frame = style({
2520
+ backgroundColor: 'background.primary',
2521
+ borderColor: 'line.secondary',
2522
+ borderRadius: 'xs',
2523
+ borderStyle: 'solid',
2524
+ borderWidth: 'regular',
2525
+ boxSizing: 'border-box',
2526
+ height: '12rem !custom',
2527
+ overflow: 'hidden',
2528
+ position: 'relative',
2529
+ width: '20rem !custom',
2530
+ })
2531
+
2532
+ export const label = style({ color: 'content.secondary', typography: 'body.b3' })
2533
+
2534
+ export const scrim = style({
2535
+ backgroundColor: 'neutral.100',
2536
+ inset: '0',
2537
+ opacity: 'disabled',
2538
+ position: 'absolute',
2539
+ })
2540
+
2541
+ export const sheet = style({
2542
+ backgroundColor: 'background.elevated',
2543
+ borderTopLeftRadius: 'sm',
2544
+ borderTopRightRadius: 'sm',
2545
+ bottom: '0',
2546
+ boxSizing: 'border-box',
2547
+ insetInline: '0',
2548
+ padding: '16',
2549
+ position: 'absolute',
2550
+ })
2551
+
2552
+ export const title = style({ color: 'content.primary', typography: 'body.b2Strong' })
2553
+
2554
+ export const value = style({ color: 'content.primary', typography: 'body.b3Strong' })
2555
+ }
2556
+ ```
2557
+
2558
+ **Don't:** Stretch the body across the full width of the viewport.
2559
+
2560
+ ```tsx
2561
+ /**
2562
+ * Don't example for "Center the Body of a Bottom Sheet" on the Drawer page.
2563
+ * Don't stretch the body across the full width of the viewport.
2564
+ * @module
2565
+ */
2566
+ import { Button, style } from '@tempoxyz/ds'
2567
+
2568
+ const details = [
2569
+ { label: 'Amount', value: '250.00 USDC' },
2570
+ { label: 'To', value: '0x3c44…93bc' },
2571
+ ]
2572
+
2573
+ /** Renders the static preview, which the guideline card shows inert. */
2574
+ export function Demo() {
2575
+ return (
2576
+ <div {...styles.frame()}>
2577
+ <div {...styles.scrim()} />
2578
+ <div {...styles.sheet()}>
2579
+ <div {...styles.content()}>
2580
+ <span {...styles.title()}>Payment to Alex</span>
2581
+ {details.map((entry) => (
2582
+ <div key={entry.label} {...styles.detail()}>
2583
+ <span {...styles.label()}>{entry.label}</span>
2584
+ <span {...styles.value()}>{entry.value}</span>
2585
+ </div>
2586
+ ))}
2587
+ <Button size="small" variant="secondary">
2588
+ Share receipt
2589
+ </Button>
2590
+ </div>
2591
+ </div>
2592
+ </div>
2593
+ )
2594
+ }
2595
+
2596
+ namespace styles {
2597
+ export const content = style({ display: 'flex', flexDirection: 'column', rowGap: '8' })
2598
+
2599
+ export const detail = style({
2600
+ display: 'flex',
2601
+ justifyContent: 'space-between',
2602
+ })
2603
+
2604
+ export const frame = style({
2605
+ backgroundColor: 'background.primary',
2606
+ borderColor: 'line.secondary',
2607
+ borderRadius: 'xs',
2608
+ borderStyle: 'solid',
2609
+ borderWidth: 'regular',
2610
+ boxSizing: 'border-box',
2611
+ height: '12rem !custom',
2612
+ overflow: 'hidden',
2613
+ position: 'relative',
2614
+ width: '20rem !custom',
2615
+ })
2616
+
2617
+ export const label = style({ color: 'content.secondary', typography: 'body.b3' })
2618
+
2619
+ export const scrim = style({
2620
+ backgroundColor: 'neutral.100',
2621
+ inset: '0',
2622
+ opacity: 'disabled',
2623
+ position: 'absolute',
2624
+ })
2625
+
2626
+ export const sheet = style({
2627
+ backgroundColor: 'background.elevated',
2628
+ borderTopLeftRadius: 'sm',
2629
+ borderTopRightRadius: 'sm',
2630
+ bottom: '0',
2631
+ boxSizing: 'border-box',
2632
+ insetInline: '0',
2633
+ padding: '16',
2634
+ position: 'absolute',
2635
+ })
2636
+
2637
+ export const title = style({ color: 'content.primary', typography: 'body.b2Strong' })
2638
+
2639
+ export const value = style({ color: 'content.primary', typography: 'body.b3Strong' })
2640
+ }
2641
+ ```
2642
+
2643
+ #### Keep the Main Action in Reach
2644
+
2645
+ The popup scrolls on overflow. Put the main action at the end, and keep a bottom sheet short enough to show it without scrolling.
2646
+
2647
+ **Do:** Keep the bottom sheet short enough to show its main action.
2648
+
2649
+ ```tsx
2650
+ /**
2651
+ * Do example for "Keep the Main Action in Reach" on the Drawer page.
2652
+ * Keep the bottom sheet short enough to show its main action.
2653
+ * @module
2654
+ */
2655
+ import { Button, style } from '@tempoxyz/ds'
2656
+
2657
+ const details = [
2658
+ { label: 'Amount', value: '250.00 USDC' },
2659
+ { label: 'To', value: '0x3c44…93bc' },
2660
+ { label: 'Fee', value: '0.01 USDC' },
2661
+ ]
2662
+
2663
+ /** Renders the static preview, which the guideline card shows inert. */
2664
+ export function Demo() {
2665
+ return (
2666
+ <div {...styles.frame()}>
2667
+ <div {...styles.scrim()} />
2668
+ <div {...styles.sheet()}>
2669
+ <span {...styles.title()}>Review payment</span>
2670
+ {details.map((entry) => (
2671
+ <div key={entry.label} {...styles.detail()}>
2672
+ <span {...styles.label()}>{entry.label}</span>
2673
+ <span {...styles.value()}>{entry.value}</span>
2674
+ </div>
2675
+ ))}
2676
+ <Button size="small">Send payment</Button>
2677
+ </div>
2678
+ </div>
2679
+ )
2680
+ }
2681
+
2682
+ namespace styles {
2683
+ export const detail = style({ display: 'flex', justifyContent: 'space-between' })
2684
+
2685
+ export const frame = style({
2686
+ backgroundColor: 'background.primary',
2687
+ borderColor: 'line.secondary',
2688
+ borderRadius: 'xs',
2689
+ borderStyle: 'solid',
2690
+ borderWidth: 'regular',
2691
+ boxSizing: 'border-box',
2692
+ height: '14rem !custom',
2693
+ overflow: 'hidden',
2694
+ position: 'relative',
2695
+ width: '12rem !custom',
2696
+ })
2697
+
2698
+ export const label = style({ color: 'content.secondary', typography: 'body.b3' })
2699
+
2700
+ export const scrim = style({
2701
+ backgroundColor: 'neutral.100',
2702
+ inset: '0',
2703
+ opacity: 'disabled',
2704
+ position: 'absolute',
2705
+ })
2706
+
2707
+ export const sheet = style({
2708
+ backgroundColor: 'background.elevated',
2709
+ borderTopLeftRadius: 'sm',
2710
+ borderTopRightRadius: 'sm',
2711
+ bottom: '0',
2712
+ boxSizing: 'border-box',
2713
+ display: 'flex',
2714
+ flexDirection: 'column',
2715
+ insetInline: '0',
2716
+ padding: '16',
2717
+ position: 'absolute',
2718
+ rowGap: '8',
2719
+ })
2720
+
2721
+ export const title = style({ color: 'content.primary', typography: 'body.b2Strong' })
2722
+
2723
+ export const value = style({ color: 'content.primary', typography: 'body.b3Strong' })
2724
+ }
2725
+ ```
2726
+
2727
+ **Don't:** Push the main action below the fold of a tall sheet.
2728
+
2729
+ ```tsx
2730
+ /**
2731
+ * Don't example for "Keep the Main Action in Reach" on the Drawer page.
2732
+ * Don't push the main action below the fold of a tall sheet.
2733
+ * @module
2734
+ */
2735
+ import { Button, style } from '@tempoxyz/ds'
2736
+
2737
+ const details = [
2738
+ { label: 'Amount', value: '250.00 USDC' },
2739
+ { label: 'To', value: '0x3c44…93bc' },
2740
+ { label: 'Fee', value: '0.01 USDC' },
2741
+ { label: 'From', value: 'Main wallet' },
2742
+ { label: 'Network', value: 'Tempo' },
2743
+ { label: 'Memo', value: 'Invoice 1042' },
2744
+ { label: 'Arrives', value: 'Instantly' },
2745
+ ]
2746
+
2747
+ /** Renders the static preview, which the guideline card shows inert. */
2748
+ export function Demo() {
2749
+ return (
2750
+ <div {...styles.frame()}>
2751
+ <div {...styles.scrim()} />
2752
+ <div {...styles.sheet()}>
2753
+ <span {...styles.title()}>Review payment</span>
2754
+ {details.map((entry) => (
2755
+ <div key={entry.label} {...styles.detail()}>
2756
+ <span {...styles.label()}>{entry.label}</span>
2757
+ <span {...styles.value()}>{entry.value}</span>
2758
+ </div>
2759
+ ))}
2760
+ <Button size="small">Send payment</Button>
2761
+ </div>
2762
+ </div>
2763
+ )
2764
+ }
2765
+
2766
+ namespace styles {
2767
+ export const detail = style({ display: 'flex', justifyContent: 'space-between' })
2768
+
2769
+ export const frame = style({
2770
+ backgroundColor: 'background.primary',
2771
+ borderColor: 'line.secondary',
2772
+ borderRadius: 'xs',
2773
+ borderStyle: 'solid',
2774
+ borderWidth: 'regular',
2775
+ boxSizing: 'border-box',
2776
+ height: '14rem !custom',
2777
+ overflow: 'hidden',
2778
+ position: 'relative',
2779
+ width: '12rem !custom',
2780
+ })
2781
+
2782
+ export const label = style({ color: 'content.secondary', typography: 'body.b3' })
2783
+
2784
+ export const scrim = style({
2785
+ backgroundColor: 'neutral.100',
2786
+ inset: '0',
2787
+ opacity: 'disabled',
2788
+ position: 'absolute',
2789
+ })
2790
+
2791
+ export const sheet = style({
2792
+ backgroundColor: 'background.elevated',
2793
+ borderTopLeftRadius: 'sm',
2794
+ borderTopRightRadius: 'sm',
2795
+ boxSizing: 'border-box',
2796
+ display: 'flex',
2797
+ flexDirection: 'column',
2798
+ insetInline: '0',
2799
+ padding: '16',
2800
+ position: 'absolute',
2801
+ rowGap: '8',
2802
+ top: '24',
2803
+ })
2804
+
2805
+ export const title = style({ color: 'content.primary', typography: 'body.b2Strong' })
2806
+
2807
+ export const value = style({ color: 'content.primary', typography: 'body.b3Strong' })
2808
+ }
2809
+ ```
2810
+
2811
+ ### Content
2812
+
2813
+ #### Name the Record or Task
2814
+
2815
+ Render a `Drawer.Title` that names the record or task, such as Payment to Alex or Filters.
2816
+
2817
+ ### Accessibility
2818
+
2819
+ A drawer is a modal dialog. It follows the [WAI-ARIA Authoring Practices modal dialog pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/).
2820
+
2821
+ #### Semantics
2822
+
2823
+ * **Drawer.Trigger (button):** Announces the dialog and whether it is open.
2824
+ * **Drawer.Popup (dialog):** Modal by default.
2825
+ * **Drawer.Title (h2):** Names the drawer.
2826
+ * **Drawer.Description (p):** Describes the drawer.
2827
+ * **Close Button (closeButton):** Adds an icon button named "Close".
2828
+ * **Page Behind (inert):** Ignores input and never scrolls with the drawer.
2829
+
2830
+ #### Keyboard
2831
+
2832
+ * **Open or Activate (Enter or Space):** Opens the drawer, or activates the focused control.
2833
+ * **Move to the Next Element (Tab):** Moves to the next element, and wraps.
2834
+ * **Move to the Previous Element (Shift+Tab):** Moves to the previous element, and wraps.
2835
+ * **Close the Drawer (Escape):** Closes the drawer.
2836
+
2837
+ #### Focus
2838
+
2839
+ * **Opening (initialFocus):** Moves to the panel, so a screen reader starts at its title.
2840
+ * **Trapping:** Focus stays inside while open.
2841
+ * **Backdrop and Swipe:** An outside press or a swipe to its edge closes the drawer.
2842
+ * **Closing (finalFocus):** Returns to the trigger, or to `finalFocus`.
2843
+
2844
+ #### Motion
2845
+
2846
+ * **Slide and Swipe (swipeDirection):** Slides in from its edge and follows a swipe.
2847
+ * **Reduced Motion (reduce):** Fades in and out instead of sliding.
2848
+
2849
+ #### Your Responsibilities
2850
+
2851
+ * **Render a Title (Drawer.Title):** Without it, the drawer has no accessible name.
2852
+ * **Name an Alternative to Gestures:** If instructions name a gesture, name a button too.
2853
+
2854
+ ### Related
2855
+
2856
+ [Dialog](#dialog)
2857
+
2858
+ Use for short, focused tasks.
2859
+
2860
+ [Popover](#popover)
2861
+
2862
+ Use for anchored content on wide screens.
2863
+
2864
+ [AppShell](layout.md#appshell)
2865
+
2866
+ Use for navigation that collapses into a drawer.
2867
+
2868
+ [Responsive Layout](../patterns.md#responsive-layout)
2869
+
2870
+ Covers switching layouts at narrow widths.
2871
+
2872
+ [Tables and Lists](../patterns.md#tables-and-lists)
2873
+
2874
+ Covers opening record details.
2875
+
2876
+ ### Examples
2877
+
2878
+ #### Basic
2879
+
2880
+ ```tsx
2881
+ import { Button, Drawer, style } from '@tempoxyz/ds'
2882
+
2883
+ export function Demo() {
2884
+ return (
2885
+ <Drawer.Root>
2886
+ <Drawer.Trigger render={<Button variant="secondary" />}>Open drawer</Drawer.Trigger>
2887
+ <Drawer.Popup closeButton>
2888
+ <Drawer.Content>
2889
+ <Drawer.Title>Filters</Drawer.Title>
2890
+ <Drawer.Description>Swipe down or press Escape to close.</Drawer.Description>
2891
+ <div {...styles.actions()}>
2892
+ <Drawer.Close render={<Button variant="secondary" />}>Close</Drawer.Close>
2893
+ </div>
2894
+ </Drawer.Content>
2895
+ </Drawer.Popup>
2896
+ </Drawer.Root>
2897
+ )
2898
+ }
2899
+
2900
+ namespace styles {
2901
+ export const actions = style({ display: 'flex', justifyContent: 'flex-end', marginTop: '32' })
2902
+ }
2903
+ ```
2904
+
2905
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Drawer/Basic.tsx)
2906
+
2907
+ #### SwipeDirection
2908
+
2909
+ Set `swipeDirection` on `Drawer.Root` to `down` (default, opens from the bottom), `up`, `left`, or `right`.
2910
+
2911
+ ```tsx
2912
+ import { Button, Drawer, style } from '@tempoxyz/ds'
2913
+
2914
+ const edges = { down: 'bottom', left: 'left', right: 'right', up: 'top' } as const
2915
+
2916
+ export function Demo() {
2917
+ return (
2918
+ <div {...styles.row()}>
2919
+ {(['down', 'right', 'left', 'up'] as const).map((direction) => (
2920
+ <Drawer.Root key={direction} swipeDirection={direction}>
2921
+ <Drawer.Trigger render={<Button variant="secondary" />}>
2922
+ Open from the {edges[direction]}
2923
+ </Drawer.Trigger>
2924
+ <Drawer.Popup closeButton>
2925
+ <Drawer.Content>
2926
+ <Drawer.Title>Filters</Drawer.Title>
2927
+ <Drawer.Description>Swipe {direction} or press Escape to close.</Drawer.Description>
2928
+ <div {...styles.actions()}>
2929
+ <Drawer.Close render={<Button variant="secondary" />}>Close</Drawer.Close>
2930
+ </div>
2931
+ </Drawer.Content>
2932
+ </Drawer.Popup>
2933
+ </Drawer.Root>
2934
+ ))}
2935
+ </div>
2936
+ )
2937
+ }
2938
+
2939
+ namespace styles {
2940
+ export const actions = style({ display: 'flex', justifyContent: 'flex-end', marginTop: '32' })
2941
+
2942
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
2943
+ }
2944
+ ```
2945
+
2946
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Drawer/SwipeDirection.tsx)
2947
+
2948
+ ## Menu
2949
+
2950
+ Opens a list of actions from a button.
2951
+
2952
+ [View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Menu.tsx)
2953
+
2954
+ Figma: [Navigation/Account Menu](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-3061) (`Menu.Popup`)
2955
+
2956
+ ### Overview
2957
+
2958
+ Menu renders a button that opens a list of actions and commands. Arrow keys move through the items, and Escape closes the list.
2959
+
2960
+ ### Anatomy
2961
+
2962
+ Import the component and assemble its parts.
2963
+
2964
+ ```tsx
2965
+ import { Menu } from '@tempoxyz/ds'
2966
+
2967
+ <Menu.Root>
2968
+ <Menu.Trigger />
2969
+ <Menu.Popup>
2970
+ <Menu.Item>
2971
+ <Menu.Shortcut />
2972
+ </Menu.Item>
2973
+ <Menu.LinkItem />
2974
+ <Menu.CheckboxItem />
2975
+ <Menu.Separator />
2976
+ <Menu.Group>
2977
+ <Menu.GroupLabel />
2978
+ <Menu.RadioGroup>
2979
+ <Menu.RadioItem />
2980
+ </Menu.RadioGroup>
2981
+ </Menu.Group>
2982
+ <Menu.SubmenuRoot>
2983
+ <Menu.SubmenuTrigger />
2984
+ <Menu.Popup />
2985
+ </Menu.SubmenuRoot>
2986
+ </Menu.Popup>
2987
+ </Menu.Root>
2988
+ ```
2989
+
2990
+ ### Guidelines
2991
+
2992
+ #### When to Use
2993
+
2994
+ * Offer actions on one object, such as Send to address, Copy address, Rename, and Remove address.
2995
+ * If a toolbar, card header, or table row has more than three secondary actions, put them behind an icon button.
2996
+ * Change view options in place with `Menu.CheckboxItem` (Show archived) or `Menu.RadioItem` (density). These items keep the menu open on click.
2997
+
2998
+ #### When Not to Use
2999
+
3000
+ * Use [Select](forms-and-inputs.md#select) or [Combobox](forms-and-inputs.md#combobox) to choose a form value, such as a token or network.
3001
+ * Use [Tabs](navigation.md#tabs) or [ChoiceGroup](forms-and-inputs.md#choicegroup) to switch views with every option visible.
3002
+ * Use a [Button](actions.md#button) for one or two actions.
3003
+ * Use [SplitButton](actions.md#splitbutton) when one action is the clear default.
3004
+ * Use [SidebarMenu](navigation.md#sidebarmenu) or links for navigation. `Menu.LinkItem` suits an occasional link among actions, such as View on explorer.
3005
+ * Use [Popover](#popover) for text or form controls. A menu holds only items.
3006
+
3007
+ #### Order Items by Frequency
3008
+
3009
+ Put the most frequent action at the top. Keep the same items in the same order wherever the menu appears, such as on every table row.
3010
+
3011
+ **Do:** Put the most frequent action at the top.
3012
+
3013
+ ```tsx
3014
+ /** Do example for "Order Items by Frequency" on the Menu page: put the most frequent action at the top. @module */
3015
+ import { style, variants } from '@tempoxyz/ds'
3016
+
3017
+ /** Renders the static preview, which the guideline card shows inert. */
3018
+ export function Demo() {
3019
+ return (
3020
+ <div {...styles.popup()}>
3021
+ <div {...styles.item()}>Send to address</div>
3022
+ <div {...styles.item()}>Copy address</div>
3023
+ <div {...styles.item()}>Rename</div>
3024
+ </div>
3025
+ )
3026
+ }
3027
+
3028
+ namespace styles {
3029
+ export const item = variants({
3030
+ base: {
3031
+ alignItems: 'center',
3032
+ borderRadius: 'xs',
3033
+ color: 'content.primary',
3034
+ columnGap: '8',
3035
+ display: 'flex',
3036
+ minHeight: '40',
3037
+ paddingInline: '12',
3038
+ typography: 'body.b2Strong',
3039
+ },
3040
+ defaultVariants: { state: 'default' },
3041
+ variants: {
3042
+ state: {
3043
+ default: {},
3044
+ disabled: { opacity: 'disabled' },
3045
+ negative: { color: 'content.negative' },
3046
+ },
3047
+ },
3048
+ })
3049
+
3050
+ export const popup = style({
3051
+ backgroundColor: 'background.elevated',
3052
+ borderRadius: 'sm',
3053
+ boxShadow: 'regular',
3054
+ boxSizing: 'border-box',
3055
+ minWidth: '14rem !custom',
3056
+ padding: '12',
3057
+ })
3058
+ }
3059
+ ```
3060
+
3061
+ **Don't:** Lead with a rare action, such as Rename.
3062
+
3063
+ ```tsx
3064
+ /**
3065
+ * Don't example for "Order Items by Frequency" on the Menu page.
3066
+ * Don't lead with a rare action, such as Rename.
3067
+ * @module
3068
+ */
3069
+ import { style, variants } from '@tempoxyz/ds'
3070
+
3071
+ /** Renders the static preview, which the guideline card shows inert. */
3072
+ export function Demo() {
3073
+ return (
3074
+ <div {...styles.popup()}>
3075
+ <div {...styles.item()}>Rename</div>
3076
+ <div {...styles.item()}>Copy address</div>
3077
+ <div {...styles.item()}>Send to address</div>
3078
+ </div>
3079
+ )
3080
+ }
3081
+
3082
+ namespace styles {
3083
+ export const item = variants({
3084
+ base: {
3085
+ alignItems: 'center',
3086
+ borderRadius: 'xs',
3087
+ color: 'content.primary',
3088
+ columnGap: '8',
3089
+ display: 'flex',
3090
+ minHeight: '40',
3091
+ paddingInline: '12',
3092
+ typography: 'body.b2Strong',
3093
+ },
3094
+ defaultVariants: { state: 'default' },
3095
+ variants: {
3096
+ state: {
3097
+ default: {},
3098
+ disabled: { opacity: 'disabled' },
3099
+ negative: { color: 'content.negative' },
3100
+ },
3101
+ },
3102
+ })
3103
+
3104
+ export const popup = style({
3105
+ backgroundColor: 'background.elevated',
3106
+ borderRadius: 'sm',
3107
+ boxShadow: 'regular',
3108
+ boxSizing: 'border-box',
3109
+ minWidth: '14rem !custom',
3110
+ padding: '12',
3111
+ })
3112
+ }
3113
+ ```
3114
+
3115
+ #### Group Related Items
3116
+
3117
+ Wrap related items in `Menu.Group` and divide groups with `Menu.Separator`. If the items alone do not explain the group, add a `Menu.GroupLabel`, such as Density.
3118
+
3119
+ Keep a menu to about seven items. A `Menu.SubmenuRoot` hides its items, so keep frequent actions at the top level and nest only one level deep.
3120
+
3121
+ **Do:** Divide groups with a separator, and label a group whose items need it.
3122
+
3123
+ ```tsx
3124
+ /**
3125
+ * Do example for "Group Related Items" on the Menu page.
3126
+ * Divide groups with a separator, and label a group whose items need it.
3127
+ * @module
3128
+ */
3129
+ import { Check } from '@tempoxyz/ds/icons'
3130
+ import { style, variants } from '@tempoxyz/ds'
3131
+
3132
+ /** Renders the static preview, which the guideline card shows inert. */
3133
+ export function Demo() {
3134
+ return (
3135
+ <div {...styles.popup()}>
3136
+ <div {...styles.item()}>Send to address</div>
3137
+ <div {...styles.item()}>Copy address</div>
3138
+ <div {...styles.separator()} />
3139
+ <div {...styles.groupLabel()}>Density</div>
3140
+ <div {...styles.item()}>
3141
+ Comfortable
3142
+ <Check {...styles.check()} />
3143
+ </div>
3144
+ <div {...styles.item()}>Compact</div>
3145
+ </div>
3146
+ )
3147
+ }
3148
+
3149
+ namespace styles {
3150
+ export const check = style({ fontSize: '16', marginInlineStart: 'auto !custom' })
3151
+
3152
+ export const groupLabel = style({
3153
+ color: 'content.secondary',
3154
+ paddingBlock: '8',
3155
+ paddingInline: '12',
3156
+ typography: 'body.b3',
3157
+ })
3158
+
3159
+ export const item = variants({
3160
+ base: {
3161
+ alignItems: 'center',
3162
+ borderRadius: 'xs',
3163
+ color: 'content.primary',
3164
+ columnGap: '8',
3165
+ display: 'flex',
3166
+ minHeight: '40',
3167
+ paddingInline: '12',
3168
+ typography: 'body.b2Strong',
3169
+ },
3170
+ defaultVariants: { state: 'default' },
3171
+ variants: {
3172
+ state: {
3173
+ default: {},
3174
+ disabled: { opacity: 'disabled' },
3175
+ negative: { color: 'content.negative' },
3176
+ },
3177
+ },
3178
+ })
3179
+
3180
+ export const popup = style({
3181
+ backgroundColor: 'background.elevated',
3182
+ borderRadius: 'sm',
3183
+ boxShadow: 'regular',
3184
+ boxSizing: 'border-box',
3185
+ minWidth: '14rem !custom',
3186
+ padding: '12',
3187
+ })
3188
+
3189
+ export const separator = style({
3190
+ backgroundColor: 'container.strong',
3191
+ height: '1px !custom',
3192
+ marginBlock: '8',
3193
+ marginInline: '12',
3194
+ })
3195
+ }
3196
+ ```
3197
+
3198
+ **Don't:** Mix actions and view options in one flat list.
3199
+
3200
+ ```tsx
3201
+ /**
3202
+ * Don't example for "Group Related Items" on the Menu page.
3203
+ * Don't mix actions and view options in one flat list.
3204
+ * @module
3205
+ */
3206
+ import { Check } from '@tempoxyz/ds/icons'
3207
+ import { style, variants } from '@tempoxyz/ds'
3208
+
3209
+ /** Renders the static preview, which the guideline card shows inert. */
3210
+ export function Demo() {
3211
+ return (
3212
+ <div {...styles.popup()}>
3213
+ <div {...styles.item()}>Send to address</div>
3214
+ <div {...styles.item()}>
3215
+ Comfortable
3216
+ <Check {...styles.check()} />
3217
+ </div>
3218
+ <div {...styles.item()}>Copy address</div>
3219
+ <div {...styles.item()}>Compact</div>
3220
+ </div>
3221
+ )
3222
+ }
3223
+
3224
+ namespace styles {
3225
+ export const check = style({ fontSize: '16', marginInlineStart: 'auto !custom' })
3226
+
3227
+ export const item = variants({
3228
+ base: {
3229
+ alignItems: 'center',
3230
+ borderRadius: 'xs',
3231
+ color: 'content.primary',
3232
+ columnGap: '8',
3233
+ display: 'flex',
3234
+ minHeight: '40',
3235
+ paddingInline: '12',
3236
+ typography: 'body.b2Strong',
3237
+ },
3238
+ defaultVariants: { state: 'default' },
3239
+ variants: {
3240
+ state: {
3241
+ default: {},
3242
+ disabled: { opacity: 'disabled' },
3243
+ negative: { color: 'content.negative' },
3244
+ },
3245
+ },
3246
+ })
3247
+
3248
+ export const popup = style({
3249
+ backgroundColor: 'background.elevated',
3250
+ borderRadius: 'sm',
3251
+ boxShadow: 'regular',
3252
+ boxSizing: 'border-box',
3253
+ minWidth: '14rem !custom',
3254
+ padding: '12',
3255
+ })
3256
+ }
3257
+ ```
3258
+
3259
+ #### Put Destructive Items Last
3260
+
3261
+ A keyboard open focuses the first item, so a destructive item at the top is one Enter press away. Place it last, after a `Menu.Separator`, with `intent="negative"`.
3262
+
3263
+ **Do:** Put destructive items at the end, after a separator.
3264
+
3265
+ ```tsx
3266
+ /**
3267
+ * Do example for "Put Destructive Items Last" on the Menu page.
3268
+ * Put destructive items at the end, after a separator.
3269
+ * @module
3270
+ */
3271
+ import { style, variants } from '@tempoxyz/ds'
3272
+
3273
+ /** Renders the static preview, which the guideline card shows inert. */
3274
+ export function Demo() {
3275
+ return (
3276
+ <div {...styles.popup()}>
3277
+ <div {...styles.item()}>Send to address</div>
3278
+ <div {...styles.item()}>Copy address</div>
3279
+ <div {...styles.item()}>Rename</div>
3280
+ <div {...styles.separator()} />
3281
+ <div {...styles.item({ intent: 'negative' })}>Remove address</div>
3282
+ </div>
3283
+ )
3284
+ }
3285
+
3286
+ namespace styles {
3287
+ export const item = variants({
3288
+ base: {
3289
+ alignItems: 'center',
3290
+ borderRadius: 'xs',
3291
+ color: 'content.primary',
3292
+ display: 'flex',
3293
+ minHeight: '40',
3294
+ paddingInline: '12',
3295
+ typography: 'body.b2Strong',
3296
+ },
3297
+ defaultVariants: { intent: 'default' },
3298
+ variants: {
3299
+ intent: {
3300
+ default: {},
3301
+ negative: { color: 'content.negative' },
3302
+ },
3303
+ },
3304
+ })
3305
+
3306
+ export const popup = style({
3307
+ backgroundColor: 'background.elevated',
3308
+ borderRadius: 'sm',
3309
+ boxShadow: 'regular',
3310
+ boxSizing: 'border-box',
3311
+ minWidth: '14rem !custom',
3312
+ padding: '12',
3313
+ })
3314
+
3315
+ export const separator = style({
3316
+ backgroundColor: 'container.strong',
3317
+ height: '1px !custom',
3318
+ marginBlock: '8',
3319
+ marginInline: '12',
3320
+ })
3321
+ }
3322
+ ```
3323
+
3324
+ **Don't:** Lead with a destructive item, or mix it in with routine actions.
3325
+
3326
+ ```tsx
3327
+ /**
3328
+ * Don't example for "Put Destructive Items Last" on the Menu page.
3329
+ * Don't lead with a destructive item, or mix it in with routine actions.
3330
+ * @module
3331
+ */
3332
+ import { style, variants } from '@tempoxyz/ds'
3333
+
3334
+ /** Renders the static preview, which the guideline card shows inert. */
3335
+ export function Demo() {
3336
+ return (
3337
+ <div {...styles.popup()}>
3338
+ <div {...styles.item({ intent: 'negative' })}>Remove address</div>
3339
+ <div {...styles.item()}>Send to address</div>
3340
+ <div {...styles.item()}>Copy address</div>
3341
+ <div {...styles.item()}>Rename</div>
3342
+ </div>
3343
+ )
3344
+ }
3345
+
3346
+ namespace styles {
3347
+ export const item = variants({
3348
+ base: {
3349
+ alignItems: 'center',
3350
+ borderRadius: 'xs',
3351
+ color: 'content.primary',
3352
+ display: 'flex',
3353
+ minHeight: '40',
3354
+ paddingInline: '12',
3355
+ typography: 'body.b2Strong',
3356
+ },
3357
+ defaultVariants: { intent: 'default' },
3358
+ variants: {
3359
+ intent: {
3360
+ default: {},
3361
+ negative: { color: 'content.negative' },
3362
+ },
3363
+ },
3364
+ })
3365
+
3366
+ export const popup = style({
3367
+ backgroundColor: 'background.elevated',
3368
+ borderRadius: 'sm',
3369
+ boxShadow: 'regular',
3370
+ boxSizing: 'border-box',
3371
+ minWidth: '14rem !custom',
3372
+ padding: '12',
3373
+ })
3374
+ }
3375
+ ```
3376
+
3377
+ If the action cannot be undone, open an [AlertDialog](#alertdialog) from the item and repeat the item's verb on its confirm button:
3378
+
3379
+ * **Placement:** Render the dialog outside `Menu.Popup`, which unmounts when the menu closes.
3380
+ * **State:** Open it from the item's `onClick` with `open` and `onOpenChange`.
3381
+
3382
+ See [Destructive Actions](../patterns.md#destructive-actions).
3383
+
3384
+ #### Disable Unavailable Items
3385
+
3386
+ Set `disabled` on an item that is unavailable now, such as Send to address with no funds. The menu keeps its shape. Leave out items that are never available, such as admin actions without the permission.
3387
+
3388
+ **Do:** Disable an item that is unavailable for now.
3389
+
3390
+ ```tsx
3391
+ /**
3392
+ * Do example for "Disable Unavailable Items" on the Menu page.
3393
+ * Disable an item that is unavailable for now.
3394
+ * @module
3395
+ */
3396
+ import { style, variants } from '@tempoxyz/ds'
3397
+
3398
+ /** Renders the static preview, which the guideline card shows inert. */
3399
+ export function Demo() {
3400
+ return (
3401
+ <div {...styles.popup()}>
3402
+ <div {...styles.item({ state: 'disabled' })}>Send to address</div>
3403
+ <div {...styles.item()}>Copy address</div>
3404
+ <div {...styles.item()}>Rename</div>
3405
+ <div {...styles.separator()} />
3406
+ <div {...styles.item({ state: 'negative' })}>Remove address</div>
3407
+ </div>
3408
+ )
3409
+ }
3410
+
3411
+ namespace styles {
3412
+ export const item = variants({
3413
+ base: {
3414
+ alignItems: 'center',
3415
+ borderRadius: 'xs',
3416
+ color: 'content.primary',
3417
+ columnGap: '8',
3418
+ display: 'flex',
3419
+ minHeight: '40',
3420
+ paddingInline: '12',
3421
+ typography: 'body.b2Strong',
3422
+ },
3423
+ defaultVariants: { state: 'default' },
3424
+ variants: {
3425
+ state: {
3426
+ default: {},
3427
+ disabled: { opacity: 'disabled' },
3428
+ negative: { color: 'content.negative' },
3429
+ },
3430
+ },
3431
+ })
3432
+
3433
+ export const popup = style({
3434
+ backgroundColor: 'background.elevated',
3435
+ borderRadius: 'sm',
3436
+ boxShadow: 'regular',
3437
+ boxSizing: 'border-box',
3438
+ minWidth: '14rem !custom',
3439
+ padding: '12',
3440
+ })
3441
+
3442
+ export const separator = style({
3443
+ backgroundColor: 'container.strong',
3444
+ height: '1px !custom',
3445
+ marginBlock: '8',
3446
+ marginInline: '12',
3447
+ })
3448
+ }
3449
+ ```
3450
+
3451
+ **Don't:** Remove an item that returns later. The menu changes shape.
3452
+
3453
+ ```tsx
3454
+ /**
3455
+ * Don't example for "Disable Unavailable Items" on the Menu page.
3456
+ * Don't remove an item that returns later. The menu changes shape.
3457
+ * @module
3458
+ */
3459
+ import { style, variants } from '@tempoxyz/ds'
3460
+
3461
+ /** Renders the static preview, which the guideline card shows inert. */
3462
+ export function Demo() {
3463
+ return (
3464
+ <div {...styles.popup()}>
3465
+ <div {...styles.item()}>Copy address</div>
3466
+ <div {...styles.item()}>Rename</div>
3467
+ <div {...styles.separator()} />
3468
+ <div {...styles.item({ state: 'negative' })}>Remove address</div>
3469
+ </div>
3470
+ )
3471
+ }
3472
+
3473
+ namespace styles {
3474
+ export const item = variants({
3475
+ base: {
3476
+ alignItems: 'center',
3477
+ borderRadius: 'xs',
3478
+ color: 'content.primary',
3479
+ columnGap: '8',
3480
+ display: 'flex',
3481
+ minHeight: '40',
3482
+ paddingInline: '12',
3483
+ typography: 'body.b2Strong',
3484
+ },
3485
+ defaultVariants: { state: 'default' },
3486
+ variants: {
3487
+ state: {
3488
+ default: {},
3489
+ disabled: { opacity: 'disabled' },
3490
+ negative: { color: 'content.negative' },
3491
+ },
3492
+ },
3493
+ })
3494
+
3495
+ export const popup = style({
3496
+ backgroundColor: 'background.elevated',
3497
+ borderRadius: 'sm',
3498
+ boxShadow: 'regular',
3499
+ boxSizing: 'border-box',
3500
+ minWidth: '14rem !custom',
3501
+ padding: '12',
3502
+ })
3503
+
3504
+ export const separator = style({
3505
+ backgroundColor: 'container.strong',
3506
+ height: '1px !custom',
3507
+ marginBlock: '8',
3508
+ marginInline: '12',
3509
+ })
3510
+ }
3511
+ ```
3512
+
3513
+ #### Show Only Shortcuts You Bind
3514
+
3515
+ `Menu.Shortcut` displays keys and binds nothing. Add one only if the shortcut also works with the menu closed, and register the key handler yourself.
3516
+
3517
+ **Do:** Show a shortcut only on an item whose key you bind.
3518
+
3519
+ ```tsx
3520
+ /**
3521
+ * Do example for "Show Only Shortcuts You Bind" on the Menu page.
3522
+ * Show a shortcut only on an item whose key you bind.
3523
+ * @module
3524
+ */
3525
+ import { style, variants } from '@tempoxyz/ds'
3526
+
3527
+ /** Renders the static preview, which the guideline card shows inert. */
3528
+ export function Demo() {
3529
+ return (
3530
+ <div {...styles.popup()}>
3531
+ <div {...styles.item()}>Send to address</div>
3532
+ <div {...styles.item()}>
3533
+ Copy address
3534
+ <kbd {...styles.shortcut()}>⌘C</kbd>
3535
+ </div>
3536
+ <div {...styles.item()}>Rename</div>
3537
+ </div>
3538
+ )
3539
+ }
3540
+
3541
+ namespace styles {
3542
+ export const item = variants({
3543
+ base: {
3544
+ alignItems: 'center',
3545
+ borderRadius: 'xs',
3546
+ color: 'content.primary',
3547
+ columnGap: '8',
3548
+ display: 'flex',
3549
+ minHeight: '40',
3550
+ paddingInline: '12',
3551
+ typography: 'body.b2Strong',
3552
+ },
3553
+ defaultVariants: { state: 'default' },
3554
+ variants: {
3555
+ state: {
3556
+ default: {},
3557
+ disabled: { opacity: 'disabled' },
3558
+ negative: { color: 'content.negative' },
3559
+ },
3560
+ },
3561
+ })
3562
+
3563
+ export const popup = style({
3564
+ backgroundColor: 'background.elevated',
3565
+ borderRadius: 'sm',
3566
+ boxShadow: 'regular',
3567
+ boxSizing: 'border-box',
3568
+ minWidth: '14rem !custom',
3569
+ padding: '12',
3570
+ })
3571
+
3572
+ export const shortcut = style({
3573
+ color: 'content.secondary',
3574
+ marginInlineStart: 'auto !custom',
3575
+ paddingInlineStart: '16',
3576
+ typography: 'body.b3',
3577
+ })
3578
+ }
3579
+ ```
3580
+
3581
+ **Don't:** Decorate every item with a shortcut that does nothing.
3582
+
3583
+ ```tsx
3584
+ /**
3585
+ * Don't example for "Show Only Shortcuts You Bind" on the Menu page.
3586
+ * Don't decorate every item with a shortcut that does nothing.
3587
+ * @module
3588
+ */
3589
+ import { style, variants } from '@tempoxyz/ds'
3590
+
3591
+ /** Renders the static preview, which the guideline card shows inert. */
3592
+ export function Demo() {
3593
+ return (
3594
+ <div {...styles.popup()}>
3595
+ <div {...styles.item()}>
3596
+ Send to address
3597
+ <kbd {...styles.shortcut()}>⌘S</kbd>
3598
+ </div>
3599
+ <div {...styles.item()}>
3600
+ Copy address
3601
+ <kbd {...styles.shortcut()}>⌘C</kbd>
3602
+ </div>
3603
+ <div {...styles.item()}>
3604
+ Rename
3605
+ <kbd {...styles.shortcut()}>⌘R</kbd>
3606
+ </div>
3607
+ </div>
3608
+ )
3609
+ }
3610
+
3611
+ namespace styles {
3612
+ export const item = variants({
3613
+ base: {
3614
+ alignItems: 'center',
3615
+ borderRadius: 'xs',
3616
+ color: 'content.primary',
3617
+ columnGap: '8',
3618
+ display: 'flex',
3619
+ minHeight: '40',
3620
+ paddingInline: '12',
3621
+ typography: 'body.b2Strong',
3622
+ },
3623
+ defaultVariants: { state: 'default' },
3624
+ variants: {
3625
+ state: {
3626
+ default: {},
3627
+ disabled: { opacity: 'disabled' },
3628
+ negative: { color: 'content.negative' },
3629
+ },
3630
+ },
3631
+ })
3632
+
3633
+ export const popup = style({
3634
+ backgroundColor: 'background.elevated',
3635
+ borderRadius: 'sm',
3636
+ boxShadow: 'regular',
3637
+ boxSizing: 'border-box',
3638
+ minWidth: '14rem !custom',
3639
+ padding: '12',
3640
+ })
3641
+
3642
+ export const shortcut = style({
3643
+ color: 'content.secondary',
3644
+ marginInlineStart: 'auto !custom',
3645
+ paddingInlineStart: '16',
3646
+ typography: 'body.b3',
3647
+ })
3648
+ }
3649
+ ```
3650
+
3651
+ ### Content
3652
+
3653
+ #### Start Items With a Verb
3654
+
3655
+ Write a verb, plus an object when the verb is ambiguous: Copy address, Rename, Remove address.
3656
+
3657
+ #### Lead With the Distinctive Word
3658
+
3659
+ Typing jumps to the item whose label starts with the typed characters. Start labels with different words. If an item's text starts with something else, such as a token symbol, pass `label`.
3660
+
3661
+ #### Name Destructive Items Plainly
3662
+
3663
+ `intent="negative"` only changes the color. Write a verb that states the loss, such as Remove address or Revoke key.
3664
+
3665
+ ### Accessibility
3666
+
3667
+ Menu follows the [WAI-ARIA Authoring Practices menu button pattern](https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/).
3668
+
3669
+ #### Semantics
3670
+
3671
+ * **Menu.Trigger (button):** Announces a menu popup and its expanded state.
3672
+ * **Menu.Popup (menu):** Named by its trigger.
3673
+ * **Menu.Item and Menu.LinkItem (menuitem):** Menu items, and link items render real links.
3674
+ * **Menu.CheckboxItem and Menu.RadioItem (aria-checked):** Checkable items that report their checked state.
3675
+ * **Menu.Group (group):** Named by its group label.
3676
+ * **Menu.Separator (separator):** Announced as a divider between groups of items.
3677
+ * **Disabled Items (aria-disabled):** Reachable with arrow keys, but never activates.
3678
+ * **Menu.Shortcut (kbd):** Displays the keys as text.
3679
+
3680
+ #### Keyboard
3681
+
3682
+ * **Open the Menu (Enter, Space, or Down Arrow):** Opens the menu from the trigger and focuses the first item.
3683
+ * **Move to the Next Item (Down Arrow):** Moves focus to the next item, wrapping from the last item to the first.
3684
+ * **Move to the Previous Item (Up Arrow):** Moves focus to the previous item, wrapping from the first item to the last.
3685
+ * **Move to the First Item (Home):** Moves focus to the first item.
3686
+ * **Move to the Last Item (End):** Moves focus to the last item.
3687
+ * **Type to Jump (Any character):** Moves focus to the next item whose label starts with the typed characters.
3688
+ * **Activate an Item (Enter):** Activates the focused item. Plain items close the menu. Checkbox and radio items keep it open.
3689
+ * **Open a Submenu (Right Arrow):** On a submenu trigger, opens the submenu and focuses its first item.
3690
+ * **Close a Submenu (Left Arrow):** In a submenu, closes it and returns focus to its trigger.
3691
+ * **Close the Menu (Escape):** Closes the menu and returns focus to the trigger.
3692
+ * **Leave the Menu (Tab):** Closes the menu and moves focus onward from it.
3693
+
3694
+ #### Focus
3695
+
3696
+ * **Opening:** A keyboard open focuses the first item. A click focuses the menu, and arrow keys then move to an item.
3697
+ * **Highlight:** One item at a time holds focus and renders highlighted.
3698
+ * **Modal (modal):** The default. A press outside closes the menu.
3699
+ * **Closing (Escape):** Activating an item, pressing Escape, or pressing outside returns focus to the trigger.
3700
+
3701
+ #### Your Responsibilities
3702
+
3703
+ * **Name Icon-Only Triggers (aria-label):** Name the object, such as "Actions for Main wallet". The menu inherits the trigger's name.
3704
+ * **Keep Links as Links (a):** Use `Menu.LinkItem` for navigation. It keeps link semantics.
3705
+
3706
+ ### Related
3707
+
3708
+ [SplitButton](actions.md#splitbutton)
3709
+
3710
+ Use for a main action with alternatives.
3711
+
3712
+ [Select](forms-and-inputs.md#select)
3713
+
3714
+ Use for choosing a form value.
3715
+
3716
+ [AlertDialog](#alertdialog)
3717
+
3718
+ Use for confirming a destructive item.
3719
+
3720
+ [Popover](#popover)
3721
+
3722
+ Use for anchored content other than actions.
3723
+
3724
+ [Destructive Actions](../patterns.md#destructive-actions)
3725
+
3726
+ Covers deleting and revoking.
3727
+
3728
+ [Tables and Lists](../patterns.md#tables-and-lists)
3729
+
3730
+ Covers row actions.
3731
+
3732
+ ### Examples
3733
+
3734
+ #### Basic
3735
+
3736
+ ```tsx
3737
+ import { Button, Menu, style } from '@tempoxyz/ds'
3738
+
3739
+ export function Demo() {
3740
+ // The gallery canvas stretches its children, so the wrapper keeps the trigger at its own width.
3741
+ return (
3742
+ <div {...styles.row()}>
3743
+ <Menu.Root>
3744
+ <Menu.Trigger render={<Button variant="secondary" />}>Options</Menu.Trigger>
3745
+ <Menu.Popup align="start">
3746
+ <Menu.Item>
3747
+ Edit
3748
+ <Menu.Shortcut>⌘E</Menu.Shortcut>
3749
+ </Menu.Item>
3750
+ <Menu.Item>Duplicate</Menu.Item>
3751
+ <Menu.Separator />
3752
+ <Menu.Item>Archive</Menu.Item>
3753
+ </Menu.Popup>
3754
+ </Menu.Root>
3755
+ </div>
3756
+ )
3757
+ }
3758
+
3759
+ namespace styles {
3760
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
3761
+ }
3762
+ ```
3763
+
3764
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Menu/Basic.tsx)
3765
+
3766
+ #### Size
3767
+
3768
+ Set `size` on `Menu.Popup` to `small`, `medium` (default), or `large`.
3769
+
3770
+ ```tsx
3771
+ import { Button, Menu, style } from '@tempoxyz/ds'
3772
+ import { useState } from 'react'
3773
+
3774
+ export function Demo() {
3775
+ const [density, setDensity] = useState('comfortable')
3776
+
3777
+ // The gallery canvas stretches its children, so the wrapper keeps each trigger at its own width.
3778
+ return (
3779
+ <div {...styles.row()}>
3780
+ {(['small', 'medium', 'large'] as const).map((size) => (
3781
+ <Menu.Root key={size}>
3782
+ <Menu.Trigger render={<Button size={size} variant="secondary" />}>
3783
+ Options ({size})
3784
+ </Menu.Trigger>
3785
+ <Menu.Popup align="start" size={size}>
3786
+ <Menu.Item>
3787
+ Edit
3788
+ <Menu.Shortcut>⌘E</Menu.Shortcut>
3789
+ </Menu.Item>
3790
+ <Menu.Item disabled>Duplicate</Menu.Item>
3791
+ <Menu.LinkItem href="https://tempo.xyz">Documentation</Menu.LinkItem>
3792
+ <Menu.Separator />
3793
+ <Menu.CheckboxItem defaultChecked>Show archived</Menu.CheckboxItem>
3794
+ <Menu.Group>
3795
+ <Menu.GroupLabel>Density</Menu.GroupLabel>
3796
+ <Menu.RadioGroup onValueChange={(value) => setDensity(String(value))} value={density}>
3797
+ <Menu.RadioItem value="comfortable">Comfortable</Menu.RadioItem>
3798
+ <Menu.RadioItem value="compact">Compact</Menu.RadioItem>
3799
+ </Menu.RadioGroup>
3800
+ </Menu.Group>
3801
+ <Menu.Separator />
3802
+ <Menu.SubmenuRoot>
3803
+ <Menu.SubmenuTrigger>Share</Menu.SubmenuTrigger>
3804
+ <Menu.Popup size={size}>
3805
+ <Menu.Item>Copy link</Menu.Item>
3806
+ <Menu.Item>Email</Menu.Item>
3807
+ </Menu.Popup>
3808
+ </Menu.SubmenuRoot>
3809
+ <Menu.Item intent="negative">Delete</Menu.Item>
3810
+ </Menu.Popup>
3811
+ </Menu.Root>
3812
+ ))}
3813
+ </div>
3814
+ )
3815
+ }
3816
+
3817
+ namespace styles {
3818
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
3819
+ }
3820
+ ```
3821
+
3822
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Menu/Size.tsx)
3823
+
3824
+ #### Intent
3825
+
3826
+ Set `intent="negative"` on a `Menu.Item` for destructive actions. The default is `default`.
3827
+
3828
+ ```tsx
3829
+ import { Button, Menu, style } from '@tempoxyz/ds'
3830
+
3831
+ export function Demo() {
3832
+ // The gallery canvas stretches its children, so the wrapper keeps the trigger at its own width.
3833
+ return (
3834
+ <div {...styles.row()}>
3835
+ <Menu.Root>
3836
+ <Menu.Trigger render={<Button variant="secondary" />}>Options</Menu.Trigger>
3837
+ <Menu.Popup align="start">
3838
+ <Menu.Item>Edit</Menu.Item>
3839
+ <Menu.Separator />
3840
+ <Menu.Item intent="negative">Delete</Menu.Item>
3841
+ </Menu.Popup>
3842
+ </Menu.Root>
3843
+ </div>
3844
+ )
3845
+ }
3846
+
3847
+ namespace styles {
3848
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
3849
+ }
3850
+ ```
3851
+
3852
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Menu/Intent.tsx)
3853
+
3854
+ #### Disabled
3855
+
3856
+ Set `disabled` on a `Menu.Item` to make it unavailable.
3857
+
3858
+ ```tsx
3859
+ import { Button, Menu, style } from '@tempoxyz/ds'
3860
+
3861
+ export function Demo() {
3862
+ // The gallery canvas stretches its children, so the wrapper keeps the trigger at its own width.
3863
+ return (
3864
+ <div {...styles.row()}>
3865
+ <Menu.Root>
3866
+ <Menu.Trigger render={<Button variant="secondary" />}>Options</Menu.Trigger>
3867
+ <Menu.Popup align="start">
3868
+ <Menu.Item>Edit</Menu.Item>
3869
+ <Menu.Item disabled>Duplicate</Menu.Item>
3870
+ </Menu.Popup>
3871
+ </Menu.Root>
3872
+ </div>
3873
+ )
3874
+ }
3875
+
3876
+ namespace styles {
3877
+ export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
3878
+ }
3879
+ ```
3880
+
3881
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Menu/Disabled.tsx)
3882
+
3883
+ ## Popover
3884
+
3885
+ Opens a non-modal popup anchored to a trigger.
3886
+
3887
+ [View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Popover.tsx)
3888
+
3889
+ ### Overview
3890
+
3891
+ Popover renders a non-modal dialog anchored to a trigger, opened on click, for interactive or longer content.
3892
+
3893
+ ### Anatomy
3894
+
3895
+ Import the component and assemble its parts.
3896
+
3897
+ ```tsx
3898
+ import { Popover } from '@tempoxyz/ds'
3899
+
3900
+ <Popover.Root>
3901
+ <Popover.Trigger />
3902
+ <Popover.Popup>
3903
+ <Popover.Arrow />
3904
+ <Popover.Title />
3905
+ <Popover.Description />
3906
+ <Popover.Close />
3907
+ </Popover.Popup>
3908
+ </Popover.Root>
3909
+ ```
3910
+
3911
+ ### Guidelines
3912
+
3913
+ #### When to Use
3914
+
3915
+ * Explain a value with a sentence and a link, such as the methodology behind a throughput tile.
3916
+ * Show details on demand, such as the breakdown of a network fee.
3917
+ * Edit one setting in place, such as the label of a saved address.
3918
+
3919
+ #### When Not to Use
3920
+
3921
+ * Use a [Tooltip](#tooltip) for a short label on an icon button.
3922
+ * Use a [Menu](#menu) for a list of actions.
3923
+ * Use [Select](forms-and-inputs.md#select), [Combobox](forms-and-inputs.md#combobox), or [DatePicker](forms-and-inputs.md#datepicker) to choose a value.
3924
+ * Use a [Dialog](#dialog) for a task with several fields or full attention.
3925
+ * Use a [Drawer](#drawer) for long content.
3926
+ * Use visible text for information everyone needs, such as an error or a required step.
3927
+
3928
+ #### Keep Content Small
3929
+
3930
+ A popover holds a title, a sentence or two, and at most two controls. `Popover.Popup` grows up to the available width, so give text popovers a `maxWidth`, such as 20rem.
3931
+
3932
+ **Do:** Explain a metric with a title, one sentence, and a link.
3933
+
3934
+ ```tsx
3935
+ /**
3936
+ * Do example for "Keep Content Small" on the Popover page.
3937
+ * Explain a metric with a title, one sentence, and a link.
3938
+ * @module
3939
+ */
3940
+ import { Button, style } from '@tempoxyz/ds'
3941
+ import { InfoCircle } from '@tempoxyz/ds/icons'
3942
+
3943
+ /** Renders the static preview, which the guideline card shows inert. */
3944
+ export function Demo() {
3945
+ return (
3946
+ <div {...styles.stack()}>
3947
+ <div {...styles.header()}>
3948
+ <span {...styles.label()}>Throughput</span>
3949
+ <Button aria-label="About throughput" shape="icon" size="small" variant="tertiary">
3950
+ <InfoCircle />
3951
+ </Button>
3952
+ </div>
3953
+ <div {...styles.popup()}>
3954
+ <span {...styles.title()}>Throughput</span>
3955
+ <p {...styles.description()}>Transactions per second, averaged over each block.</p>
3956
+ <span {...styles.link()}>View methodology</span>
3957
+ </div>
3958
+ </div>
3959
+ )
3960
+ }
3961
+
3962
+ namespace styles {
3963
+ export const description = style({
3964
+ color: 'content.secondary',
3965
+ margin: '0 !custom',
3966
+ typography: 'body.b2',
3967
+ })
3968
+
3969
+ export const header = style({ alignItems: 'center', columnGap: '4', display: 'flex' })
3970
+
3971
+ export const label = style({ color: 'content.primary', typography: 'body.b2Strong' })
3972
+
3973
+ export const link = style({
3974
+ color: 'content.primary',
3975
+ textDecorationLine: 'underline !custom',
3976
+ typography: 'body.b2Strong',
3977
+ })
3978
+
3979
+ export const popup = style({
3980
+ backgroundColor: 'background.elevated',
3981
+ borderRadius: 'sm',
3982
+ boxShadow: 'regular',
3983
+ boxSizing: 'border-box',
3984
+ display: 'flex',
3985
+ flexDirection: 'column',
3986
+ padding: '20',
3987
+ rowGap: '8',
3988
+ width: '15rem !custom',
3989
+ })
3990
+
3991
+ export const stack = style({
3992
+ alignItems: 'flex-start',
3993
+ display: 'flex',
3994
+ flexDirection: 'column',
3995
+ rowGap: '8',
3996
+ })
3997
+
3998
+ export const title = style({ color: 'content.primary', typography: 'body.b1Strong' })
3999
+ }
4000
+ ```
4001
+
4002
+ **Don't:** Build a multi-field form in a popover. Use a [Dialog](#dialog).
4003
+
4004
+ ```tsx
4005
+ /**
4006
+ * Don't example for "Keep Content Small" on the Popover page.
4007
+ * Don't build a multi-field form in a popover. Use a Dialog.
4008
+ * @module
4009
+ */
4010
+ import { Button, style, TextInput } from '@tempoxyz/ds'
4011
+
4012
+ /** Renders the static preview, which the guideline card shows inert. */
4013
+ export function Demo() {
4014
+ return (
4015
+ <div {...styles.popup()}>
4016
+ <span {...styles.title()}>New webhook</span>
4017
+ <TextInput.Group>
4018
+ <TextInput.Control aria-label="Endpoint URL" placeholder="Endpoint URL" />
4019
+ </TextInput.Group>
4020
+ <TextInput.Group>
4021
+ <TextInput.Control aria-label="Events" placeholder="Events" />
4022
+ </TextInput.Group>
4023
+ <TextInput.Group>
4024
+ <TextInput.Control aria-label="Signing secret" placeholder="Signing secret" />
4025
+ </TextInput.Group>
4026
+ <div {...styles.actions()}>
4027
+ <Button size="small" variant="secondary">
4028
+ Cancel
4029
+ </Button>
4030
+ <Button size="small">Create webhook</Button>
4031
+ </div>
4032
+ </div>
4033
+ )
4034
+ }
4035
+
4036
+ namespace styles {
4037
+ export const actions = style({
4038
+ columnGap: '8',
4039
+ display: 'flex',
4040
+ justifyContent: 'flex-end',
4041
+ marginTop: '4',
4042
+ })
4043
+
4044
+ export const popup = style({
4045
+ backgroundColor: 'background.elevated',
4046
+ borderRadius: 'sm',
4047
+ boxShadow: 'regular',
4048
+ boxSizing: 'border-box',
4049
+ display: 'flex',
4050
+ flexDirection: 'column',
4051
+ padding: '20',
4052
+ rowGap: '8',
4053
+ width: '16rem !custom',
4054
+ })
4055
+
4056
+ export const title = style({ color: 'content.primary', typography: 'body.b1Strong' })
4057
+ }
4058
+ ```
4059
+
4060
+ #### Add Hover Without Replacing Click
4061
+
4062
+ * **Click (default):** `Popover.Trigger` toggles on click, which covers a mouse, a tap, and Enter or Space.
4063
+ * **Hover and Click (openOnHover):** For info icons on dashboards. Opens after 300ms of hover, and click still works.
4064
+
4065
+ #### Offer a Close Action for Controls
4066
+
4067
+ Escape and an outside press close a popover. If it holds controls, add a `Popover.Close` button, such as Cancel or Done, for touch screens.
4068
+
4069
+ **Do:** Add a `Popover.Close` action beside the controls.
4070
+
4071
+ ```tsx
4072
+ /**
4073
+ * Do example for "Offer a Close Action for Controls" on the Popover page.
4074
+ * Add a `Popover.Close` action beside the controls.
4075
+ * @module
4076
+ */
4077
+ import { Button, style, TextInput } from '@tempoxyz/ds'
4078
+
4079
+ /** Renders the static preview, which the guideline card shows inert. */
4080
+ export function Demo() {
4081
+ return (
4082
+ <div {...styles.popup()}>
4083
+ <span {...styles.title()}>Address label</span>
4084
+ <TextInput.Group>
4085
+ <TextInput.Control aria-label="Label" defaultValue="Alex, main wallet" />
4086
+ </TextInput.Group>
4087
+ <div {...styles.actions()}>
4088
+ <Button size="small" variant="secondary">
4089
+ Cancel
4090
+ </Button>
4091
+ <Button size="small">Save label</Button>
4092
+ </div>
4093
+ </div>
4094
+ )
4095
+ }
4096
+
4097
+ namespace styles {
4098
+ export const actions = style({
4099
+ columnGap: '8',
4100
+ display: 'flex',
4101
+ justifyContent: 'flex-end',
4102
+ marginTop: '4',
4103
+ })
4104
+
4105
+ export const popup = style({
4106
+ backgroundColor: 'background.elevated',
4107
+ borderRadius: 'sm',
4108
+ boxShadow: 'regular',
4109
+ boxSizing: 'border-box',
4110
+ display: 'flex',
4111
+ flexDirection: 'column',
4112
+ padding: '20',
4113
+ rowGap: '8',
4114
+ width: '16rem !custom',
4115
+ })
4116
+
4117
+ export const title = style({ color: 'content.primary', typography: 'body.b1Strong' })
4118
+ }
4119
+ ```
4120
+
4121
+ **Don't:** Rely on Escape or an outside press to leave a popover with controls.
4122
+
4123
+ ```tsx
4124
+ /**
4125
+ * Don't example for "Offer a Close Action for Controls" on the Popover page.
4126
+ * Don't rely on Escape or an outside press to leave a popover with controls.
4127
+ * @module
4128
+ */
4129
+ import { style, TextInput } from '@tempoxyz/ds'
4130
+
4131
+ /** Renders the static preview, which the guideline card shows inert. */
4132
+ export function Demo() {
4133
+ return (
4134
+ <div {...styles.popup()}>
4135
+ <span {...styles.title()}>Address label</span>
4136
+ <TextInput.Group>
4137
+ <TextInput.Control aria-label="Label" defaultValue="Alex, main wallet" />
4138
+ </TextInput.Group>
4139
+ </div>
4140
+ )
4141
+ }
4142
+
4143
+ namespace styles {
4144
+ export const popup = style({
4145
+ backgroundColor: 'background.elevated',
4146
+ borderRadius: 'sm',
4147
+ boxShadow: 'regular',
4148
+ boxSizing: 'border-box',
4149
+ display: 'flex',
4150
+ flexDirection: 'column',
4151
+ padding: '20',
4152
+ rowGap: '8',
4153
+ width: '16rem !custom',
4154
+ })
4155
+
4156
+ export const title = style({ color: 'content.primary', typography: 'body.b1Strong' })
4157
+ }
4158
+ ```
4159
+
4160
+ #### Point at Small Triggers
4161
+
4162
+ `Popover.Popup` opens 8px from its trigger. If the trigger is small, such as an info icon in a table header, add `Popover.Arrow`.
4163
+
4164
+ **Do:** Add `Popover.Arrow` to point at a small trigger.
4165
+
4166
+ ```tsx
4167
+ /**
4168
+ * Do example for "Point at Small Triggers" on the Popover page.
4169
+ * Add `Popover.Arrow` to point at a small trigger.
4170
+ * @module
4171
+ */
4172
+ import { Button, style } from '@tempoxyz/ds'
4173
+ import { InfoCircle } from '@tempoxyz/ds/icons'
4174
+
4175
+ /** Renders the static preview, which the guideline card shows inert. */
4176
+ export function Demo() {
4177
+ return (
4178
+ <div {...styles.stack()}>
4179
+ <div {...styles.header()}>
4180
+ <span {...styles.column()}>
4181
+ Fee
4182
+ <Button aria-label="About fee" shape="icon" size="small" variant="tertiary">
4183
+ <InfoCircle />
4184
+ </Button>
4185
+ </span>
4186
+ <span {...styles.column()}>
4187
+ Throughput
4188
+ <Button aria-label="About throughput" shape="icon" size="small" variant="tertiary">
4189
+ <InfoCircle />
4190
+ </Button>
4191
+ </span>
4192
+ </div>
4193
+ <div {...styles.popup()}>
4194
+ {/* Popover.Arrow needs an open popup, so this preview draws its shape in place. */}
4195
+ <svg
4196
+ aria-hidden="true"
4197
+ fill="currentColor"
4198
+ height="10"
4199
+ viewBox="0 0 20 10"
4200
+ width="20"
4201
+ {...styles.arrow()}
4202
+ >
4203
+ <path d="M0 10C4 10 7 7 8.6 4.6a2 2 0 0 1 2.8 0C13 7 16 10 20 10Z" />
4204
+ </svg>
4205
+ <p {...styles.description()}>Paid in the token you send, about 0.01 USDC.</p>
4206
+ </div>
4207
+ </div>
4208
+ )
4209
+ }
4210
+
4211
+ namespace styles {
4212
+ export const arrow = style({
4213
+ color: 'background.elevated',
4214
+ left: '4.25rem !custom',
4215
+ position: 'absolute',
4216
+ top: '-10px !custom',
4217
+ })
4218
+
4219
+ export const column = style({
4220
+ alignItems: 'center',
4221
+ color: 'content.secondary',
4222
+ columnGap: '2px !custom',
4223
+ display: 'flex',
4224
+ typography: 'body.b3',
4225
+ })
4226
+
4227
+ export const description = style({
4228
+ color: 'content.secondary',
4229
+ margin: '0 !custom',
4230
+ typography: 'body.b2',
4231
+ })
4232
+
4233
+ export const header = style({ columnGap: '24', display: 'flex', paddingInlineStart: '24' })
4234
+
4235
+ export const popup = style({
4236
+ backgroundColor: 'background.elevated',
4237
+ borderRadius: 'sm',
4238
+ boxShadow: 'regular',
4239
+ boxSizing: 'border-box',
4240
+ padding: '16',
4241
+ position: 'relative',
4242
+ width: '15rem !custom',
4243
+ })
4244
+
4245
+ export const stack = style({ display: 'flex', flexDirection: 'column', rowGap: '8' })
4246
+ }
4247
+ ```
4248
+
4249
+ **Don't:** Leave the popup's trigger unclear among small icons.
4250
+
4251
+ ```tsx
4252
+ /**
4253
+ * Don't example for "Point at Small Triggers" on the Popover page.
4254
+ * Don't leave the popup's trigger unclear among small icons.
4255
+ * @module
4256
+ */
4257
+ import { Button, style } from '@tempoxyz/ds'
4258
+ import { InfoCircle } from '@tempoxyz/ds/icons'
4259
+
4260
+ /** Renders the static preview, which the guideline card shows inert. */
4261
+ export function Demo() {
4262
+ return (
4263
+ <div {...styles.stack()}>
4264
+ <div {...styles.header()}>
4265
+ <span {...styles.column()}>
4266
+ Fee
4267
+ <Button aria-label="About fee" shape="icon" size="small" variant="tertiary">
4268
+ <InfoCircle />
4269
+ </Button>
4270
+ </span>
4271
+ <span {...styles.column()}>
4272
+ Throughput
4273
+ <Button aria-label="About throughput" shape="icon" size="small" variant="tertiary">
4274
+ <InfoCircle />
4275
+ </Button>
4276
+ </span>
4277
+ </div>
4278
+ <div {...styles.popup()}>
4279
+ <p {...styles.description()}>Paid in the token you send, about 0.01 USDC.</p>
4280
+ </div>
4281
+ </div>
4282
+ )
4283
+ }
4284
+
4285
+ namespace styles {
4286
+ export const column = style({
4287
+ alignItems: 'center',
4288
+ color: 'content.secondary',
4289
+ columnGap: '2px !custom',
4290
+ display: 'flex',
4291
+ typography: 'body.b3',
4292
+ })
4293
+
4294
+ export const description = style({
4295
+ color: 'content.secondary',
4296
+ margin: '0 !custom',
4297
+ typography: 'body.b2',
4298
+ })
4299
+
4300
+ export const header = style({ columnGap: '24', display: 'flex', paddingInlineStart: '24' })
4301
+
4302
+ export const popup = style({
4303
+ backgroundColor: 'background.elevated',
4304
+ borderRadius: 'sm',
4305
+ boxShadow: 'regular',
4306
+ boxSizing: 'border-box',
4307
+ padding: '16',
4308
+ width: '15rem !custom',
4309
+ })
4310
+
4311
+ export const stack = style({ display: 'flex', flexDirection: 'column', rowGap: '8' })
4312
+ }
4313
+ ```
4314
+
4315
+ ### Content
4316
+
4317
+ #### Title With the Subject
4318
+
4319
+ Name the value or setting, such as Network fee, with no question. Put the explanation in `Popover.Description`.
4320
+
4321
+ #### Lead With the Answer
4322
+
4323
+ Start with the explanation, such as Transactions per second, averaged over each block. Keep it under about 25 words.
4324
+
4325
+ ### Accessibility
4326
+
4327
+ #### Semantics
4328
+
4329
+ * **Popover.Trigger (button):** Announces a dialog that click and keyboard open.
4330
+ * **Popover.Popup (dialog):** A non-modal dialog, named by its title.
4331
+ * **Popover.Title (h2):** Names the popup.
4332
+ * **Popover.Description (p):** Describes the popup to screen readers.
4333
+ * **Popover.Arrow (aria-hidden):** Decorative and hidden from assistive technology.
4334
+
4335
+ #### Keyboard
4336
+
4337
+ * **Open and Activate (Enter or Space):** Opens the popover from the trigger, and activates the focused control in it.
4338
+ * **Move Through the Popup (Tab):** Moves through the controls in the popup. Past the last control, the popover closes.
4339
+ * **Return to the Trigger (Shift+Tab):** From the first control, moves focus back to the trigger.
4340
+ * **Close the Popover (Escape):** Closes the popover.
4341
+
4342
+ #### Focus
4343
+
4344
+ * **Opening (initialFocus):** Focus moves to the first control, or to the popup on touch. Pass `initialFocus` to change it.
4345
+ * **Non-Modal (modal):** Focus is not trapped, and the page stays interactive unless you set `modal`.
4346
+ * **Outside Press:** A press outside the popup closes it.
4347
+ * **Closing (finalFocus):** Escape or an outside press returns focus to the trigger. If the trigger is gone, pass `finalFocus`.
4348
+
4349
+ #### Your Responsibilities
4350
+
4351
+ * **Render Popover.Title:** Always render a title, so the dialog has an accessible name.
4352
+ * **Name Icon-Only Triggers (aria-label):** Name the trigger's subject, such as "About throughput".
4353
+
4354
+ ### Related
4355
+
4356
+ [Tooltip](#tooltip)
4357
+
4358
+ Use for short labels on icon buttons.
4359
+
4360
+ [Dialog](#dialog)
4361
+
4362
+ Use for focused tasks that block the page.
4363
+
4364
+ [Drawer](#drawer)
4365
+
4366
+ Use for long content and bottom sheets.
4367
+
4368
+ [Menu](#menu)
4369
+
4370
+ Use for lists of actions.
4371
+
4372
+ [Dashboards](../patterns.md#dashboards)
4373
+
4374
+ Covers explaining metrics.
4375
+
4376
+ ### Examples
4377
+
4378
+ #### Basic
4379
+
4380
+ ```tsx
4381
+ import { Button, Popover, style } from '@tempoxyz/ds'
4382
+
4383
+ export function Demo() {
4384
+ return (
4385
+ <Popover.Root>
4386
+ <Popover.Trigger render={<Button variant="secondary" />}>Network fee</Popover.Trigger>
4387
+ <Popover.Popup>
4388
+ <Popover.Title>Network fee</Popover.Title>
4389
+ <Popover.Description>Paid in the token you send.</Popover.Description>
4390
+ <div {...styles.actions()}>
4391
+ <Popover.Close render={<Button size="small" variant="secondary" />}>Got it</Popover.Close>
4392
+ </div>
4393
+ </Popover.Popup>
4394
+ </Popover.Root>
4395
+ )
4396
+ }
4397
+
4398
+ namespace styles {
4399
+ export const actions = style({ marginTop: '16' })
4400
+ }
4401
+ ```
4402
+
4403
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Popover/Basic.tsx)
4404
+
4405
+ #### Side
4406
+
4407
+ Set `side` on `Popover.Popup` to `top`, `right`, `bottom` (default), or `left`. Add `Popover.Arrow` to point toward the trigger.
4408
+
4409
+ ```tsx
4410
+ import { Button, Popover } from '@tempoxyz/ds'
4411
+
4412
+ export function Demo() {
4413
+ return (
4414
+ <Popover.Root>
4415
+ <Popover.Trigger render={<Button variant="secondary" />}>With arrow</Popover.Trigger>
4416
+ <Popover.Popup side="right">
4417
+ <Popover.Arrow />
4418
+ <Popover.Title>Estimated arrival</Popover.Title>
4419
+ <Popover.Description>About one minute.</Popover.Description>
4420
+ </Popover.Popup>
4421
+ </Popover.Root>
4422
+ )
4423
+ }
4424
+ ```
4425
+
4426
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Popover/Side.tsx)
4427
+
4428
+ ## Tooltip
4429
+
4430
+ Shows a short label for a control on hover or focus.
4431
+
4432
+ [View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Tooltip.tsx)
4433
+
4434
+ Figma: [Tooltip](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=3084-1076) (`Tooltip.Popup`)
4435
+
4436
+ ### Overview
4437
+
4438
+ A tooltip is a visual label that opens on hover and keyboard focus.
4439
+
4440
+ ### Anatomy
4441
+
4442
+ Import the component and assemble its parts.
4443
+
4444
+ ```tsx
4445
+ import { Tooltip } from '@tempoxyz/ds'
4446
+
4447
+ <Tooltip.Provider>
4448
+ <Tooltip.Root>
4449
+ <Tooltip.Trigger />
4450
+ <Tooltip.Popup />
4451
+ </Tooltip.Root>
4452
+ </Tooltip.Provider>
4453
+ ```
4454
+
4455
+ ### Guidelines
4456
+
4457
+ #### When to Use
4458
+
4459
+ * Label an icon-only button, such as Refresh balances, Filter activity, or Settings.
4460
+ * Name a control whose icon is ambiguous, such as an arrow that could mean Send or Export.
4461
+
4462
+ #### When Not to Use
4463
+
4464
+ * Use a [Popover](#popover) with `openOnHover` on `Popover.Trigger` for info icons, such as the explanation beside a dashboard metric.
4465
+ * Use visible text, such as a `Field.Description` from [Field](forms-and-inputs.md#field-1), for fees, limits, requirements, and errors.
4466
+ * Use an [Alert](feedback-and-status.md#alert) for warnings.
4467
+ * Write the reason for a disabled [Button](actions.md#button) in nearby text, not in a tooltip.
4468
+ * Don't add a tooltip to a [Button](actions.md#button) with a visible label. It repeats the label and covers nearby content.
4469
+
4470
+ #### Use Tooltips as Labels Only
4471
+
4472
+ Focus stays on the trigger while the tooltip is open, so Tab can't reach a link or button inside it.
4473
+
4474
+ **Do:** Name the action of an icon-only button in a few words.
4475
+
4476
+ ```tsx
4477
+ /**
4478
+ * Do example for "Use Tooltips as Labels Only" on the Tooltip page.
4479
+ * Name the action of an icon-only button in a few words.
4480
+ * @module
4481
+ */
4482
+ import { Button, style } from '@tempoxyz/ds'
4483
+ import { Filter } from '@tempoxyz/ds/icons'
4484
+
4485
+ /** Renders the static preview, which the guideline card shows inert. */
4486
+ export function Demo() {
4487
+ return (
4488
+ <div {...styles.stack()}>
4489
+ <div {...styles.tooltip()}>Filter activity</div>
4490
+ <Button aria-label="Filter activity" shape="icon" variant="secondary">
4491
+ <Filter />
4492
+ </Button>
4493
+ </div>
4494
+ )
4495
+ }
4496
+
4497
+ namespace styles {
4498
+ export const stack = style({
4499
+ alignItems: 'center',
4500
+ display: 'flex',
4501
+ flexDirection: 'column',
4502
+ rowGap: '8',
4503
+ })
4504
+
4505
+ export const tooltip = style({
4506
+ backgroundColor: 'content.primary',
4507
+ borderRadius: 'xs',
4508
+ color: 'background.primary',
4509
+ paddingBlock: '6px !custom',
4510
+ paddingInline: '12',
4511
+ typography: 'body.b3',
4512
+ })
4513
+ }
4514
+ ```
4515
+
4516
+ **Don't:** Put links, buttons, or other controls in a tooltip. Use a
4517
+ [Popover](#popover).
4518
+
4519
+ ```tsx
4520
+ /**
4521
+ * Don't example for "Use Tooltips as Labels Only" on the Tooltip page.
4522
+ * Don't put links, buttons, or other controls in a tooltip. Use a Popover.
4523
+ * @module
4524
+ */
4525
+ import { Button, style } from '@tempoxyz/ds'
4526
+ import { InfoCircle } from '@tempoxyz/ds/icons'
4527
+
4528
+ /** Renders the static preview, which the guideline card shows inert. */
4529
+ export function Demo() {
4530
+ return (
4531
+ <div {...styles.stack()}>
4532
+ <div {...styles.tooltip()}>
4533
+ Fees depend on network load. <span {...styles.link()}>Learn more</span>
4534
+ </div>
4535
+ <Button aria-label="About network fees" shape="icon" size="small" variant="tertiary">
4536
+ <InfoCircle />
4537
+ </Button>
4538
+ </div>
4539
+ )
4540
+ }
4541
+
4542
+ namespace styles {
4543
+ export const link = style({ textDecorationLine: 'underline !custom' })
4544
+
4545
+ export const stack = style({
4546
+ alignItems: 'center',
4547
+ display: 'flex',
4548
+ flexDirection: 'column',
4549
+ rowGap: '8',
4550
+ })
4551
+
4552
+ export const tooltip = style({
4553
+ backgroundColor: 'content.primary',
4554
+ borderRadius: 'xs',
4555
+ color: 'background.primary',
4556
+ maxWidth: '14rem !custom',
4557
+ paddingBlock: '6px !custom',
4558
+ paddingInline: '12',
4559
+ typography: 'body.b3',
4560
+ })
4561
+ }
4562
+ ```
4563
+
4564
+ #### Keep Essential Information Visible
4565
+
4566
+ Touch input never opens a tooltip, and screen readers don't announce it. Show amounts, fees, and requirements as text on the page.
4567
+
4568
+ **Do:** Show the fee and its explanation as visible text.
4569
+
4570
+ ```tsx
4571
+ /**
4572
+ * Do example for "Keep Essential Information Visible" on the Tooltip page.
4573
+ * Show the fee and its explanation as visible text.
4574
+ * @module
4575
+ */
4576
+ import { style } from '@tempoxyz/ds'
4577
+
4578
+ /** Renders the static preview, which the guideline card shows inert. */
4579
+ export function Demo() {
4580
+ return (
4581
+ <div {...styles.row()}>
4582
+ <div {...styles.text()}>
4583
+ <span {...styles.label()}>Network fee</span>
4584
+ <span {...styles.hint()}>Paid in the token you send</span>
4585
+ </div>
4586
+ <span {...styles.value()}>0.001 USDC</span>
4587
+ </div>
4588
+ )
4589
+ }
4590
+
4591
+ namespace styles {
4592
+ export const hint = style({ color: 'content.secondary', typography: 'body.b3' })
4593
+
4594
+ export const label = style({ color: 'content.primary', typography: 'body.b2Strong' })
4595
+
4596
+ export const row = style({
4597
+ alignItems: 'center',
4598
+ columnGap: '24',
4599
+ display: 'flex',
4600
+ justifyContent: 'space-between',
4601
+ width: '16rem !custom',
4602
+ })
4603
+
4604
+ export const text = style({ display: 'flex', flexDirection: 'column', rowGap: '4' })
4605
+
4606
+ export const value = style({ color: 'content.primary', typography: 'body.b2' })
4607
+ }
4608
+ ```
4609
+
4610
+ **Don't:** Hide a value you need to decide behind a tooltip.
4611
+
4612
+ ```tsx
4613
+ /**
4614
+ * Don't example for "Keep Essential Information Visible" on the Tooltip page.
4615
+ * Don't hide a value you need to decide behind a tooltip.
4616
+ * @module
4617
+ */
4618
+ import { Button, style } from '@tempoxyz/ds'
4619
+ import { InfoCircle } from '@tempoxyz/ds/icons'
4620
+
4621
+ /** Renders the static preview, which the guideline card shows inert. */
4622
+ export function Demo() {
4623
+ return (
4624
+ <div {...styles.stack()}>
4625
+ <div {...styles.tooltip()}>0.001 USDC, paid in the token you send</div>
4626
+ <div {...styles.row()}>
4627
+ <span {...styles.label()}>Network fee</span>
4628
+ <Button aria-label="Network fee" shape="icon" size="small" variant="tertiary">
4629
+ <InfoCircle />
4630
+ </Button>
4631
+ </div>
4632
+ </div>
4633
+ )
4634
+ }
4635
+
4636
+ namespace styles {
4637
+ export const label = style({ color: 'content.primary', typography: 'body.b2Strong' })
4638
+
4639
+ export const row = style({ alignItems: 'center', columnGap: '4', display: 'flex' })
4640
+
4641
+ export const stack = style({
4642
+ alignItems: 'flex-end',
4643
+ display: 'flex',
4644
+ flexDirection: 'column',
4645
+ rowGap: '8',
4646
+ })
4647
+
4648
+ export const tooltip = style({
4649
+ backgroundColor: 'content.primary',
4650
+ borderRadius: 'xs',
4651
+ color: 'background.primary',
4652
+ paddingBlock: '6px !custom',
4653
+ paddingInline: '12',
4654
+ typography: 'body.b3',
4655
+ })
4656
+ }
4657
+ ```
4658
+
4659
+ #### Group Tooltips With a Provider
4660
+
4661
+ * **Toolbars (Tooltip.Provider):** Wrap a row of icon buttons, so once one tooltip opens, its neighbors open instantly.
4662
+ * **Single Triggers (600ms):** Keep the default `delay`. Shorter delays flash tooltips as the pointer passes.
4663
+
4664
+ #### Place Tooltips Clear of Related Content
4665
+
4666
+ `Tooltip.Popup` flips when it would overflow the viewport. Set `side="bottom"` for triggers in a header or top toolbar.
4667
+
4668
+ **Do:** Choose a side that keeps the value the control acts on visible.
4669
+
4670
+ ```tsx
4671
+ /**
4672
+ * Do example for "Place Tooltips Clear of Related Content" on the Tooltip page.
4673
+ * Choose a side that keeps the value the control acts on visible.
4674
+ * @module
4675
+ */
4676
+ import { Button, style } from '@tempoxyz/ds'
4677
+ import { Refresh } from '@tempoxyz/ds/icons'
4678
+
4679
+ /** Renders the static preview, which the guideline card shows inert. */
4680
+ export function Demo() {
4681
+ return (
4682
+ <div {...styles.card()}>
4683
+ <span {...styles.label()}>Balance</span>
4684
+ <div {...styles.row()}>
4685
+ <span {...styles.value()}>1,250.00 USDC</span>
4686
+ <span {...styles.anchor()}>
4687
+ <Button aria-label="Refresh balance" shape="icon" size="small" variant="secondary">
4688
+ <Refresh />
4689
+ </Button>
4690
+ <span {...styles.tooltip()}>Refresh balance</span>
4691
+ </span>
4692
+ </div>
4693
+ </div>
4694
+ )
4695
+ }
4696
+
4697
+ namespace styles {
4698
+ export const anchor = style({ display: 'flex', position: 'relative' })
4699
+
4700
+ export const card = style({
4701
+ display: 'flex',
4702
+ flexDirection: 'column',
4703
+ height: '7rem !custom',
4704
+ rowGap: '4',
4705
+ width: '17rem !custom',
4706
+ })
4707
+
4708
+ export const label = style({ color: 'content.secondary', typography: 'body.b3' })
4709
+
4710
+ export const row = style({ alignItems: 'center', columnGap: '8', display: 'flex' })
4711
+
4712
+ // Tooltips render in a portal, so this preview places one with the popup's styles, below the trigger.
4713
+ export const tooltip = style({
4714
+ backgroundColor: 'content.primary',
4715
+ borderRadius: 'xs',
4716
+ color: 'background.primary',
4717
+ paddingBlock: '6px !custom',
4718
+ paddingInline: '12',
4719
+ position: 'absolute',
4720
+ right: '0',
4721
+ top: 'calc(100% + 8px) !custom',
4722
+ typography: 'body.b3',
4723
+ whiteSpace: 'nowrap',
4724
+ })
4725
+
4726
+ export const value = style({ color: 'content.primary', typography: 'heading.h2' })
4727
+ }
4728
+ ```
4729
+
4730
+ **Don't:** Let the tooltip cover the value beside its trigger.
4731
+
4732
+ ```tsx
4733
+ /**
4734
+ * Don't example for "Place Tooltips Clear of Related Content" on the Tooltip page.
4735
+ * Don't let the tooltip cover the value beside its trigger.
4736
+ * @module
4737
+ */
4738
+ import { Button, style } from '@tempoxyz/ds'
4739
+ import { Refresh } from '@tempoxyz/ds/icons'
4740
+
4741
+ /** Renders the static preview, which the guideline card shows inert. */
4742
+ export function Demo() {
4743
+ return (
4744
+ <div {...styles.card()}>
4745
+ <span {...styles.label()}>Balance</span>
4746
+ <div {...styles.row()}>
4747
+ <span {...styles.value()}>1,250.00 USDC</span>
4748
+ <span {...styles.anchor()}>
4749
+ <Button aria-label="Refresh balance" shape="icon" size="small" variant="secondary">
4750
+ <Refresh />
4751
+ </Button>
4752
+ <span {...styles.tooltip()}>Refresh balance</span>
4753
+ </span>
4754
+ </div>
4755
+ </div>
4756
+ )
4757
+ }
4758
+
4759
+ namespace styles {
4760
+ export const anchor = style({ display: 'flex', position: 'relative' })
4761
+
4762
+ export const card = style({
4763
+ display: 'flex',
4764
+ flexDirection: 'column',
4765
+ height: '7rem !custom',
4766
+ rowGap: '4',
4767
+ width: '17rem !custom',
4768
+ })
4769
+
4770
+ export const label = style({ color: 'content.secondary', typography: 'body.b3' })
4771
+
4772
+ export const row = style({ alignItems: 'center', columnGap: '8', display: 'flex' })
4773
+
4774
+ // Tooltips render in a portal, so this preview places one with the popup's styles, left of the trigger.
4775
+ export const tooltip = style({
4776
+ backgroundColor: 'content.primary',
4777
+ borderRadius: 'xs',
4778
+ color: 'background.primary',
4779
+ paddingBlock: '6px !custom',
4780
+ paddingInline: '12',
4781
+ position: 'absolute',
4782
+ right: 'calc(100% + 8px) !custom',
4783
+ top: '50% !custom',
4784
+ transform: 'translateY(-50%) !custom',
4785
+ typography: 'body.b3',
4786
+ whiteSpace: 'nowrap',
4787
+ })
4788
+
4789
+ export const value = style({ color: 'content.primary', typography: 'heading.h2' })
4790
+ }
4791
+ ```
4792
+
4793
+ ### Content
4794
+
4795
+ #### Write a Few Words
4796
+
4797
+ Use one to four words. Name the action, such as Refresh balances, not the icon, such as Circular arrows.
4798
+
4799
+ ### Accessibility
4800
+
4801
+ A tooltip is visual only, so the trigger needs its own accessible name.
4802
+
4803
+ #### Semantics
4804
+
4805
+ * **Tooltip.Trigger (button):** Keeps the role of the element it renders.
4806
+ * **Tooltip.Popup:** Has no role and isn't linked to the trigger, so it neither names nor describes it. Mounts only while open.
4807
+ * **Contrast (elevated):** Sets primary text on the elevated fill in both schemes.
4808
+
4809
+ #### Keyboard
4810
+
4811
+ * **Open on Focus (Tab):** Focus on the trigger opens the tooltip at once.
4812
+ * **Close the Tooltip (Escape):** Closes the tooltip while focus stays on the trigger.
4813
+
4814
+ #### Focus
4815
+
4816
+ * **No Focus:** The tooltip never takes focus and holds no interactive content.
4817
+ * **Pointer:** Opens after 600ms of hover. The pointer can move onto the popup without closing it.
4818
+ * **Touch:** Touch input never opens it, so no task may depend on one.
4819
+
4820
+ #### Your Responsibilities
4821
+
4822
+ * **Name Icon-Only Triggers (aria-label):** Name an icon-only trigger with the tooltip text.
4823
+
4824
+ ### Related
4825
+
4826
+ [Popover](#popover)
4827
+
4828
+ Use for info icons and interactive content.
4829
+
4830
+ [Button](actions.md#button)
4831
+
4832
+ Use for icon-only buttons.
4833
+
4834
+ [CopyButton](actions.md#copybutton)
4835
+
4836
+ Use for a copy action that names itself.
4837
+
4838
+ [Field](forms-and-inputs.md#field-1)
4839
+
4840
+ Use for descriptions that stay visible.
4841
+
4842
+ [Dashboards](../patterns.md#dashboards)
4843
+
4844
+ Covers metric explanations.
4845
+
4846
+ ### Examples
4847
+
4848
+ #### Basic
4849
+
4850
+ ```tsx
4851
+ import { Button, Tooltip } from '@tempoxyz/ds'
4852
+ import { Plus } from '@tempoxyz/ds/icons'
4853
+
4854
+ export function Demo() {
4855
+ return (
4856
+ <Tooltip.Provider>
4857
+ <Tooltip.Root>
4858
+ <Tooltip.Trigger
4859
+ render={<Button aria-label="Add funds" shape="icon" variant="secondary" />}
4860
+ >
4861
+ <Plus />
4862
+ </Tooltip.Trigger>
4863
+ <Tooltip.Popup>Add funds</Tooltip.Popup>
4864
+ </Tooltip.Root>
4865
+ </Tooltip.Provider>
4866
+ )
4867
+ }
4868
+ ```
4869
+
4870
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Tooltip/Basic.tsx)
4871
+
4872
+ #### Side
4873
+
4874
+ Set `side` on `Tooltip.Popup` to `top` (default), `bottom`, `left`, or `right`.
4875
+
4876
+ ```tsx
4877
+ import { Button, Tooltip } from '@tempoxyz/ds'
4878
+
4879
+ export function Demo() {
4880
+ return (
4881
+ <Tooltip.Provider>
4882
+ <Tooltip.Root>
4883
+ <Tooltip.Trigger render={<Button variant="secondary" />}>Bottom</Tooltip.Trigger>
4884
+ <Tooltip.Popup side="bottom">Shown below the trigger</Tooltip.Popup>
4885
+ </Tooltip.Root>
4886
+ </Tooltip.Provider>
4887
+ )
4888
+ }
4889
+ ```
4890
+
4891
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Tooltip/Side.tsx)
4892
+
4893
+ #### Disabled
4894
+
4895
+ Wrap a disabled control in a focusable trigger. Disabled elements receive no pointer or focus events.
4896
+
4897
+ ```tsx
4898
+ import { Button, Tooltip } from '@tempoxyz/ds'
4899
+ import { Refresh } from '@tempoxyz/ds/icons'
4900
+
4901
+ export function Demo() {
4902
+ return (
4903
+ <Tooltip.Provider>
4904
+ <Tooltip.Root>
4905
+ <Tooltip.Trigger render={<span tabIndex={0} />}>
4906
+ <Button aria-label="Refresh balances" disabled shape="icon" variant="secondary">
4907
+ <Refresh />
4908
+ </Button>
4909
+ </Tooltip.Trigger>
4910
+ <Tooltip.Popup>Refresh balances</Tooltip.Popup>
4911
+ </Tooltip.Root>
4912
+ </Tooltip.Provider>
4913
+ )
4914
+ }
4915
+ ```
4916
+
4917
+ [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Tooltip/Disabled.tsx)