@tempoxyz/ds 0.3.14 → 0.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/AGENTS.md +73 -10
- package/dist/docs/{marketing/introduction/getting-started.md → marketing.md} +28 -20
- package/dist/docs/product/components/actions.md +2058 -0
- package/dist/docs/product/components/blockchain.md +3825 -0
- package/dist/docs/product/components/data-display.md +5901 -0
- package/dist/docs/product/components/feedback-and-status.md +4008 -0
- package/dist/docs/product/components/forms-and-inputs.md +10543 -0
- package/dist/docs/product/components/layout.md +3339 -0
- package/dist/docs/product/components/navigation.md +2914 -0
- package/dist/docs/product/components/overlays.md +4917 -0
- package/dist/docs/product/components.md +125 -125
- package/dist/docs/product/foundations.md +4596 -0
- package/dist/docs/product/patterns.md +10129 -0
- package/package.json +1 -1
- package/dist/docs/index.md +0 -145
- package/dist/docs/product/components/accordion.md +0 -489
- package/dist/docs/product/components/address-card.md +0 -147
- package/dist/docs/product/components/agent-logo.md +0 -194
- package/dist/docs/product/components/alert-dialog.md +0 -631
- package/dist/docs/product/components/alert.md +0 -448
- package/dist/docs/product/components/amount-input.md +0 -305
- package/dist/docs/product/components/amount.md +0 -794
- package/dist/docs/product/components/app-shell.md +0 -559
- package/dist/docs/product/components/asset-chip.md +0 -294
- package/dist/docs/product/components/autocomplete.md +0 -620
- package/dist/docs/product/components/avatar.md +0 -321
- package/dist/docs/product/components/badge.md +0 -339
- package/dist/docs/product/components/badged-logo.md +0 -116
- package/dist/docs/product/components/banner.md +0 -379
- package/dist/docs/product/components/bar-chart.md +0 -208
- package/dist/docs/product/components/breadcrumbs.md +0 -380
- package/dist/docs/product/components/button-group.md +0 -286
- package/dist/docs/product/components/button.md +0 -650
- package/dist/docs/product/components/calendar.md +0 -375
- package/dist/docs/product/components/callout.md +0 -96
- package/dist/docs/product/components/checkbox-group.md +0 -521
- package/dist/docs/product/components/checkbox.md +0 -467
- package/dist/docs/product/components/choice-group.md +0 -516
- package/dist/docs/product/components/choicebox.md +0 -641
- package/dist/docs/product/components/code.md +0 -100
- package/dist/docs/product/components/combobox.md +0 -939
- package/dist/docs/product/components/container.md +0 -257
- package/dist/docs/product/components/copy-button.md +0 -642
- package/dist/docs/product/components/date-picker.md +0 -514
- package/dist/docs/product/components/dialog.md +0 -1332
- package/dist/docs/product/components/drawer.md +0 -966
- package/dist/docs/product/components/empty.md +0 -340
- package/dist/docs/product/components/field.md +0 -570
- package/dist/docs/product/components/fieldset.md +0 -398
- package/dist/docs/product/components/frame.md +0 -434
- package/dist/docs/product/components/gauge.md +0 -299
- package/dist/docs/product/components/get-started-visual.md +0 -117
- package/dist/docs/product/components/grid.md +0 -288
- package/dist/docs/product/components/hero-visual.md +0 -155
- package/dist/docs/product/components/hex.md +0 -487
- package/dist/docs/product/components/icon-tile.md +0 -292
- package/dist/docs/product/components/identicon.md +0 -371
- package/dist/docs/product/components/inline.md +0 -233
- package/dist/docs/product/components/inset.md +0 -225
- package/dist/docs/product/components/kbd.md +0 -423
- package/dist/docs/product/components/list-group.md +0 -981
- package/dist/docs/product/components/loading-dots.md +0 -237
- package/dist/docs/product/components/menu.md +0 -934
- package/dist/docs/product/components/native-select.md +0 -204
- package/dist/docs/product/components/network-logo.md +0 -248
- package/dist/docs/product/components/number-field.md +0 -543
- package/dist/docs/product/components/otp-field.md +0 -616
- package/dist/docs/product/components/pagination.md +0 -516
- package/dist/docs/product/components/popover.md +0 -544
- package/dist/docs/product/components/progress.md +0 -388
- package/dist/docs/product/components/qr.md +0 -314
- package/dist/docs/product/components/radio-group.md +0 -528
- package/dist/docs/product/components/secret-value.md +0 -406
- package/dist/docs/product/components/select.md +0 -751
- package/dist/docs/product/components/separator.md +0 -379
- package/dist/docs/product/components/sidebar-menu.md +0 -922
- package/dist/docs/product/components/skeleton.md +0 -517
- package/dist/docs/product/components/slider.md +0 -539
- package/dist/docs/product/components/snippet.md +0 -424
- package/dist/docs/product/components/spinner.md +0 -216
- package/dist/docs/product/components/split-bar.md +0 -139
- package/dist/docs/product/components/split-button.md +0 -464
- package/dist/docs/product/components/stack.md +0 -299
- package/dist/docs/product/components/status-chip.md +0 -226
- package/dist/docs/product/components/status-indicator.md +0 -119
- package/dist/docs/product/components/status-row.md +0 -174
- package/dist/docs/product/components/stepper.md +0 -451
- package/dist/docs/product/components/success-hero.md +0 -157
- package/dist/docs/product/components/surface.md +0 -639
- package/dist/docs/product/components/switch.md +0 -472
- package/dist/docs/product/components/table.md +0 -968
- package/dist/docs/product/components/tabs.md +0 -627
- package/dist/docs/product/components/tempo-logo.md +0 -185
- package/dist/docs/product/components/text-input.md +0 -624
- package/dist/docs/product/components/textarea.md +0 -352
- package/dist/docs/product/components/toast.md +0 -535
- package/dist/docs/product/components/token-logo.md +0 -371
- package/dist/docs/product/components/token.md +0 -247
- package/dist/docs/product/components/tooltip.md +0 -490
- package/dist/docs/product/components/verification-code.md +0 -116
- package/dist/docs/product/components/visual.md +0 -249
- package/dist/docs/product/foundations/accessibility.md +0 -377
- package/dist/docs/product/foundations/agents.md +0 -159
- package/dist/docs/product/foundations/color.md +0 -522
- package/dist/docs/product/foundations/content/tone.md +0 -194
- package/dist/docs/product/foundations/content/voice.md +0 -194
- package/dist/docs/product/foundations/content/writing-style.md +0 -406
- package/dist/docs/product/foundations/iconography.md +0 -282
- package/dist/docs/product/foundations/intent.md +0 -360
- package/dist/docs/product/foundations/layout.md +0 -508
- package/dist/docs/product/foundations/linter.md +0 -523
- package/dist/docs/product/foundations/motion.md +0 -151
- package/dist/docs/product/foundations/radius-and-padding.md +0 -86
- package/dist/docs/product/foundations/typography.md +0 -331
- package/dist/docs/product/introduction/faq.md +0 -133
- package/dist/docs/product/introduction/getting-started.md +0 -377
- package/dist/docs/product/patterns/blockchain-values.md +0 -709
- package/dist/docs/product/patterns/dashboards.md +0 -638
- package/dist/docs/product/patterns/destructive-actions.md +0 -626
- package/dist/docs/product/patterns/empty-states.md +0 -612
- package/dist/docs/product/patterns/errors-and-validation.md +0 -808
- package/dist/docs/product/patterns/feedback-and-status.md +0 -518
- package/dist/docs/product/patterns/forms.md +0 -679
- package/dist/docs/product/patterns/loading.md +0 -630
- package/dist/docs/product/patterns/navigation.md +0 -397
- package/dist/docs/product/patterns/payments.md +0 -765
- package/dist/docs/product/patterns/responsive-layout.md +0 -997
- package/dist/docs/product/patterns/tables-and-lists.md +0 -1170
- package/dist/docs/product/products/tempo-console.md +0 -671
- package/dist/docs/product/products/tempo-performance.md +0 -435
- package/dist/docs/product/products/tempo-wallet.md +0 -438
|
@@ -0,0 +1,4008 @@
|
|
|
1
|
+
# Feedback and Status
|
|
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
|
+
Components that report progress, results, and system state.
|
|
8
|
+
|
|
9
|
+
- [Alert](#alert): Shows an inline message tied to nearby content.
|
|
10
|
+
- [Banner](#banner): Shows a full-width message about the system or page.
|
|
11
|
+
- [Callout](#callout): Sets a short passage of body text apart in a subtle box.
|
|
12
|
+
- [Empty](#empty): Fills a region that has nothing to show yet.
|
|
13
|
+
- [Gauge](#gauge): Shows a measurement within a range as a ring.
|
|
14
|
+
- [LoadingDots](#loadingdots): Shows three pulsing dots for inline loading.
|
|
15
|
+
- [Progress](#progress-1): Shows how far a task has advanced.
|
|
16
|
+
- [Skeleton](#skeleton): Holds the place of content while it loads.
|
|
17
|
+
- [Spinner](#spinner): Shows that something is loading.
|
|
18
|
+
- [StatusChip](#statuschip): Names the status of a payment, an authorization, or a network.
|
|
19
|
+
- [StatusIndicator](#statusindicator): Names the status of a system or a service with a dot and a label.
|
|
20
|
+
- [StatusRow](#statusrow): Follows the status of one payment or task while it runs.
|
|
21
|
+
- [Toast](#toast): Shows a brief notification that dismisses itself.
|
|
22
|
+
|
|
23
|
+
## Alert
|
|
24
|
+
|
|
25
|
+
Shows an inline message tied to nearby content.
|
|
26
|
+
|
|
27
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Alert.tsx)
|
|
28
|
+
|
|
29
|
+
Figma: [Alert](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=3056-453)
|
|
30
|
+
|
|
31
|
+
### Overview
|
|
32
|
+
|
|
33
|
+
An inline message on a tinted container, with a square indicator in the color of its `intent`. It is a live region, so screen readers announce it when it appears.
|
|
34
|
+
|
|
35
|
+
### Anatomy
|
|
36
|
+
|
|
37
|
+
Import the component and assemble its parts.
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { Alert } from '@tempoxyz/ds'
|
|
41
|
+
|
|
42
|
+
<Alert>
|
|
43
|
+
<Alert.Icon />
|
|
44
|
+
<Alert.Content>
|
|
45
|
+
<Alert.Title />
|
|
46
|
+
<Alert.Action />
|
|
47
|
+
</Alert.Content>
|
|
48
|
+
<Alert.Dismiss />
|
|
49
|
+
</Alert>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Guidelines
|
|
53
|
+
|
|
54
|
+
#### When to Use
|
|
55
|
+
|
|
56
|
+
* Explain a condition that affects nearby content, such as higher network fees above the Send payment form.
|
|
57
|
+
* Keep a result visible beside its section, such as a failed webhook delivery.
|
|
58
|
+
* Give guidance before a task, such as a note that testnet tokens have no value.
|
|
59
|
+
* Add optional context with `tip`, such as the token that pays network fees.
|
|
60
|
+
|
|
61
|
+
#### When Not to Use
|
|
62
|
+
|
|
63
|
+
* Use [Banner](#banner) for a message about the whole product or page, such as an outage.
|
|
64
|
+
* Use [Toast](#toast) to confirm that an action finished, such as Payment sent.
|
|
65
|
+
* If an action needs a decision before it continues, use [AlertDialog](overlays.md#alertdialog).
|
|
66
|
+
* Use `Field.Error` from [Field](forms-and-inputs.md#field-1) for a validation message on one input.
|
|
67
|
+
* Use [Badge](data-display.md#badge) for a one-word status on a table row or card, such as Pending.
|
|
68
|
+
|
|
69
|
+
#### Choose an Intent by Severity
|
|
70
|
+
|
|
71
|
+
* **Neutral (default):** Context that needs no action, such as when deposits confirm.
|
|
72
|
+
* **Positive (positive):** A result that stays in place, such as a verified webhook endpoint.
|
|
73
|
+
* **Warning (warning):** An avoidable risk, such as sending to an address new to Tempo.
|
|
74
|
+
* **Negative (negative):** A blocking failure, such as balances that couldn't load.
|
|
75
|
+
* **Tip (tip):** Optional context, such as the token that pays the network fee.
|
|
76
|
+
* **Special (special):** A new feature to announce, such as vaults for idle USDC balances.
|
|
77
|
+
|
|
78
|
+
Use `warning` before a risky step and `negative` before one that can't be undone. Never use `positive` as decoration.
|
|
79
|
+
|
|
80
|
+
#### Pair the Icon With Text That States the Outcome
|
|
81
|
+
|
|
82
|
+
Add `Alert.Icon` to every alert. It draws a square in the color of the intent.
|
|
83
|
+
|
|
84
|
+
**Do:** Combine `Alert.Icon` with a sentence that names the condition.
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
/**
|
|
88
|
+
* Do example for "Pair the Icon With Text That States the Outcome" on the Alert page.
|
|
89
|
+
* Combine `Alert.Icon` with a sentence that names the condition.
|
|
90
|
+
* @module
|
|
91
|
+
*/
|
|
92
|
+
import { Alert } from '@tempoxyz/ds'
|
|
93
|
+
|
|
94
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
95
|
+
export function Demo() {
|
|
96
|
+
return (
|
|
97
|
+
<Alert intent="warning">
|
|
98
|
+
<Alert.Icon />
|
|
99
|
+
<Alert.Content>
|
|
100
|
+
Network fees are higher than usual.
|
|
101
|
+
<Alert.Action>Review fees</Alert.Action>
|
|
102
|
+
</Alert.Content>
|
|
103
|
+
</Alert>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Don't:** Leave out the icon or let the tint carry the warning.
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
/**
|
|
112
|
+
* Don't example for "Pair the Icon With Text That States the Outcome" on the Alert page.
|
|
113
|
+
* Don't leave out the icon or let the tint carry the warning.
|
|
114
|
+
* @module
|
|
115
|
+
*/
|
|
116
|
+
import { Alert } from '@tempoxyz/ds'
|
|
117
|
+
|
|
118
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
119
|
+
export function Demo() {
|
|
120
|
+
return (
|
|
121
|
+
<Alert intent="warning">
|
|
122
|
+
<Alert.Content>
|
|
123
|
+
Network fees
|
|
124
|
+
<Alert.Action>Review</Alert.Action>
|
|
125
|
+
</Alert.Content>
|
|
126
|
+
</Alert>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
#### Place It Beside What It Describes
|
|
132
|
+
|
|
133
|
+
Remove the alert when its condition ends, such as when fees return to normal. In a [Dialog](overlays.md#dialog), show one alert at full width, below the input it describes.
|
|
134
|
+
|
|
135
|
+
**Do:** Put the alert directly above the form it describes, or directly below its control.
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
/**
|
|
139
|
+
* Do example for "Place It Beside What It Describes" on the Alert page.
|
|
140
|
+
* Put the callout directly above the form it describes, or directly below its control.
|
|
141
|
+
* @module
|
|
142
|
+
*/
|
|
143
|
+
import { Alert, Button, Field, Stack, style, TextInput } from '@tempoxyz/ds'
|
|
144
|
+
|
|
145
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
146
|
+
export function Demo() {
|
|
147
|
+
return (
|
|
148
|
+
<Stack gap="16" {...styles.fill()}>
|
|
149
|
+
<div {...styles.activity()}>
|
|
150
|
+
<div {...styles.heading()}>Recent activity</div>
|
|
151
|
+
<div>Sent 25.00 USDC to 0x8f3c…a21b</div>
|
|
152
|
+
<div>Received 120.00 USDC from 0x41d0…9c7e</div>
|
|
153
|
+
</div>
|
|
154
|
+
<Alert intent="warning">
|
|
155
|
+
<Alert.Icon />
|
|
156
|
+
<Alert.Content>Network fees are higher than usual.</Alert.Content>
|
|
157
|
+
</Alert>
|
|
158
|
+
<Field.Root>
|
|
159
|
+
<Field.Label>Amount</Field.Label>
|
|
160
|
+
<TextInput.Group>
|
|
161
|
+
<TextInput.Control defaultValue="50.00" />
|
|
162
|
+
</TextInput.Group>
|
|
163
|
+
</Field.Root>
|
|
164
|
+
<Button>Send payment</Button>
|
|
165
|
+
</Stack>
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
namespace styles {
|
|
170
|
+
export const activity = style({
|
|
171
|
+
color: 'content.secondary',
|
|
172
|
+
display: 'flex',
|
|
173
|
+
flexDirection: 'column',
|
|
174
|
+
gap: '4',
|
|
175
|
+
typography: 'body.b2',
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
export const fill = style({ width: '100% !custom' })
|
|
179
|
+
|
|
180
|
+
export const heading = style({ color: 'content.primary', typography: 'body.b2' })
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Don't:** Place it at the top of a long page, away from its content.
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
/**
|
|
188
|
+
* Don't example for "Place It Beside What It Describes" on the Alert page.
|
|
189
|
+
* Don't place it at the top of a long page, away from its content.
|
|
190
|
+
* @module
|
|
191
|
+
*/
|
|
192
|
+
import { Alert, Button, Field, Stack, style, TextInput } from '@tempoxyz/ds'
|
|
193
|
+
|
|
194
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
195
|
+
export function Demo() {
|
|
196
|
+
return (
|
|
197
|
+
<Stack gap="16" {...styles.fill()}>
|
|
198
|
+
<Alert intent="warning">
|
|
199
|
+
<Alert.Icon />
|
|
200
|
+
<Alert.Content>Network fees are higher than usual.</Alert.Content>
|
|
201
|
+
</Alert>
|
|
202
|
+
<div {...styles.activity()}>
|
|
203
|
+
<div {...styles.heading()}>Recent activity</div>
|
|
204
|
+
<div>Sent 25.00 USDC to 0x8f3c…a21b</div>
|
|
205
|
+
<div>Received 120.00 USDC from 0x41d0…9c7e</div>
|
|
206
|
+
</div>
|
|
207
|
+
<Field.Root>
|
|
208
|
+
<Field.Label>Amount</Field.Label>
|
|
209
|
+
<TextInput.Group>
|
|
210
|
+
<TextInput.Control defaultValue="50.00" />
|
|
211
|
+
</TextInput.Group>
|
|
212
|
+
</Field.Root>
|
|
213
|
+
<Button>Send payment</Button>
|
|
214
|
+
</Stack>
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
namespace styles {
|
|
219
|
+
export const activity = style({
|
|
220
|
+
color: 'content.secondary',
|
|
221
|
+
display: 'flex',
|
|
222
|
+
flexDirection: 'column',
|
|
223
|
+
gap: '4',
|
|
224
|
+
typography: 'body.b2',
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
export const fill = style({ width: '100% !custom' })
|
|
228
|
+
|
|
229
|
+
export const heading = style({ color: 'content.primary', typography: 'body.b2' })
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
#### Offer One Action
|
|
234
|
+
|
|
235
|
+
For more options than one action, link to a page that explains them.
|
|
236
|
+
|
|
237
|
+
**Do:** Offer the one action that resolves the message.
|
|
238
|
+
|
|
239
|
+
```tsx
|
|
240
|
+
/** Do example for "Offer One Action" on the Alert page: offer the one action that resolves the message. @module */
|
|
241
|
+
import { Alert } from '@tempoxyz/ds'
|
|
242
|
+
|
|
243
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
244
|
+
export function Demo() {
|
|
245
|
+
return (
|
|
246
|
+
<Alert intent="negative">
|
|
247
|
+
<Alert.Icon />
|
|
248
|
+
<Alert.Content>
|
|
249
|
+
<Alert.Title>Webhook delivery failed</Alert.Title>
|
|
250
|
+
Your endpoint returned 500.
|
|
251
|
+
<Alert.Action>Retry</Alert.Action>
|
|
252
|
+
</Alert.Content>
|
|
253
|
+
</Alert>
|
|
254
|
+
)
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Don't:** Line up several actions inside one alert.
|
|
259
|
+
|
|
260
|
+
```tsx
|
|
261
|
+
/**
|
|
262
|
+
* Don't example for "Offer One Action" on the Alert page.
|
|
263
|
+
* Don't line up several actions inside one callout.
|
|
264
|
+
* @module
|
|
265
|
+
*/
|
|
266
|
+
import { Alert } from '@tempoxyz/ds'
|
|
267
|
+
|
|
268
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
269
|
+
export function Demo() {
|
|
270
|
+
return (
|
|
271
|
+
<Alert intent="negative">
|
|
272
|
+
<Alert.Icon />
|
|
273
|
+
<Alert.Content>
|
|
274
|
+
Webhook delivery failed.
|
|
275
|
+
<Alert.Action>Retry</Alert.Action>
|
|
276
|
+
<Alert.Action>Logs</Alert.Action>
|
|
277
|
+
<Alert.Action>Docs</Alert.Action>
|
|
278
|
+
</Alert.Content>
|
|
279
|
+
</Alert>
|
|
280
|
+
)
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
To link elsewhere, pass `Alert.Action` a `render` with an `a` element and `nativeButton={false}`.
|
|
285
|
+
|
|
286
|
+
### Content
|
|
287
|
+
|
|
288
|
+
* Lead with the condition, then the consequence or next step: Network fees are higher than usual. Your payment may take longer to confirm.
|
|
289
|
+
* Keep it to one or two sentences. Add an `Alert.Title` of two or three words, such as New address, when the message needs a label.
|
|
290
|
+
* Describe the condition, not the intent. Write Webhook delivery failed, not Error.
|
|
291
|
+
* Use specific values, such as the amount needed: You need to deposit $25.00 to continue.
|
|
292
|
+
* Start the action label with a verb, such as Review fees or Add funds.
|
|
293
|
+
|
|
294
|
+
### Accessibility
|
|
295
|
+
|
|
296
|
+
An alert is a live region whose role depends on `intent`. It does not move focus when it appears.
|
|
297
|
+
|
|
298
|
+
#### Semantics
|
|
299
|
+
|
|
300
|
+
* **Neutral, Positive, Tip, and Special (status):** Announced at the next pause.
|
|
301
|
+
* **Warning and Negative (alert):** Interrupts the screen reader.
|
|
302
|
+
* **Role Override (role):** Replaces either default, such as `role="note"` for static text.
|
|
303
|
+
* **Alert.Icon (aria-hidden):** Never announced. The text carries the meaning.
|
|
304
|
+
* **Alert.Action (button):** A native button. Enter and Space activate it.
|
|
305
|
+
* **Contrast (content.primary):** Text stays primary on every tint and scheme. Keep the background.
|
|
306
|
+
|
|
307
|
+
#### Keyboard
|
|
308
|
+
|
|
309
|
+
* **Move to the Action (Tab):** Moves focus to the alert's action, if any.
|
|
310
|
+
* **Activate the Action (Enter or Space):** Activates the action.
|
|
311
|
+
|
|
312
|
+
#### Your Responsibilities
|
|
313
|
+
|
|
314
|
+
* **Reserve Assertive Intents (warning or negative):** They interrupt the screen reader, so use them only for a message the reader must act on.
|
|
315
|
+
* **Insert It When the Condition Occurs:** An alert present on first render may not be announced. Insert it after the failed request.
|
|
316
|
+
* **Render the Region First:** If one alert shows several messages, render the live region before you change its content.
|
|
317
|
+
* **Remove It on Dismiss (onClick):** `Alert.Dismiss` only renders the button. Remove the alert and move focus in `onClick`.
|
|
318
|
+
|
|
319
|
+
### Related
|
|
320
|
+
|
|
321
|
+
[Banner](#banner)
|
|
322
|
+
|
|
323
|
+
Use for a message about the whole page.
|
|
324
|
+
|
|
325
|
+
[Toast](#toast)
|
|
326
|
+
|
|
327
|
+
Use for confirming a finished action.
|
|
328
|
+
|
|
329
|
+
[Field](forms-and-inputs.md#field-1)
|
|
330
|
+
|
|
331
|
+
Use for validation messages on an input.
|
|
332
|
+
|
|
333
|
+
[Errors and Validation](../patterns.md#errors-and-validation)
|
|
334
|
+
|
|
335
|
+
Covers reporting failures.
|
|
336
|
+
|
|
337
|
+
[Feedback and Status](../patterns.md#feedback-and-status)
|
|
338
|
+
|
|
339
|
+
Covers choosing a message component.
|
|
340
|
+
|
|
341
|
+
### Examples
|
|
342
|
+
|
|
343
|
+
#### Basic
|
|
344
|
+
|
|
345
|
+
```tsx
|
|
346
|
+
import { Alert } from '@tempoxyz/ds'
|
|
347
|
+
|
|
348
|
+
export function Demo() {
|
|
349
|
+
return (
|
|
350
|
+
<Alert>
|
|
351
|
+
<Alert.Icon />
|
|
352
|
+
<Alert.Content>Changes may take a few minutes to appear.</Alert.Content>
|
|
353
|
+
</Alert>
|
|
354
|
+
)
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Alert/Basic.tsx)
|
|
359
|
+
|
|
360
|
+
#### Intent
|
|
361
|
+
|
|
362
|
+
Set `intent` to `neutral` (default), `positive`, `warning`, `negative`, `tip`, or `special`.
|
|
363
|
+
|
|
364
|
+
```tsx
|
|
365
|
+
import { Alert, style } from '@tempoxyz/ds'
|
|
366
|
+
|
|
367
|
+
export const fill = true
|
|
368
|
+
export function Demo() {
|
|
369
|
+
return (
|
|
370
|
+
<div {...styles.stack()}>
|
|
371
|
+
{(['neutral', 'positive', 'warning', 'negative', 'tip', 'special'] as const).map((intent) => (
|
|
372
|
+
<Alert intent={intent} key={intent}>
|
|
373
|
+
<Alert.Icon />
|
|
374
|
+
<Alert.Content>You need to deposit $25.00 to continue.</Alert.Content>
|
|
375
|
+
</Alert>
|
|
376
|
+
))}
|
|
377
|
+
</div>
|
|
378
|
+
)
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
namespace styles {
|
|
382
|
+
export const stack = style({
|
|
383
|
+
display: 'flex',
|
|
384
|
+
flexDirection: 'column',
|
|
385
|
+
gap: '12',
|
|
386
|
+
maxWidth: '36rem !custom',
|
|
387
|
+
})
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Alert/Intent.tsx)
|
|
392
|
+
|
|
393
|
+
#### Title and Action
|
|
394
|
+
|
|
395
|
+
Add an `Alert.Title` above the message, and an `Alert.Action` after it, inside `Alert.Content`.
|
|
396
|
+
|
|
397
|
+
```tsx
|
|
398
|
+
import { Alert, style } from '@tempoxyz/ds'
|
|
399
|
+
|
|
400
|
+
export const fill = true
|
|
401
|
+
export function Demo() {
|
|
402
|
+
return (
|
|
403
|
+
<Alert intent="warning" {...styles.note()}>
|
|
404
|
+
<Alert.Icon />
|
|
405
|
+
<Alert.Content>
|
|
406
|
+
<Alert.Title>New address</Alert.Title>
|
|
407
|
+
Check the first and last 4 characters.
|
|
408
|
+
<Alert.Action>View details</Alert.Action>
|
|
409
|
+
</Alert.Content>
|
|
410
|
+
</Alert>
|
|
411
|
+
)
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
namespace styles {
|
|
415
|
+
export const note = style({ maxWidth: '24rem !custom' })
|
|
416
|
+
}
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Alert/Title.tsx)
|
|
420
|
+
|
|
421
|
+
#### Inline
|
|
422
|
+
|
|
423
|
+
The content flows as text, so inline elements such as `strong` stay on the lines of the message.
|
|
424
|
+
|
|
425
|
+
```tsx
|
|
426
|
+
/** Renders a warning whose message holds inline `strong` text, for the Alert docs. @module */
|
|
427
|
+
import { Alert } from '@tempoxyz/ds'
|
|
428
|
+
|
|
429
|
+
export function Demo() {
|
|
430
|
+
return (
|
|
431
|
+
<Alert intent="warning" role="note">
|
|
432
|
+
<Alert.Icon />
|
|
433
|
+
<Alert.Content>
|
|
434
|
+
Only send <strong>supported stablecoins</strong> on <strong>Tempo</strong>. Sending other
|
|
435
|
+
tokens or using a different network may result in permanent loss.
|
|
436
|
+
</Alert.Content>
|
|
437
|
+
</Alert>
|
|
438
|
+
)
|
|
439
|
+
}
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Alert/Inline.tsx)
|
|
443
|
+
|
|
444
|
+
#### Dismiss
|
|
445
|
+
|
|
446
|
+
Add an `Alert.Dismiss` after `Alert.Content`. Remove the alert in its `onClick`.
|
|
447
|
+
|
|
448
|
+
```tsx
|
|
449
|
+
import { Alert, style } from '@tempoxyz/ds'
|
|
450
|
+
|
|
451
|
+
export const fill = true
|
|
452
|
+
export function Demo() {
|
|
453
|
+
return (
|
|
454
|
+
<Alert intent="tip" {...styles.note()}>
|
|
455
|
+
<Alert.Icon />
|
|
456
|
+
<Alert.Content>
|
|
457
|
+
<Alert.Title>Fee token</Alert.Title>
|
|
458
|
+
Fees are paid in USDC. Change it in Settings.
|
|
459
|
+
</Alert.Content>
|
|
460
|
+
<Alert.Dismiss />
|
|
461
|
+
</Alert>
|
|
462
|
+
)
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
namespace styles {
|
|
466
|
+
export const note = style({ maxWidth: '24rem !custom' })
|
|
467
|
+
}
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Alert/Dismiss.tsx)
|
|
471
|
+
|
|
472
|
+
## Banner
|
|
473
|
+
|
|
474
|
+
Shows a full-width message about the system or page.
|
|
475
|
+
|
|
476
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Banner.tsx)
|
|
477
|
+
|
|
478
|
+
### Overview
|
|
479
|
+
|
|
480
|
+
A full-width strip for a message about the whole product or page.
|
|
481
|
+
|
|
482
|
+
### Anatomy
|
|
483
|
+
|
|
484
|
+
Import the component and assemble its parts.
|
|
485
|
+
|
|
486
|
+
```tsx
|
|
487
|
+
import { Banner } from '@tempoxyz/ds'
|
|
488
|
+
|
|
489
|
+
<Banner>
|
|
490
|
+
<Banner.Content />
|
|
491
|
+
<Banner.Action />
|
|
492
|
+
<Banner.Dismiss />
|
|
493
|
+
</Banner>
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
### Guidelines
|
|
497
|
+
|
|
498
|
+
#### When to Use
|
|
499
|
+
|
|
500
|
+
* Report a condition that affects the whole product or page, such as degraded RPC service or paused deposits.
|
|
501
|
+
* Announce maintenance or a change for every account, such as a new webhook retry policy.
|
|
502
|
+
* Mark the environment, such as a testnet build of Tempo Wallet.
|
|
503
|
+
|
|
504
|
+
#### When Not to Use
|
|
505
|
+
|
|
506
|
+
* Use [Alert](#alert) for a message about one section, form, or field.
|
|
507
|
+
* Use [Toast](#toast) to confirm that an action finished, such as Payment sent.
|
|
508
|
+
* If an action needs a decision before it continues, use [AlertDialog](overlays.md#alertdialog).
|
|
509
|
+
* Use `Field.Error` from [Field](forms-and-inputs.md#field-1) for a validation message on one input.
|
|
510
|
+
|
|
511
|
+
#### Choose an Intent by Severity
|
|
512
|
+
|
|
513
|
+
* **Neutral (neutral):** The default. Announcements with no severity, such as a testnet notice.
|
|
514
|
+
* **Info (info):** Context that needs no action now, such as upcoming maintenance.
|
|
515
|
+
* **Positive (positive):** A resolved condition, such as resumed deposits.
|
|
516
|
+
* **Warning (warning):** Degraded service or a step to take soon, such as delayed deposits.
|
|
517
|
+
* **Negative (negative):** An outage or failure that blocks work, such as paused payments.
|
|
518
|
+
|
|
519
|
+
#### State Severity in the Text
|
|
520
|
+
|
|
521
|
+
Banner has no icon part, so the text carries the severity. The `intent` tint doesn't reach screen reader users or forced-colors modes.
|
|
522
|
+
|
|
523
|
+
**Do:** Name the affected feature and the impact, such as delayed deposits.
|
|
524
|
+
|
|
525
|
+
```tsx
|
|
526
|
+
/**
|
|
527
|
+
* Do example for "State Severity in the Text" on the Banner page.
|
|
528
|
+
* Name the affected feature and the impact, such as delayed deposits.
|
|
529
|
+
* @module
|
|
530
|
+
*/
|
|
531
|
+
import { Banner } from '@tempoxyz/ds'
|
|
532
|
+
|
|
533
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
534
|
+
export function Demo() {
|
|
535
|
+
return (
|
|
536
|
+
<Banner intent="warning">
|
|
537
|
+
<Banner.Content>Deposits from Ethereum are delayed by about 20 minutes.</Banner.Content>
|
|
538
|
+
<Banner.Action>View status</Banner.Action>
|
|
539
|
+
</Banner>
|
|
540
|
+
)
|
|
541
|
+
}
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
**Don't:** Rely on the `negative` tint to say that something is broken.
|
|
545
|
+
|
|
546
|
+
```tsx
|
|
547
|
+
/**
|
|
548
|
+
* Don't example for "State Severity in the Text" on the Banner page.
|
|
549
|
+
* Don't rely on the `negative` tint to say that something is broken.
|
|
550
|
+
* @module
|
|
551
|
+
*/
|
|
552
|
+
import { Banner } from '@tempoxyz/ds'
|
|
553
|
+
|
|
554
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
555
|
+
export function Demo() {
|
|
556
|
+
return (
|
|
557
|
+
<Banner intent="negative">
|
|
558
|
+
<Banner.Content>Heads up</Banner.Content>
|
|
559
|
+
<Banner.Action>Learn more</Banner.Action>
|
|
560
|
+
</Banner>
|
|
561
|
+
)
|
|
562
|
+
}
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
#### Show One Banner at a Time
|
|
566
|
+
|
|
567
|
+
Hold the less severe messages until the current one clears. Place the banner above the page header.
|
|
568
|
+
|
|
569
|
+
**Do:** Show the single most urgent banner above the page content.
|
|
570
|
+
|
|
571
|
+
```tsx
|
|
572
|
+
/**
|
|
573
|
+
* Do example for "Show One Banner at a Time" on the Banner page.
|
|
574
|
+
* Show the single most urgent banner above the page content.
|
|
575
|
+
* @module
|
|
576
|
+
*/
|
|
577
|
+
import { Banner, style } from '@tempoxyz/ds'
|
|
578
|
+
|
|
579
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
580
|
+
export function Demo() {
|
|
581
|
+
return (
|
|
582
|
+
<div {...styles.page()}>
|
|
583
|
+
<Banner intent="negative">
|
|
584
|
+
<Banner.Content>Payments are paused while we fix an RPC outage.</Banner.Content>
|
|
585
|
+
</Banner>
|
|
586
|
+
<div {...styles.content()}>
|
|
587
|
+
<div {...styles.label()}>Balance</div>
|
|
588
|
+
<div {...styles.value()}>$1,250.00</div>
|
|
589
|
+
</div>
|
|
590
|
+
</div>
|
|
591
|
+
)
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
namespace styles {
|
|
595
|
+
export const content = style({
|
|
596
|
+
display: 'flex',
|
|
597
|
+
flexDirection: 'column',
|
|
598
|
+
gap: '4',
|
|
599
|
+
padding: '16',
|
|
600
|
+
})
|
|
601
|
+
|
|
602
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b3' })
|
|
603
|
+
|
|
604
|
+
export const page = style({ display: 'flex', flexDirection: 'column', width: '100% !custom' })
|
|
605
|
+
|
|
606
|
+
export const value = style({ color: 'content.primary', typography: 'heading.h2' })
|
|
607
|
+
}
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
**Don't:** Stack several banners of different intents.
|
|
611
|
+
|
|
612
|
+
```tsx
|
|
613
|
+
/**
|
|
614
|
+
* Don't example for "Show One Banner at a Time" on the Banner page.
|
|
615
|
+
* Don't stack several banners of different intents.
|
|
616
|
+
* @module
|
|
617
|
+
*/
|
|
618
|
+
import { Banner, style } from '@tempoxyz/ds'
|
|
619
|
+
|
|
620
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
621
|
+
export function Demo() {
|
|
622
|
+
return (
|
|
623
|
+
<div {...styles.page()}>
|
|
624
|
+
<Banner intent="negative">
|
|
625
|
+
<Banner.Content>Payments are paused.</Banner.Content>
|
|
626
|
+
</Banner>
|
|
627
|
+
<Banner intent="info">
|
|
628
|
+
<Banner.Content>Maintenance on Oct 22 at 14:00 UTC.</Banner.Content>
|
|
629
|
+
</Banner>
|
|
630
|
+
<Banner>
|
|
631
|
+
<Banner.Content>Webhooks now retry for 24 hours.</Banner.Content>
|
|
632
|
+
<Banner.Dismiss />
|
|
633
|
+
</Banner>
|
|
634
|
+
</div>
|
|
635
|
+
)
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
namespace styles {
|
|
639
|
+
export const page = style({ display: 'flex', flexDirection: 'column', width: '100% !custom' })
|
|
640
|
+
}
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
#### Limit Dismissal to Announcements
|
|
644
|
+
|
|
645
|
+
`Banner.Dismiss` only renders the button. Remove the banner in its `onClick`, and store the dismissal so the banner doesn't return on the next page.
|
|
646
|
+
|
|
647
|
+
**Do:** Add `Banner.Dismiss` to announcements and `info` messages.
|
|
648
|
+
|
|
649
|
+
```tsx
|
|
650
|
+
/**
|
|
651
|
+
* Do example for "Limit Dismissal to Announcements" on the Banner page.
|
|
652
|
+
* Add `Banner.Dismiss` to announcements and `info` messages.
|
|
653
|
+
* @module
|
|
654
|
+
*/
|
|
655
|
+
import { Banner, style } from '@tempoxyz/ds'
|
|
656
|
+
|
|
657
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
658
|
+
export function Demo() {
|
|
659
|
+
return (
|
|
660
|
+
<div {...styles.page()}>
|
|
661
|
+
<Banner intent="info">
|
|
662
|
+
<Banner.Content>Maintenance starts Oct 22 at 14:00 UTC.</Banner.Content>
|
|
663
|
+
<Banner.Dismiss />
|
|
664
|
+
</Banner>
|
|
665
|
+
</div>
|
|
666
|
+
)
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
namespace styles {
|
|
670
|
+
export const page = style({ display: 'flex', flexDirection: 'column', width: '100% !custom' })
|
|
671
|
+
}
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
**Don't:** Let people dismiss an active outage. Remove the banner when the condition ends.
|
|
675
|
+
|
|
676
|
+
```tsx
|
|
677
|
+
/**
|
|
678
|
+
* Don't example for "Limit Dismissal to Announcements" on the Banner page.
|
|
679
|
+
* Don't let people dismiss an active outage. Remove the banner when the condition ends.
|
|
680
|
+
* @module
|
|
681
|
+
*/
|
|
682
|
+
import { Banner, style } from '@tempoxyz/ds'
|
|
683
|
+
|
|
684
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
685
|
+
export function Demo() {
|
|
686
|
+
return (
|
|
687
|
+
<div {...styles.page()}>
|
|
688
|
+
<Banner intent="negative">
|
|
689
|
+
<Banner.Content>Payments are paused during an RPC outage.</Banner.Content>
|
|
690
|
+
<Banner.Dismiss />
|
|
691
|
+
</Banner>
|
|
692
|
+
</div>
|
|
693
|
+
)
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
namespace styles {
|
|
697
|
+
export const page = style({ display: 'flex', flexDirection: 'column', width: '100% !custom' })
|
|
698
|
+
}
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
#### Offer One Action
|
|
702
|
+
|
|
703
|
+
**Do:** Add at most one `Banner.Action`, such as View status.
|
|
704
|
+
|
|
705
|
+
```tsx
|
|
706
|
+
/**
|
|
707
|
+
* Do example for "Offer One Action" on the Banner page.
|
|
708
|
+
* Add at most one `Banner.Action`, such as View status.
|
|
709
|
+
* @module
|
|
710
|
+
*/
|
|
711
|
+
import { Banner, style } from '@tempoxyz/ds'
|
|
712
|
+
|
|
713
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
714
|
+
export function Demo() {
|
|
715
|
+
return (
|
|
716
|
+
<div {...styles.page()}>
|
|
717
|
+
<Banner intent="warning">
|
|
718
|
+
<Banner.Content>Deposits from Ethereum are delayed by about 20 minutes.</Banner.Content>
|
|
719
|
+
<Banner.Action>View status</Banner.Action>
|
|
720
|
+
</Banner>
|
|
721
|
+
</div>
|
|
722
|
+
)
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
namespace styles {
|
|
726
|
+
export const page = style({ display: 'flex', flexDirection: 'column', width: '100% !custom' })
|
|
727
|
+
}
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
**Don't:** Add several actions to one banner.
|
|
731
|
+
|
|
732
|
+
```tsx
|
|
733
|
+
/** Don't example for "Offer One Action" on the Banner page. Don't add several actions to one banner. @module */
|
|
734
|
+
import { Banner, style } from '@tempoxyz/ds'
|
|
735
|
+
|
|
736
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
737
|
+
export function Demo() {
|
|
738
|
+
return (
|
|
739
|
+
<div {...styles.page()}>
|
|
740
|
+
<Banner intent="warning">
|
|
741
|
+
<Banner.Content>Deposits are delayed.</Banner.Content>
|
|
742
|
+
<Banner.Action>Status</Banner.Action>
|
|
743
|
+
<Banner.Action>Support</Banner.Action>
|
|
744
|
+
<Banner.Action>Retry</Banner.Action>
|
|
745
|
+
</Banner>
|
|
746
|
+
</div>
|
|
747
|
+
)
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
namespace styles {
|
|
751
|
+
export const page = style({ display: 'flex', flexDirection: 'column', width: '100% !custom' })
|
|
752
|
+
}
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
### Content
|
|
756
|
+
|
|
757
|
+
* Lead with what changed and who it affects, then what to do: Deposits from Ethereum are delayed by about 20 minutes.
|
|
758
|
+
* Keep it to one or two short sentences.
|
|
759
|
+
* Give times with a time zone, such as Maintenance starts Oct 22 at 14:00 UTC.
|
|
760
|
+
* Describe the condition, not the intent. Write Payments are paused, not Error or Warning.
|
|
761
|
+
* Name the destination in the action label, such as View status. Avoid Click here and Learn more.
|
|
762
|
+
|
|
763
|
+
### Accessibility
|
|
764
|
+
|
|
765
|
+
Renders a plain `div` with no role and no live region. The action and dismiss controls are native buttons, and the banner never takes focus.
|
|
766
|
+
|
|
767
|
+
#### Semantics
|
|
768
|
+
|
|
769
|
+
* **Banner (div):** Not a landmark or live region. Screen readers read it in order, so place it before the main content.
|
|
770
|
+
* **Banner.Action (button):** To make it a link, pass `render` with a link and `nativeButton={false}`.
|
|
771
|
+
* **Banner.Dismiss (button):** Named "Dismiss" by default. Its close icon is decorative.
|
|
772
|
+
|
|
773
|
+
#### Keyboard
|
|
774
|
+
|
|
775
|
+
* **Move to the Next Control (Tab):** Focuses the action, then the dismiss button.
|
|
776
|
+
* **Activate the Button (Enter or Space):** Activates the action or the dismiss button.
|
|
777
|
+
|
|
778
|
+
#### Your Responsibilities
|
|
779
|
+
|
|
780
|
+
* **Announce Late Banners (role):** If a banner appears after page load, add `role="status"`, or `role="alert"` for an outage.
|
|
781
|
+
* **Move Focus on Dismiss:** After a dismissal, move focus to the start of the main content.
|
|
782
|
+
* **Name Each Dismiss (aria-label):** If a page has several, name each one, such as "Dismiss maintenance notice".
|
|
783
|
+
|
|
784
|
+
### Related
|
|
785
|
+
|
|
786
|
+
[Alert](#alert)
|
|
787
|
+
|
|
788
|
+
Use for a message about one section.
|
|
789
|
+
|
|
790
|
+
[Toast](#toast)
|
|
791
|
+
|
|
792
|
+
Use for confirming a finished action.
|
|
793
|
+
|
|
794
|
+
[AlertDialog](overlays.md#alertdialog)
|
|
795
|
+
|
|
796
|
+
Use for a decision before an action continues.
|
|
797
|
+
|
|
798
|
+
[Feedback and Status](../patterns.md#feedback-and-status)
|
|
799
|
+
|
|
800
|
+
Covers choosing a message component.
|
|
801
|
+
|
|
802
|
+
### Examples
|
|
803
|
+
|
|
804
|
+
#### Basic
|
|
805
|
+
|
|
806
|
+
```tsx
|
|
807
|
+
import { Banner } from '@tempoxyz/ds'
|
|
808
|
+
|
|
809
|
+
export const fill = true
|
|
810
|
+
export function Demo() {
|
|
811
|
+
return (
|
|
812
|
+
<Banner>
|
|
813
|
+
<Banner.Content>Tempo mainnet is live.</Banner.Content>
|
|
814
|
+
<Banner.Action>Read more</Banner.Action>
|
|
815
|
+
<Banner.Dismiss />
|
|
816
|
+
</Banner>
|
|
817
|
+
)
|
|
818
|
+
}
|
|
819
|
+
```
|
|
820
|
+
|
|
821
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Banner/Basic.tsx)
|
|
822
|
+
|
|
823
|
+
#### Intent
|
|
824
|
+
|
|
825
|
+
Set `intent` to `neutral` (default), `info`, `positive`, `warning`, or `negative`.
|
|
826
|
+
|
|
827
|
+
```tsx
|
|
828
|
+
import { Banner, style } from '@tempoxyz/ds'
|
|
829
|
+
|
|
830
|
+
export const fill = true
|
|
831
|
+
export function Demo() {
|
|
832
|
+
return (
|
|
833
|
+
<div {...styles.stack()}>
|
|
834
|
+
{(['neutral', 'info', 'positive', 'warning', 'negative'] as const).map((intent) => (
|
|
835
|
+
<Banner intent={intent} key={intent}>
|
|
836
|
+
<Banner.Content>Tempo mainnet is live.</Banner.Content>
|
|
837
|
+
<Banner.Action>Read more</Banner.Action>
|
|
838
|
+
<Banner.Dismiss />
|
|
839
|
+
</Banner>
|
|
840
|
+
))}
|
|
841
|
+
</div>
|
|
842
|
+
)
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
namespace styles {
|
|
846
|
+
export const stack = style({ display: 'flex', flexDirection: 'column', gap: '8' })
|
|
847
|
+
}
|
|
848
|
+
```
|
|
849
|
+
|
|
850
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Banner/Intent.tsx)
|
|
851
|
+
|
|
852
|
+
## Callout
|
|
853
|
+
|
|
854
|
+
Sets a short passage of body text apart in a subtle box.
|
|
855
|
+
|
|
856
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Callout.tsx)
|
|
857
|
+
|
|
858
|
+
Figma: [Callout](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=3506-2664)
|
|
859
|
+
|
|
860
|
+
### Overview
|
|
861
|
+
|
|
862
|
+
A callout renders body text in a subtle box, padded 24px above and below and 32px at the sides. It sets a summary or an aside apart from the text around it, and adds no role or announcement.
|
|
863
|
+
|
|
864
|
+
### Anatomy
|
|
865
|
+
|
|
866
|
+
Import the component and assemble its parts.
|
|
867
|
+
|
|
868
|
+
```tsx
|
|
869
|
+
import { Callout } from '@tempoxyz/ds'
|
|
870
|
+
|
|
871
|
+
<Callout />
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
### Guidelines
|
|
875
|
+
|
|
876
|
+
#### When to Use
|
|
877
|
+
|
|
878
|
+
* Set a summary, a definition, or an aside apart from the body of an article or a docs page.
|
|
879
|
+
|
|
880
|
+
#### When Not to Use
|
|
881
|
+
|
|
882
|
+
* Use an [Alert](#alert) for a message about a status or an outcome.
|
|
883
|
+
* Use a [Banner](#banner) for a message about the whole page or product.
|
|
884
|
+
* Use a [Snippet](data-display.md#snippet) for code that people copy.
|
|
885
|
+
|
|
886
|
+
#### Keep the Passage Optional
|
|
887
|
+
|
|
888
|
+
**Do:** Use it for context that a reader can skip without missing a step.
|
|
889
|
+
|
|
890
|
+
```tsx
|
|
891
|
+
<Callout style={{ width: 360 }}>
|
|
892
|
+
Tempo settles a payment in under a second, with fees paid in stablecoins.
|
|
893
|
+
</Callout>
|
|
894
|
+
```
|
|
895
|
+
|
|
896
|
+
**Don't:** Use it for an error or a warning. Use an Alert instead.
|
|
897
|
+
|
|
898
|
+
```tsx
|
|
899
|
+
<Callout style={{ width: 360 }}>Your payment failed. Check the address and try again.</Callout>
|
|
900
|
+
```
|
|
901
|
+
|
|
902
|
+
#### Keep One Callout per Section
|
|
903
|
+
|
|
904
|
+
* **One Passage (1):** Sets one passage apart, so the reader notices it among the body text.
|
|
905
|
+
* **Short Text (3 lines):** Holds a few lines at most. Move a longer passage into the body text.
|
|
906
|
+
|
|
907
|
+
### Content
|
|
908
|
+
|
|
909
|
+
* Write complete sentences in the same voice as the text around the callout.
|
|
910
|
+
* Keep it to one idea in two or three lines.
|
|
911
|
+
|
|
912
|
+
### Accessibility
|
|
913
|
+
|
|
914
|
+
A callout renders a `<div>` with no role, so screen readers read its text in place.
|
|
915
|
+
|
|
916
|
+
* **Root (div):** Reads its text in place, as part of the surrounding content, with no role.
|
|
917
|
+
* **Landmark (role):** If the callout is an aside, set `role="note"` and an `aria-label` that names it.
|
|
918
|
+
* **Contrast (4.5:1):** Renders primary text on the subtle fill, above 4.5:1 in both color schemes.
|
|
919
|
+
|
|
920
|
+
### Related
|
|
921
|
+
|
|
922
|
+
[Alert](#alert)
|
|
923
|
+
|
|
924
|
+
Use for a message about a status or an outcome.
|
|
925
|
+
|
|
926
|
+
[Banner](#banner)
|
|
927
|
+
|
|
928
|
+
Use for a message about the whole page.
|
|
929
|
+
|
|
930
|
+
### Examples
|
|
931
|
+
|
|
932
|
+
#### Basic
|
|
933
|
+
|
|
934
|
+
```tsx
|
|
935
|
+
import { Callout } from '@tempoxyz/ds'
|
|
936
|
+
|
|
937
|
+
export function Demo() {
|
|
938
|
+
return (
|
|
939
|
+
<Callout>
|
|
940
|
+
Stablecoin payments move fiat-referenced digital assets over blockchain networks. The onchain
|
|
941
|
+
transfer is only one part of the end-to-end payment.
|
|
942
|
+
</Callout>
|
|
943
|
+
)
|
|
944
|
+
}
|
|
945
|
+
```
|
|
946
|
+
|
|
947
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Callout/Basic.tsx)
|
|
948
|
+
|
|
949
|
+
## Empty
|
|
950
|
+
|
|
951
|
+
Fills a region that has nothing to show yet.
|
|
952
|
+
|
|
953
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Empty.tsx)
|
|
954
|
+
|
|
955
|
+
Figma: [Messaging/Progress Panel](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-3967) (`Empty.Root`)
|
|
956
|
+
|
|
957
|
+
### Overview
|
|
958
|
+
|
|
959
|
+
A centered placeholder with a title, a description, an optional icon, and actions.
|
|
960
|
+
|
|
961
|
+
### Anatomy
|
|
962
|
+
|
|
963
|
+
Import the component and assemble its parts.
|
|
964
|
+
|
|
965
|
+
```tsx
|
|
966
|
+
import { Empty } from '@tempoxyz/ds'
|
|
967
|
+
|
|
968
|
+
<Empty.Root>
|
|
969
|
+
<Empty.Icon />
|
|
970
|
+
<Empty.Title />
|
|
971
|
+
<Empty.Description />
|
|
972
|
+
<Empty.Actions />
|
|
973
|
+
</Empty.Root>
|
|
974
|
+
```
|
|
975
|
+
|
|
976
|
+
### Guidelines
|
|
977
|
+
|
|
978
|
+
#### When to Use
|
|
979
|
+
|
|
980
|
+
* Fill a list or table with no records yet.
|
|
981
|
+
* Replace results when a search or filter matches nothing.
|
|
982
|
+
* Confirm that a list is clear on purpose, such as a retry queue with nothing left.
|
|
983
|
+
|
|
984
|
+
#### When Not to Use
|
|
985
|
+
|
|
986
|
+
* Use [Skeleton](#skeleton) while the request runs. Show the empty state only after it returns no records.
|
|
987
|
+
* Use a `negative` [Alert](#alert) with a Retry action if the data fails to load.
|
|
988
|
+
* Use `Combobox.Empty` of [Combobox](forms-and-inputs.md#combobox) or `Autocomplete.Empty` of [Autocomplete](forms-and-inputs.md#autocomplete) for a popup list with no matches.
|
|
989
|
+
|
|
990
|
+
#### Explain Why, Then Offer a Next Step
|
|
991
|
+
|
|
992
|
+
* **`Empty.Title`:** States what belongs here.
|
|
993
|
+
* **`Empty.Description`:** States why there is nothing.
|
|
994
|
+
* **`Empty.Actions`:** Holds a [Button](actions.md#button) for the next step.
|
|
995
|
+
|
|
996
|
+
**Do:** Say what will appear and offer the action that adds it.
|
|
997
|
+
|
|
998
|
+
```tsx
|
|
999
|
+
/**
|
|
1000
|
+
* Do example for "Explain Why, Then Offer a Next Step" on the Empty page.
|
|
1001
|
+
* Say what will appear and offer the action that adds it.
|
|
1002
|
+
* @module
|
|
1003
|
+
*/
|
|
1004
|
+
import { Button, Empty } from '@tempoxyz/ds'
|
|
1005
|
+
import { Key } from '@tempoxyz/ds/icons'
|
|
1006
|
+
|
|
1007
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1008
|
+
export function Demo() {
|
|
1009
|
+
return (
|
|
1010
|
+
<Empty.Root>
|
|
1011
|
+
<Empty.Icon>
|
|
1012
|
+
<Key />
|
|
1013
|
+
</Empty.Icon>
|
|
1014
|
+
<Empty.Title>No API keys yet</Empty.Title>
|
|
1015
|
+
<Empty.Description>Create a key to call the Tempo API from your server.</Empty.Description>
|
|
1016
|
+
<Empty.Actions>
|
|
1017
|
+
<Button size="small">Create key</Button>
|
|
1018
|
+
</Empty.Actions>
|
|
1019
|
+
</Empty.Root>
|
|
1020
|
+
)
|
|
1021
|
+
}
|
|
1022
|
+
```
|
|
1023
|
+
|
|
1024
|
+
**Don't:** Show a bare No data with no reason or next step.
|
|
1025
|
+
|
|
1026
|
+
```tsx
|
|
1027
|
+
/**
|
|
1028
|
+
* Don't example for "Explain Why, Then Offer a Next Step" on the Empty page.
|
|
1029
|
+
* Don't show a bare No data with no reason or next step.
|
|
1030
|
+
* @module
|
|
1031
|
+
*/
|
|
1032
|
+
import { Empty } from '@tempoxyz/ds'
|
|
1033
|
+
|
|
1034
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1035
|
+
export function Demo() {
|
|
1036
|
+
return (
|
|
1037
|
+
<Empty.Root>
|
|
1038
|
+
<Empty.Title>No data</Empty.Title>
|
|
1039
|
+
</Empty.Root>
|
|
1040
|
+
)
|
|
1041
|
+
}
|
|
1042
|
+
```
|
|
1043
|
+
|
|
1044
|
+
#### Match the Message to the Cause
|
|
1045
|
+
|
|
1046
|
+
* **Nothing Created Yet:** Offer the action that adds the first item.
|
|
1047
|
+
* **No Search Results:** Repeat the query and offer to clear it.
|
|
1048
|
+
* **Filters Exclude All:** Offer to clear the filters.
|
|
1049
|
+
* **Cleared on Purpose:** Offer no action, or a link to the logs.
|
|
1050
|
+
|
|
1051
|
+
#### Offer One Primary Action
|
|
1052
|
+
|
|
1053
|
+
Add a `secondary` button only for a real alternative, such as View docs. Use `size="small"` to match the centered text.
|
|
1054
|
+
|
|
1055
|
+
**Do:** Give `Empty.Actions` one `primary` button that resolves the empty state.
|
|
1056
|
+
|
|
1057
|
+
```tsx
|
|
1058
|
+
/**
|
|
1059
|
+
* Do example for "Offer One Primary Action" on the Empty page.
|
|
1060
|
+
* Give `Empty.Actions` one `primary` button that resolves the empty state.
|
|
1061
|
+
* @module
|
|
1062
|
+
*/
|
|
1063
|
+
import { Button, Empty } from '@tempoxyz/ds'
|
|
1064
|
+
import { Key } from '@tempoxyz/ds/icons'
|
|
1065
|
+
|
|
1066
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1067
|
+
export function Demo() {
|
|
1068
|
+
return (
|
|
1069
|
+
<Empty.Root>
|
|
1070
|
+
<Empty.Icon>
|
|
1071
|
+
<Key />
|
|
1072
|
+
</Empty.Icon>
|
|
1073
|
+
<Empty.Title>No API keys yet</Empty.Title>
|
|
1074
|
+
<Empty.Description>Create a key to call the Tempo API from your server.</Empty.Description>
|
|
1075
|
+
<Empty.Actions>
|
|
1076
|
+
<Button size="small" variant="secondary">
|
|
1077
|
+
View docs
|
|
1078
|
+
</Button>
|
|
1079
|
+
<Button size="small">Create key</Button>
|
|
1080
|
+
</Empty.Actions>
|
|
1081
|
+
</Empty.Root>
|
|
1082
|
+
)
|
|
1083
|
+
}
|
|
1084
|
+
```
|
|
1085
|
+
|
|
1086
|
+
**Don't:** Offer several `primary` buttons.
|
|
1087
|
+
|
|
1088
|
+
```tsx
|
|
1089
|
+
/** Don't example for "Offer One Primary Action" on the Empty page. Don't offer several `primary` buttons. @module */
|
|
1090
|
+
import { Button, Empty } from '@tempoxyz/ds'
|
|
1091
|
+
import { Key } from '@tempoxyz/ds/icons'
|
|
1092
|
+
|
|
1093
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1094
|
+
export function Demo() {
|
|
1095
|
+
return (
|
|
1096
|
+
<Empty.Root>
|
|
1097
|
+
<Empty.Icon>
|
|
1098
|
+
<Key />
|
|
1099
|
+
</Empty.Icon>
|
|
1100
|
+
<Empty.Title>No API keys yet</Empty.Title>
|
|
1101
|
+
<Empty.Description>Create a key to call the Tempo API from your server.</Empty.Description>
|
|
1102
|
+
<Empty.Actions>
|
|
1103
|
+
<Button size="small">View docs</Button>
|
|
1104
|
+
<Button size="small">Import key</Button>
|
|
1105
|
+
<Button size="small">Create key</Button>
|
|
1106
|
+
</Empty.Actions>
|
|
1107
|
+
</Empty.Root>
|
|
1108
|
+
)
|
|
1109
|
+
}
|
|
1110
|
+
```
|
|
1111
|
+
|
|
1112
|
+
#### Keep It Inside the Region It Replaces
|
|
1113
|
+
|
|
1114
|
+
**Do:** Render `Empty.Root` in place of the list or table body. Keep the heading and filters around it.
|
|
1115
|
+
|
|
1116
|
+
```tsx
|
|
1117
|
+
/**
|
|
1118
|
+
* Do example for "Keep It Inside the Region It Replaces" on the Empty page.
|
|
1119
|
+
* Render `Empty.Root` in place of the list or table body. Keep the heading and filters around it.
|
|
1120
|
+
* @module
|
|
1121
|
+
*/
|
|
1122
|
+
import { Empty, style, Surface, TextInput } from '@tempoxyz/ds'
|
|
1123
|
+
import { Search } from '@tempoxyz/ds/icons'
|
|
1124
|
+
|
|
1125
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1126
|
+
export function Demo() {
|
|
1127
|
+
return (
|
|
1128
|
+
<Surface size="medium" {...styles.card()}>
|
|
1129
|
+
<div {...styles.heading()}>Payments</div>
|
|
1130
|
+
<TextInput.Group>
|
|
1131
|
+
<TextInput.Prefix>
|
|
1132
|
+
<Search />
|
|
1133
|
+
</TextInput.Prefix>
|
|
1134
|
+
<TextInput.Control aria-label="Search payments" defaultValue="0x8f3c" />
|
|
1135
|
+
</TextInput.Group>
|
|
1136
|
+
<Empty.Root>
|
|
1137
|
+
<Empty.Title>No results for "0x8f3c"</Empty.Title>
|
|
1138
|
+
<Empty.Description>Check the address, or search by amount.</Empty.Description>
|
|
1139
|
+
</Empty.Root>
|
|
1140
|
+
</Surface>
|
|
1141
|
+
)
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
namespace styles {
|
|
1145
|
+
export const card = style({
|
|
1146
|
+
boxSizing: 'border-box',
|
|
1147
|
+
display: 'flex',
|
|
1148
|
+
flexDirection: 'column',
|
|
1149
|
+
gap: '16',
|
|
1150
|
+
width: '100% !custom',
|
|
1151
|
+
})
|
|
1152
|
+
|
|
1153
|
+
export const heading = style({ color: 'content.primary', typography: 'body.b1Strong' })
|
|
1154
|
+
}
|
|
1155
|
+
```
|
|
1156
|
+
|
|
1157
|
+
**Don't:** Replace the heading and filters with the empty state.
|
|
1158
|
+
|
|
1159
|
+
```tsx
|
|
1160
|
+
/**
|
|
1161
|
+
* Don't example for "Keep It Inside the Region It Replaces" on the Empty page.
|
|
1162
|
+
* Don't replace the heading and filters with the empty state.
|
|
1163
|
+
* @module
|
|
1164
|
+
*/
|
|
1165
|
+
import { Empty, style, Surface } from '@tempoxyz/ds'
|
|
1166
|
+
|
|
1167
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1168
|
+
export function Demo() {
|
|
1169
|
+
return (
|
|
1170
|
+
<Surface size="medium" {...styles.card()}>
|
|
1171
|
+
<Empty.Root>
|
|
1172
|
+
<Empty.Title>No results for "0x8f3c"</Empty.Title>
|
|
1173
|
+
<Empty.Description>Check the address, or search by amount.</Empty.Description>
|
|
1174
|
+
</Empty.Root>
|
|
1175
|
+
</Surface>
|
|
1176
|
+
)
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
namespace styles {
|
|
1180
|
+
export const card = style({
|
|
1181
|
+
boxSizing: 'border-box',
|
|
1182
|
+
display: 'flex',
|
|
1183
|
+
flexDirection: 'column',
|
|
1184
|
+
gap: '16',
|
|
1185
|
+
width: '100% !custom',
|
|
1186
|
+
})
|
|
1187
|
+
}
|
|
1188
|
+
```
|
|
1189
|
+
|
|
1190
|
+
Use `Empty.Icon` for an icon that names the content type, such as `Key` for API keys. Leave out status icons such as `AlertTriangle`.
|
|
1191
|
+
|
|
1192
|
+
### Content
|
|
1193
|
+
|
|
1194
|
+
* **Title:** State what is missing, such as No activity yet, without a period.
|
|
1195
|
+
* **Description:** In one sentence, state when content appears or why it is hidden, such as Transactions appear here once you send or receive. It wraps at 22.5rem.
|
|
1196
|
+
* **Tone:** Avoid blame and jokes. Write No payments match these filters, not You haven't made any payments.
|
|
1197
|
+
* **Action:** Start with a verb and name the object, such as Create key. Avoid Get started.
|
|
1198
|
+
|
|
1199
|
+
### Accessibility
|
|
1200
|
+
|
|
1201
|
+
An empty state renders plain elements with no ARIA wiring, in the order you compose them.
|
|
1202
|
+
|
|
1203
|
+
#### Semantics
|
|
1204
|
+
|
|
1205
|
+
* **Empty.Title (h3):** Titles the empty state below a section heading.
|
|
1206
|
+
* **Empty.Description (p):** Explains why the area is empty or what to do.
|
|
1207
|
+
* **Empty.Icon (aria-hidden):** A decorative badge that screen readers skip.
|
|
1208
|
+
* **Empty.Actions:** Holds the buttons or links you pass.
|
|
1209
|
+
|
|
1210
|
+
#### Keyboard
|
|
1211
|
+
|
|
1212
|
+
* **Move Through the Actions (Tab):** Moves focus to each action, in order.
|
|
1213
|
+
* **Activate an Action (Enter or Space):** Actions keep native keys and focus outlines.
|
|
1214
|
+
|
|
1215
|
+
#### Your Responsibilities
|
|
1216
|
+
|
|
1217
|
+
* **Keep the Heading Order (h2 then h3):** Put the empty state under a section heading to keep the outline in order (SC 1.3.1).
|
|
1218
|
+
* **Announce New Results (role="status"):** Not a live region. If it replaces results after a search, announce it in a status element.
|
|
1219
|
+
|
|
1220
|
+
### Related
|
|
1221
|
+
|
|
1222
|
+
[Skeleton](#skeleton)
|
|
1223
|
+
|
|
1224
|
+
Use for content that is still loading.
|
|
1225
|
+
|
|
1226
|
+
[Alert](#alert)
|
|
1227
|
+
|
|
1228
|
+
Use for a failed load with a retry.
|
|
1229
|
+
|
|
1230
|
+
[Button](actions.md#button)
|
|
1231
|
+
|
|
1232
|
+
Use for the action that fills the state.
|
|
1233
|
+
|
|
1234
|
+
[Empty States](../patterns.md#empty-states)
|
|
1235
|
+
|
|
1236
|
+
Covers first-use, no-results, and cleared states.
|
|
1237
|
+
|
|
1238
|
+
### Examples
|
|
1239
|
+
|
|
1240
|
+
#### Basic
|
|
1241
|
+
|
|
1242
|
+
```tsx
|
|
1243
|
+
import { Button, Empty } from '@tempoxyz/ds'
|
|
1244
|
+
import { Clipboard } from '@tempoxyz/ds/icons'
|
|
1245
|
+
|
|
1246
|
+
export function Demo() {
|
|
1247
|
+
return (
|
|
1248
|
+
<Empty.Root>
|
|
1249
|
+
<Empty.Icon>
|
|
1250
|
+
<Clipboard />
|
|
1251
|
+
</Empty.Icon>
|
|
1252
|
+
<Empty.Title>No activity yet</Empty.Title>
|
|
1253
|
+
<Empty.Description>Transactions will appear here once you send or receive.</Empty.Description>
|
|
1254
|
+
<Empty.Actions>
|
|
1255
|
+
<Button size="small">Refresh</Button>
|
|
1256
|
+
<Button size="small" variant="secondary">
|
|
1257
|
+
Learn more
|
|
1258
|
+
</Button>
|
|
1259
|
+
</Empty.Actions>
|
|
1260
|
+
</Empty.Root>
|
|
1261
|
+
)
|
|
1262
|
+
}
|
|
1263
|
+
```
|
|
1264
|
+
|
|
1265
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Empty/Basic.tsx)
|
|
1266
|
+
|
|
1267
|
+
#### Progress
|
|
1268
|
+
|
|
1269
|
+
Use a [Spinner](#spinner) instead of the icon while the region waits on another task, such as a checkout in another window. Frame it in a `medium` [Surface](layout.md#surface) for a panel.
|
|
1270
|
+
|
|
1271
|
+
```tsx
|
|
1272
|
+
/** An empty state in a medium surface that waits on a checkout in another window. @module */
|
|
1273
|
+
import { Empty, Spinner, Surface } from '@tempoxyz/ds'
|
|
1274
|
+
|
|
1275
|
+
export function Demo() {
|
|
1276
|
+
return (
|
|
1277
|
+
<Surface size="medium">
|
|
1278
|
+
<Empty.Root>
|
|
1279
|
+
<Spinner aria-label="Waiting for checkout" />
|
|
1280
|
+
<Empty.Title>Finish checkout in the window that opened</Empty.Title>
|
|
1281
|
+
<Empty.Description>Buying $10.00 of MACH. This updates when it lands.</Empty.Description>
|
|
1282
|
+
</Empty.Root>
|
|
1283
|
+
</Surface>
|
|
1284
|
+
)
|
|
1285
|
+
}
|
|
1286
|
+
```
|
|
1287
|
+
|
|
1288
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Empty/Progress.tsx)
|
|
1289
|
+
|
|
1290
|
+
## Gauge
|
|
1291
|
+
|
|
1292
|
+
Shows a measurement within a range as a ring.
|
|
1293
|
+
|
|
1294
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Gauge.tsx)
|
|
1295
|
+
|
|
1296
|
+
### Overview
|
|
1297
|
+
|
|
1298
|
+
A gauge is a ring that shows a measurement within a range, such as usage or a score.
|
|
1299
|
+
|
|
1300
|
+
### Anatomy
|
|
1301
|
+
|
|
1302
|
+
Import the component and assemble its parts.
|
|
1303
|
+
|
|
1304
|
+
```tsx
|
|
1305
|
+
import { Gauge } from '@tempoxyz/ds'
|
|
1306
|
+
|
|
1307
|
+
<Gauge />
|
|
1308
|
+
```
|
|
1309
|
+
|
|
1310
|
+
### Guidelines
|
|
1311
|
+
|
|
1312
|
+
#### When to Use
|
|
1313
|
+
|
|
1314
|
+
* Show how much of a limit is used, such as API requests against a quota.
|
|
1315
|
+
* Show a ratio in a metric tile, such as gas used against the gas limit.
|
|
1316
|
+
* Show a score with a fixed range, such as validator uptime.
|
|
1317
|
+
|
|
1318
|
+
#### When Not to Use
|
|
1319
|
+
|
|
1320
|
+
* Use [Progress](#progress-1) for a task that advances, such as an upload.
|
|
1321
|
+
* Use [Skeleton](#skeleton) or [Spinner](#spinner) while the measurement loads.
|
|
1322
|
+
* Use [Slider](forms-and-inputs.md#slider) when the user sets the value.
|
|
1323
|
+
* Use plain text if the value has no fixed maximum, such as 4,812 TPS.
|
|
1324
|
+
|
|
1325
|
+
#### Show the Value in Text
|
|
1326
|
+
|
|
1327
|
+
Set `showValue` to print the percentage in the ring.
|
|
1328
|
+
|
|
1329
|
+
**Do:** Pair the ring with its label and the absolute values beside it.
|
|
1330
|
+
|
|
1331
|
+
```tsx
|
|
1332
|
+
/**
|
|
1333
|
+
* Do example for "Show the Value in Text" on the Gauge page.
|
|
1334
|
+
* Pair the ring with its label and the absolute values beside it.
|
|
1335
|
+
* @module
|
|
1336
|
+
*/
|
|
1337
|
+
import { Gauge, style } from '@tempoxyz/ds'
|
|
1338
|
+
|
|
1339
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1340
|
+
export function Demo() {
|
|
1341
|
+
return (
|
|
1342
|
+
<div {...styles.row()}>
|
|
1343
|
+
<Gauge aria-labelledby="gauge-requests" max={10000} showValue value={7200} />
|
|
1344
|
+
<div {...styles.text()}>
|
|
1345
|
+
<div {...styles.label()} id="gauge-requests">
|
|
1346
|
+
API requests this month
|
|
1347
|
+
</div>
|
|
1348
|
+
<div {...styles.value()}>7,200 of 10,000</div>
|
|
1349
|
+
</div>
|
|
1350
|
+
</div>
|
|
1351
|
+
)
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
namespace styles {
|
|
1355
|
+
export const label = style({ color: 'content.primary', typography: 'body.b2' })
|
|
1356
|
+
|
|
1357
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
1358
|
+
|
|
1359
|
+
export const text = style({ display: 'flex', flexDirection: 'column', gap: '4' })
|
|
1360
|
+
|
|
1361
|
+
export const value = style({ color: 'content.secondary', typography: 'body.b3' })
|
|
1362
|
+
}
|
|
1363
|
+
```
|
|
1364
|
+
|
|
1365
|
+
**Don't:** Show a ring without its value or what it measures.
|
|
1366
|
+
|
|
1367
|
+
```tsx
|
|
1368
|
+
/**
|
|
1369
|
+
* Don't example for "Show the Value in Text" on the Gauge page.
|
|
1370
|
+
* Don't show a ring without its value or what it measures.
|
|
1371
|
+
* @module
|
|
1372
|
+
*/
|
|
1373
|
+
import { Gauge } from '@tempoxyz/ds'
|
|
1374
|
+
|
|
1375
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1376
|
+
export function Demo() {
|
|
1377
|
+
return <Gauge aria-label="Usage" max={10000} value={7200} />
|
|
1378
|
+
}
|
|
1379
|
+
```
|
|
1380
|
+
|
|
1381
|
+
#### Pass the Real Range
|
|
1382
|
+
|
|
1383
|
+
The ring, `showValue`, and the accessible value derive the percentage from `min` (default 0) and `max` (default 100).
|
|
1384
|
+
|
|
1385
|
+
**Do:** Set `max` to the actual bound, such as `value={7200}` with `max={10000}`.
|
|
1386
|
+
|
|
1387
|
+
```tsx
|
|
1388
|
+
/**
|
|
1389
|
+
* Do example for "Pass the Real Range" on the Gauge page.
|
|
1390
|
+
* Set `max` to the actual bound, such as `value={7200}` with `max={10000}`.
|
|
1391
|
+
* @module
|
|
1392
|
+
*/
|
|
1393
|
+
import { Gauge, style } from '@tempoxyz/ds'
|
|
1394
|
+
|
|
1395
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1396
|
+
export function Demo() {
|
|
1397
|
+
return (
|
|
1398
|
+
<div {...styles.row()}>
|
|
1399
|
+
<Gauge aria-labelledby="gauge-range" max={10000} showValue value={7200} />
|
|
1400
|
+
<div {...styles.text()}>
|
|
1401
|
+
<div {...styles.label()} id="gauge-range">
|
|
1402
|
+
API requests this month
|
|
1403
|
+
</div>
|
|
1404
|
+
<div {...styles.value()}>7,200 of 10,000</div>
|
|
1405
|
+
</div>
|
|
1406
|
+
</div>
|
|
1407
|
+
)
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
namespace styles {
|
|
1411
|
+
export const label = style({ color: 'content.primary', typography: 'body.b2' })
|
|
1412
|
+
|
|
1413
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
1414
|
+
|
|
1415
|
+
export const text = style({ display: 'flex', flexDirection: 'column', gap: '4' })
|
|
1416
|
+
|
|
1417
|
+
export const value = style({ color: 'content.secondary', typography: 'body.b3' })
|
|
1418
|
+
}
|
|
1419
|
+
```
|
|
1420
|
+
|
|
1421
|
+
**Don't:** Pass a raw count against the default `max` of 100.
|
|
1422
|
+
|
|
1423
|
+
```tsx
|
|
1424
|
+
/**
|
|
1425
|
+
* Don't example for "Pass the Real Range" on the Gauge page.
|
|
1426
|
+
* Don't pass a raw count against the default `max` of 100.
|
|
1427
|
+
* @module
|
|
1428
|
+
*/
|
|
1429
|
+
import { Gauge, style } from '@tempoxyz/ds'
|
|
1430
|
+
|
|
1431
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1432
|
+
export function Demo() {
|
|
1433
|
+
return (
|
|
1434
|
+
<div {...styles.row()}>
|
|
1435
|
+
<Gauge aria-labelledby="gauge-default" showValue value={7200} />
|
|
1436
|
+
<div {...styles.text()}>
|
|
1437
|
+
<div {...styles.label()} id="gauge-default">
|
|
1438
|
+
API requests this month
|
|
1439
|
+
</div>
|
|
1440
|
+
<div {...styles.value()}>7,200 of 10,000</div>
|
|
1441
|
+
</div>
|
|
1442
|
+
</div>
|
|
1443
|
+
)
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
namespace styles {
|
|
1447
|
+
export const label = style({ color: 'content.primary', typography: 'body.b2' })
|
|
1448
|
+
|
|
1449
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
1450
|
+
|
|
1451
|
+
export const text = style({ display: 'flex', flexDirection: 'column', gap: '4' })
|
|
1452
|
+
|
|
1453
|
+
export const value = style({ color: 'content.secondary', typography: 'body.b3' })
|
|
1454
|
+
}
|
|
1455
|
+
```
|
|
1456
|
+
|
|
1457
|
+
#### Choose an Intent
|
|
1458
|
+
|
|
1459
|
+
* **Most Measurements (neutral):** The default, for a measurement such as API requests against a quota.
|
|
1460
|
+
* **Full Is Good (positive):** A measurement where a full value is good, such as 100% uptime.
|
|
1461
|
+
* **Nearing a Limit (Alert):** There is no `warning` intent. Add a `warning` [Alert](#alert) with the next step.
|
|
1462
|
+
|
|
1463
|
+
#### Match Size to Context
|
|
1464
|
+
|
|
1465
|
+
* **Small (32px):** Table cells and dense lists. Print the value beside it.
|
|
1466
|
+
* **Medium (48px):** The default, for metric tiles and cards.
|
|
1467
|
+
* **Large (80px):** A featured measurement, such as plan usage in billing.
|
|
1468
|
+
|
|
1469
|
+
### Content
|
|
1470
|
+
|
|
1471
|
+
* **Label:** Name the measurement, not the component, such as Gas used.
|
|
1472
|
+
|
|
1473
|
+
### Accessibility
|
|
1474
|
+
|
|
1475
|
+
A gauge renders a `meter`. It follows the [WAI-ARIA Authoring Practices meter pattern](https://www.w3.org/WAI/ARIA/apg/patterns/meter/). It is not a live region, so a changed value is read only on the next visit.
|
|
1476
|
+
|
|
1477
|
+
#### Semantics
|
|
1478
|
+
|
|
1479
|
+
* **Root (meter):** Reports its minimum, maximum, and value to assistive technology.
|
|
1480
|
+
* **Value Text (72%):** Defaults to the value as a locale-formatted percentage of the range.
|
|
1481
|
+
* **Ring (aria-hidden):** Hidden. Assistive technology reads the value text instead.
|
|
1482
|
+
* **Visible Value (showValue):** Shows the number. It ignores `format`, which changes only the announced text.
|
|
1483
|
+
* **Arc Color (foreground):** Green for positive intent, on a gray track. Keep the gauge on a plain surface.
|
|
1484
|
+
* **Reduced Motion (reduce):** Under reduced motion, the arc doesn't animate between values.
|
|
1485
|
+
|
|
1486
|
+
#### Your Responsibilities
|
|
1487
|
+
|
|
1488
|
+
* **Name the Gauge (SC 4.1.2):** Use `aria-label` or `aria-labelledby`. The gauge renders no label.
|
|
1489
|
+
* **Describe Non-Percentage Values (getAriaValueText):** Use it if a percentage doesn't describe the value, such as "7.2 of 10 GB".
|
|
1490
|
+
|
|
1491
|
+
### Related
|
|
1492
|
+
|
|
1493
|
+
[Progress](#progress-1)
|
|
1494
|
+
|
|
1495
|
+
Use for a task that advances.
|
|
1496
|
+
|
|
1497
|
+
[Alert](#alert)
|
|
1498
|
+
|
|
1499
|
+
Use for a warning when usage nears a limit.
|
|
1500
|
+
|
|
1501
|
+
[Dashboards](../patterns.md#dashboards)
|
|
1502
|
+
|
|
1503
|
+
Covers laying out metric tiles.
|
|
1504
|
+
|
|
1505
|
+
### Examples
|
|
1506
|
+
|
|
1507
|
+
#### Basic
|
|
1508
|
+
|
|
1509
|
+
```tsx
|
|
1510
|
+
import { Gauge } from '@tempoxyz/ds'
|
|
1511
|
+
|
|
1512
|
+
export function Demo() {
|
|
1513
|
+
return <Gauge aria-label="Storage used" showValue value={72} />
|
|
1514
|
+
}
|
|
1515
|
+
```
|
|
1516
|
+
|
|
1517
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Gauge/Basic.tsx)
|
|
1518
|
+
|
|
1519
|
+
#### Intent
|
|
1520
|
+
|
|
1521
|
+
Set `intent` to `neutral` (default) or `positive`.
|
|
1522
|
+
|
|
1523
|
+
```tsx
|
|
1524
|
+
import { Gauge, style } from '@tempoxyz/ds'
|
|
1525
|
+
|
|
1526
|
+
export function Demo() {
|
|
1527
|
+
return (
|
|
1528
|
+
<div {...styles.row()}>
|
|
1529
|
+
{(['neutral', 'positive'] as const).map((intent, index) => (
|
|
1530
|
+
<Gauge aria-label={intent} intent={intent} key={intent} showValue value={20 + index * 20} />
|
|
1531
|
+
))}
|
|
1532
|
+
</div>
|
|
1533
|
+
)
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
namespace styles {
|
|
1537
|
+
export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '16' })
|
|
1538
|
+
}
|
|
1539
|
+
```
|
|
1540
|
+
|
|
1541
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Gauge/Intent.tsx)
|
|
1542
|
+
|
|
1543
|
+
#### Size
|
|
1544
|
+
|
|
1545
|
+
Set `size` to `small`, `medium` (default), or `large`.
|
|
1546
|
+
|
|
1547
|
+
```tsx
|
|
1548
|
+
import { Gauge, style } from '@tempoxyz/ds'
|
|
1549
|
+
|
|
1550
|
+
export function Demo() {
|
|
1551
|
+
return (
|
|
1552
|
+
<div {...styles.row()}>
|
|
1553
|
+
<Gauge aria-label="Small" size="small" value={72} />
|
|
1554
|
+
<Gauge aria-label="Medium" size="medium" value={72} />
|
|
1555
|
+
<Gauge aria-label="Large" showValue size="large" value={72} />
|
|
1556
|
+
</div>
|
|
1557
|
+
)
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
namespace styles {
|
|
1561
|
+
export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '16' })
|
|
1562
|
+
}
|
|
1563
|
+
```
|
|
1564
|
+
|
|
1565
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Gauge/Size.tsx)
|
|
1566
|
+
|
|
1567
|
+
#### ShowValue
|
|
1568
|
+
|
|
1569
|
+
Set `showValue` to print the value inside the ring.
|
|
1570
|
+
|
|
1571
|
+
```tsx
|
|
1572
|
+
import { Gauge, style } from '@tempoxyz/ds'
|
|
1573
|
+
|
|
1574
|
+
export function Demo() {
|
|
1575
|
+
return (
|
|
1576
|
+
<div {...styles.row()}>
|
|
1577
|
+
<Gauge aria-label="Hidden value" value={40} />
|
|
1578
|
+
<Gauge aria-label="Shown value" showValue value={40} />
|
|
1579
|
+
</div>
|
|
1580
|
+
)
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
namespace styles {
|
|
1584
|
+
export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '16' })
|
|
1585
|
+
}
|
|
1586
|
+
```
|
|
1587
|
+
|
|
1588
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Gauge/ShowValue.tsx)
|
|
1589
|
+
|
|
1590
|
+
## LoadingDots
|
|
1591
|
+
|
|
1592
|
+
Shows three pulsing dots for inline loading.
|
|
1593
|
+
|
|
1594
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/LoadingDots.tsx)
|
|
1595
|
+
|
|
1596
|
+
### Overview
|
|
1597
|
+
|
|
1598
|
+
LoadingDots renders three pulsing dots inline, such as inside a button or beside text.
|
|
1599
|
+
|
|
1600
|
+
### Anatomy
|
|
1601
|
+
|
|
1602
|
+
Import the component and assemble its parts.
|
|
1603
|
+
|
|
1604
|
+
```tsx
|
|
1605
|
+
import { LoadingDots } from '@tempoxyz/ds'
|
|
1606
|
+
|
|
1607
|
+
<LoadingDots />
|
|
1608
|
+
```
|
|
1609
|
+
|
|
1610
|
+
### Guidelines
|
|
1611
|
+
|
|
1612
|
+
#### When to Use
|
|
1613
|
+
|
|
1614
|
+
* Show a short wait inside a line of text, such as Estimating network fee.
|
|
1615
|
+
* Hold the place of one inline value, such as an exchange rate or a recipient name.
|
|
1616
|
+
|
|
1617
|
+
#### When Not to Use
|
|
1618
|
+
|
|
1619
|
+
* Use `loading` on a [Button](actions.md#button) while its action runs.
|
|
1620
|
+
* Use [Spinner](#spinner) for a busy region or control.
|
|
1621
|
+
* Use [Skeleton](#skeleton) for content with a known shape, such as rows or cards.
|
|
1622
|
+
* Use [Progress](#progress-1) for measurable work, or any wait longer than about 10 seconds.
|
|
1623
|
+
|
|
1624
|
+
#### Keep Them in Line With Text
|
|
1625
|
+
|
|
1626
|
+
The dots render as an inline `span`, aligned to the middle of the line in the current text color.
|
|
1627
|
+
|
|
1628
|
+
**Do:** Put the dots after the words that describe the wait.
|
|
1629
|
+
|
|
1630
|
+
```tsx
|
|
1631
|
+
/**
|
|
1632
|
+
* Do example for "Keep Them in Line With Text" on the LoadingDots page.
|
|
1633
|
+
* Put the dots after the words that describe the wait.
|
|
1634
|
+
* @module
|
|
1635
|
+
*/
|
|
1636
|
+
import { LoadingDots, style } from '@tempoxyz/ds'
|
|
1637
|
+
|
|
1638
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1639
|
+
export function Demo() {
|
|
1640
|
+
return (
|
|
1641
|
+
<div {...styles.text()}>
|
|
1642
|
+
Estimating network fee <LoadingDots aria-label="Estimating network fee" size="small" />
|
|
1643
|
+
</div>
|
|
1644
|
+
)
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
namespace styles {
|
|
1648
|
+
export const text = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
1649
|
+
}
|
|
1650
|
+
```
|
|
1651
|
+
|
|
1652
|
+
**Don't:** Fill an empty card with dots in place of its content.
|
|
1653
|
+
|
|
1654
|
+
```tsx
|
|
1655
|
+
/**
|
|
1656
|
+
* Don't example for "Keep Them in Line With Text" on the LoadingDots page.
|
|
1657
|
+
* Don't fill an empty card with dots in place of its content.
|
|
1658
|
+
* @module
|
|
1659
|
+
*/
|
|
1660
|
+
import { LoadingDots, style } from '@tempoxyz/ds'
|
|
1661
|
+
|
|
1662
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1663
|
+
export function Demo() {
|
|
1664
|
+
return (
|
|
1665
|
+
<div {...styles.card()}>
|
|
1666
|
+
<div {...styles.title()}>Activity</div>
|
|
1667
|
+
<div {...styles.body()}>
|
|
1668
|
+
<LoadingDots size="large" />
|
|
1669
|
+
</div>
|
|
1670
|
+
</div>
|
|
1671
|
+
)
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
namespace styles {
|
|
1675
|
+
export const body = style({
|
|
1676
|
+
alignItems: 'center',
|
|
1677
|
+
display: 'flex',
|
|
1678
|
+
height: '100',
|
|
1679
|
+
justifyContent: 'center',
|
|
1680
|
+
})
|
|
1681
|
+
|
|
1682
|
+
export const card = style({
|
|
1683
|
+
borderColor: 'line.secondary',
|
|
1684
|
+
borderRadius: 'xs',
|
|
1685
|
+
borderStyle: 'solid',
|
|
1686
|
+
borderWidth: 'regular',
|
|
1687
|
+
boxSizing: 'border-box',
|
|
1688
|
+
padding: '16',
|
|
1689
|
+
width: '100% !custom',
|
|
1690
|
+
})
|
|
1691
|
+
|
|
1692
|
+
export const title = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
1693
|
+
}
|
|
1694
|
+
```
|
|
1695
|
+
|
|
1696
|
+
#### Show Them Only After a Delay
|
|
1697
|
+
|
|
1698
|
+
* **Fast Responses (Under 300 ms):** Show no dots. Render the value when it arrives.
|
|
1699
|
+
* **Longer Waits (Over 300 ms):** Show the dots after the delay, to avoid a flash.
|
|
1700
|
+
|
|
1701
|
+
#### Replace Them With the Result
|
|
1702
|
+
|
|
1703
|
+
Keep the text length stable so the line does not reflow. If loading fails, show an error message in place of the dots.
|
|
1704
|
+
|
|
1705
|
+
**Do:** Replace the dots with the value when loading finishes.
|
|
1706
|
+
|
|
1707
|
+
```tsx
|
|
1708
|
+
/**
|
|
1709
|
+
* Do example for "Replace Them With the Result" on the LoadingDots page.
|
|
1710
|
+
* Replace the dots with the value when loading finishes.
|
|
1711
|
+
* @module
|
|
1712
|
+
*/
|
|
1713
|
+
import { style } from '@tempoxyz/ds'
|
|
1714
|
+
|
|
1715
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1716
|
+
export function Demo() {
|
|
1717
|
+
return <div {...styles.text()}>Network fee: $0.01</div>
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
namespace styles {
|
|
1721
|
+
export const text = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
1722
|
+
}
|
|
1723
|
+
```
|
|
1724
|
+
|
|
1725
|
+
**Don't:** Leave the dots beside the value after it arrives.
|
|
1726
|
+
|
|
1727
|
+
```tsx
|
|
1728
|
+
/**
|
|
1729
|
+
* Don't example for "Replace Them With the Result" on the LoadingDots page.
|
|
1730
|
+
* Don't leave the dots beside the value after it arrives.
|
|
1731
|
+
* @module
|
|
1732
|
+
*/
|
|
1733
|
+
import { LoadingDots, style } from '@tempoxyz/ds'
|
|
1734
|
+
|
|
1735
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1736
|
+
export function Demo() {
|
|
1737
|
+
return (
|
|
1738
|
+
<div {...styles.text()}>
|
|
1739
|
+
Network fee: $0.01 <LoadingDots aria-label="Estimating network fee" size="small" />
|
|
1740
|
+
</div>
|
|
1741
|
+
)
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
namespace styles {
|
|
1745
|
+
export const text = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
1746
|
+
}
|
|
1747
|
+
```
|
|
1748
|
+
|
|
1749
|
+
#### Size Them to the Text
|
|
1750
|
+
|
|
1751
|
+
* **Small (small):** Dense text, such as table cells.
|
|
1752
|
+
* **Medium (medium):** The default, beside body text.
|
|
1753
|
+
* **Large (large):** Beside larger values or headings.
|
|
1754
|
+
|
|
1755
|
+
### Accessibility
|
|
1756
|
+
|
|
1757
|
+
LoadingDots renders a polite live region named "Loading". The dots carry no text.
|
|
1758
|
+
|
|
1759
|
+
#### Semantics
|
|
1760
|
+
|
|
1761
|
+
* **Root (status):** Announced politely as "Loading" by default, after current speech.
|
|
1762
|
+
* **Custom Name (aria-label):** Replaces the default "Loading" name with a more specific one.
|
|
1763
|
+
* **Reduced Motion (reduce):** If the reader prefers reduced motion, the dots hold still at reduced opacity.
|
|
1764
|
+
|
|
1765
|
+
#### Your Responsibilities
|
|
1766
|
+
|
|
1767
|
+
* **Say What Is Loading (aria-label):** Name it, such as "Estimating network fee", when "Loading" is too vague.
|
|
1768
|
+
* **Keep Visible Text:** The dots are not focusable, and the accessible name is not visible. Keep text beside them.
|
|
1769
|
+
* **Show One per Region:** Many status regions at once, such as one per table row, repeat the announcement.
|
|
1770
|
+
* **Announce the Outcome (SC 4.1.3):** Announce the result or error in a live region when loading finishes.
|
|
1771
|
+
|
|
1772
|
+
### Related
|
|
1773
|
+
|
|
1774
|
+
[Spinner](#spinner)
|
|
1775
|
+
|
|
1776
|
+
Use for a busy region or control.
|
|
1777
|
+
|
|
1778
|
+
[Skeleton](#skeleton)
|
|
1779
|
+
|
|
1780
|
+
Use for content with a known shape.
|
|
1781
|
+
|
|
1782
|
+
[Button](actions.md#button)
|
|
1783
|
+
|
|
1784
|
+
Use for an action's loading state.
|
|
1785
|
+
|
|
1786
|
+
[Loading](../patterns.md#loading)
|
|
1787
|
+
|
|
1788
|
+
Covers choosing a loading indicator.
|
|
1789
|
+
|
|
1790
|
+
### Examples
|
|
1791
|
+
|
|
1792
|
+
#### Basic
|
|
1793
|
+
|
|
1794
|
+
```tsx
|
|
1795
|
+
import { LoadingDots } from '@tempoxyz/ds'
|
|
1796
|
+
|
|
1797
|
+
export function Demo() {
|
|
1798
|
+
return <LoadingDots />
|
|
1799
|
+
}
|
|
1800
|
+
```
|
|
1801
|
+
|
|
1802
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/LoadingDots/Basic.tsx)
|
|
1803
|
+
|
|
1804
|
+
#### Size
|
|
1805
|
+
|
|
1806
|
+
Set `size` to `small`, `medium` (default), or `large`.
|
|
1807
|
+
|
|
1808
|
+
```tsx
|
|
1809
|
+
import { LoadingDots, style } from '@tempoxyz/ds'
|
|
1810
|
+
|
|
1811
|
+
export function Demo() {
|
|
1812
|
+
return (
|
|
1813
|
+
<div {...styles.row()}>
|
|
1814
|
+
{(['small', 'medium', 'large'] as const).map((size) => (
|
|
1815
|
+
<LoadingDots key={size} size={size} />
|
|
1816
|
+
))}
|
|
1817
|
+
</div>
|
|
1818
|
+
)
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
namespace styles {
|
|
1822
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '24' })
|
|
1823
|
+
}
|
|
1824
|
+
```
|
|
1825
|
+
|
|
1826
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/LoadingDots/Size.tsx)
|
|
1827
|
+
|
|
1828
|
+
## Progress
|
|
1829
|
+
|
|
1830
|
+
Shows how far a task has advanced.
|
|
1831
|
+
|
|
1832
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Progress.tsx)
|
|
1833
|
+
|
|
1834
|
+
Figma: [Progress](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=3048-372) (`Progress.Root`)
|
|
1835
|
+
|
|
1836
|
+
### Overview
|
|
1837
|
+
|
|
1838
|
+
A bar that fills in the `intent` color as a task advances, with an optional label and printed value.
|
|
1839
|
+
|
|
1840
|
+
### Anatomy
|
|
1841
|
+
|
|
1842
|
+
Import the component and assemble its parts.
|
|
1843
|
+
|
|
1844
|
+
```tsx
|
|
1845
|
+
import { Progress } from '@tempoxyz/ds'
|
|
1846
|
+
|
|
1847
|
+
<Progress.Root>
|
|
1848
|
+
<Progress.Label />
|
|
1849
|
+
<Progress.Value />
|
|
1850
|
+
<Progress.Track>
|
|
1851
|
+
<Progress.Indicator />
|
|
1852
|
+
</Progress.Track>
|
|
1853
|
+
</Progress.Root>
|
|
1854
|
+
```
|
|
1855
|
+
|
|
1856
|
+
### Guidelines
|
|
1857
|
+
|
|
1858
|
+
#### When to Use
|
|
1859
|
+
|
|
1860
|
+
* Report measurable work, such as an upload of a payouts CSV or an export of 1,240 transactions.
|
|
1861
|
+
* Count through a batch, such as 3 of 5 payments in a payout run.
|
|
1862
|
+
* Track a long sync with a known end, such as block indexing up to the current height.
|
|
1863
|
+
* Show an indeterminate bar for a named task of unknown length, such as a bridge deposit confirmation.
|
|
1864
|
+
|
|
1865
|
+
#### When Not to Use
|
|
1866
|
+
|
|
1867
|
+
* Use [Gauge](#gauge) for a measurement that does not advance, such as storage used.
|
|
1868
|
+
* Use [Spinner](#spinner) for a short wait in a region or control.
|
|
1869
|
+
* Use [Skeleton](#skeleton) for content with a known shape.
|
|
1870
|
+
* Use `loading` on a [Button](actions.md#button) while its action runs.
|
|
1871
|
+
* Use [Stepper](navigation.md#stepper) for a fixed sequence of steps, such as account setup.
|
|
1872
|
+
|
|
1873
|
+
#### Show Determinate Progress When You Can Measure It
|
|
1874
|
+
|
|
1875
|
+
A rough count of steps is enough. Keep `value={null}` for work with no measurable end.
|
|
1876
|
+
|
|
1877
|
+
**Do:** Pass a `value` for an upload whose size you know.
|
|
1878
|
+
|
|
1879
|
+
```tsx
|
|
1880
|
+
/**
|
|
1881
|
+
* Do example for "Show Determinate Progress When You Can Measure It" on the Progress page.
|
|
1882
|
+
* Pass a `value` for an upload whose size you know.
|
|
1883
|
+
* @module
|
|
1884
|
+
*/
|
|
1885
|
+
import { Progress, style } from '@tempoxyz/ds'
|
|
1886
|
+
|
|
1887
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1888
|
+
export function Demo() {
|
|
1889
|
+
return (
|
|
1890
|
+
<Progress.Root value={60} {...styles.progress()}>
|
|
1891
|
+
<Progress.Label>Uploading payouts.csv</Progress.Label>
|
|
1892
|
+
<Progress.Value />
|
|
1893
|
+
<Progress.Track>
|
|
1894
|
+
<Progress.Indicator />
|
|
1895
|
+
</Progress.Track>
|
|
1896
|
+
</Progress.Root>
|
|
1897
|
+
)
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
namespace styles {
|
|
1901
|
+
export const progress = style({ maxWidth: '20rem !custom' })
|
|
1902
|
+
}
|
|
1903
|
+
```
|
|
1904
|
+
|
|
1905
|
+
**Don't:** Show an indeterminate bar for work you can measure.
|
|
1906
|
+
|
|
1907
|
+
```tsx
|
|
1908
|
+
/**
|
|
1909
|
+
* Don't example for "Show Determinate Progress When You Can Measure It" on the Progress page.
|
|
1910
|
+
* Don't show an indeterminate bar for work you can measure.
|
|
1911
|
+
* @module
|
|
1912
|
+
*/
|
|
1913
|
+
import { Progress, style } from '@tempoxyz/ds'
|
|
1914
|
+
|
|
1915
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1916
|
+
export function Demo() {
|
|
1917
|
+
return (
|
|
1918
|
+
<Progress.Root value={null} {...styles.progress()}>
|
|
1919
|
+
<Progress.Label>Uploading payouts.csv</Progress.Label>
|
|
1920
|
+
<Progress.Track>
|
|
1921
|
+
<Progress.Indicator />
|
|
1922
|
+
</Progress.Track>
|
|
1923
|
+
</Progress.Root>
|
|
1924
|
+
)
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
namespace styles {
|
|
1928
|
+
export const progress = style({ maxWidth: '20rem !custom' })
|
|
1929
|
+
}
|
|
1930
|
+
```
|
|
1931
|
+
|
|
1932
|
+
#### Name the Task
|
|
1933
|
+
|
|
1934
|
+
Add `Progress.Value` to print the percentage, or pass it a function child for units, such as 3 of 5 files. Without a visible label, pass `aria-label`.
|
|
1935
|
+
|
|
1936
|
+
**Do:** Put a `Progress.Label` in every bar.
|
|
1937
|
+
|
|
1938
|
+
```tsx
|
|
1939
|
+
/** Do example for "Name the Task" on the Progress page: put a `Progress.Label` in every bar. @module */
|
|
1940
|
+
import { Progress, style } from '@tempoxyz/ds'
|
|
1941
|
+
|
|
1942
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1943
|
+
export function Demo() {
|
|
1944
|
+
return (
|
|
1945
|
+
<Progress.Root value={60} {...styles.progress()}>
|
|
1946
|
+
<Progress.Label>Exporting 1,240 transactions</Progress.Label>
|
|
1947
|
+
<Progress.Value />
|
|
1948
|
+
<Progress.Track>
|
|
1949
|
+
<Progress.Indicator />
|
|
1950
|
+
</Progress.Track>
|
|
1951
|
+
</Progress.Root>
|
|
1952
|
+
)
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
namespace styles {
|
|
1956
|
+
export const progress = style({ maxWidth: '20rem !custom' })
|
|
1957
|
+
}
|
|
1958
|
+
```
|
|
1959
|
+
|
|
1960
|
+
**Don't:** Show a bar without a name for its task.
|
|
1961
|
+
|
|
1962
|
+
```tsx
|
|
1963
|
+
/** Don't example for "Name the Task" on the Progress page. Don't show a bar without a name for its task. @module */
|
|
1964
|
+
import { Progress, style } from '@tempoxyz/ds'
|
|
1965
|
+
|
|
1966
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1967
|
+
export function Demo() {
|
|
1968
|
+
return (
|
|
1969
|
+
<Progress.Root value={60} {...styles.progress()}>
|
|
1970
|
+
<Progress.Value />
|
|
1971
|
+
<Progress.Track>
|
|
1972
|
+
<Progress.Indicator />
|
|
1973
|
+
</Progress.Track>
|
|
1974
|
+
</Progress.Root>
|
|
1975
|
+
)
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
namespace styles {
|
|
1979
|
+
export const progress = style({ maxWidth: '20rem !custom' })
|
|
1980
|
+
}
|
|
1981
|
+
```
|
|
1982
|
+
|
|
1983
|
+
#### Move Forward Only
|
|
1984
|
+
|
|
1985
|
+
Use an indeterminate bar for a phase you cannot measure.
|
|
1986
|
+
|
|
1987
|
+
**Do:** If a task has phases, such as upload then verification, change the label for each.
|
|
1988
|
+
|
|
1989
|
+
```tsx
|
|
1990
|
+
/**
|
|
1991
|
+
* Do example for "Move Forward Only" on the Progress page.
|
|
1992
|
+
* If a task has phases, such as upload then verification, change the label for each.
|
|
1993
|
+
* @module
|
|
1994
|
+
*/
|
|
1995
|
+
import { Progress, style } from '@tempoxyz/ds'
|
|
1996
|
+
|
|
1997
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1998
|
+
export function Demo() {
|
|
1999
|
+
return (
|
|
2000
|
+
<div {...styles.steps()}>
|
|
2001
|
+
<Progress.Root value={90} {...styles.progress()}>
|
|
2002
|
+
<Progress.Label>Uploading payouts.csv</Progress.Label>
|
|
2003
|
+
<Progress.Value />
|
|
2004
|
+
<Progress.Track>
|
|
2005
|
+
<Progress.Indicator />
|
|
2006
|
+
</Progress.Track>
|
|
2007
|
+
</Progress.Root>
|
|
2008
|
+
<div {...styles.step()}>Then</div>
|
|
2009
|
+
<Progress.Root value={10} {...styles.progress()}>
|
|
2010
|
+
<Progress.Label>Verifying payments</Progress.Label>
|
|
2011
|
+
<Progress.Value />
|
|
2012
|
+
<Progress.Track>
|
|
2013
|
+
<Progress.Indicator />
|
|
2014
|
+
</Progress.Track>
|
|
2015
|
+
</Progress.Root>
|
|
2016
|
+
</div>
|
|
2017
|
+
)
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
namespace styles {
|
|
2021
|
+
export const progress = style({ maxWidth: '20rem !custom' })
|
|
2022
|
+
|
|
2023
|
+
export const step = style({ color: 'content.secondary', typography: 'body.b3' })
|
|
2024
|
+
|
|
2025
|
+
export const steps = style({
|
|
2026
|
+
display: 'flex',
|
|
2027
|
+
flexDirection: 'column',
|
|
2028
|
+
gap: '12',
|
|
2029
|
+
width: '100% !custom',
|
|
2030
|
+
})
|
|
2031
|
+
}
|
|
2032
|
+
```
|
|
2033
|
+
|
|
2034
|
+
**Don't:** Let the value decrease or restart at 0 under the same label.
|
|
2035
|
+
|
|
2036
|
+
```tsx
|
|
2037
|
+
/**
|
|
2038
|
+
* Don't example for "Move Forward Only" on the Progress page.
|
|
2039
|
+
* Don't let the value decrease or restart at 0 under the same label.
|
|
2040
|
+
* @module
|
|
2041
|
+
*/
|
|
2042
|
+
import { Progress, style } from '@tempoxyz/ds'
|
|
2043
|
+
|
|
2044
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2045
|
+
export function Demo() {
|
|
2046
|
+
return (
|
|
2047
|
+
<div {...styles.steps()}>
|
|
2048
|
+
<Progress.Root value={90} {...styles.progress()}>
|
|
2049
|
+
<Progress.Label>Uploading payouts.csv</Progress.Label>
|
|
2050
|
+
<Progress.Value />
|
|
2051
|
+
<Progress.Track>
|
|
2052
|
+
<Progress.Indicator />
|
|
2053
|
+
</Progress.Track>
|
|
2054
|
+
</Progress.Root>
|
|
2055
|
+
<div {...styles.step()}>Then</div>
|
|
2056
|
+
<Progress.Root value={10} {...styles.progress()}>
|
|
2057
|
+
<Progress.Label>Uploading payouts.csv</Progress.Label>
|
|
2058
|
+
<Progress.Value />
|
|
2059
|
+
<Progress.Track>
|
|
2060
|
+
<Progress.Indicator />
|
|
2061
|
+
</Progress.Track>
|
|
2062
|
+
</Progress.Root>
|
|
2063
|
+
</div>
|
|
2064
|
+
)
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
namespace styles {
|
|
2068
|
+
export const progress = style({ maxWidth: '20rem !custom' })
|
|
2069
|
+
|
|
2070
|
+
export const step = style({ color: 'content.secondary', typography: 'body.b3' })
|
|
2071
|
+
|
|
2072
|
+
export const steps = style({
|
|
2073
|
+
display: 'flex',
|
|
2074
|
+
flexDirection: 'column',
|
|
2075
|
+
gap: '12',
|
|
2076
|
+
width: '100% !custom',
|
|
2077
|
+
})
|
|
2078
|
+
}
|
|
2079
|
+
```
|
|
2080
|
+
|
|
2081
|
+
#### Report the Outcome
|
|
2082
|
+
|
|
2083
|
+
* **Success (positive):** Set `intent` to `positive` and change the label. Then replace the bar with the result, such as a link to the file.
|
|
2084
|
+
* **Failure (Alert):** Progress has no `negative` intent. Replace the bar with a `negative` [Alert](#alert) that offers Retry.
|
|
2085
|
+
|
|
2086
|
+
### Content
|
|
2087
|
+
|
|
2088
|
+
* **Label:** A verb ending in -ing and its object, such as Uploading payouts.csv.
|
|
2089
|
+
* **Units:** If a percentage hides the size of the job, count files, payments, or blocks.
|
|
2090
|
+
* **Time estimate:** Add one only when it is reliable, and round it, such as About 2 minutes left.
|
|
2091
|
+
|
|
2092
|
+
### Accessibility
|
|
2093
|
+
|
|
2094
|
+
The bar is not a live region. A changed value is read only when the reader returns to it.
|
|
2095
|
+
|
|
2096
|
+
#### Semantics
|
|
2097
|
+
|
|
2098
|
+
* **Progress.Root (progressbar):** Reports its range and value to assistive technology.
|
|
2099
|
+
* **Value Text (aria-valuetext):** Defaults to a locale percentage, such as "60%". `format` and `getAriaValueText` change it.
|
|
2100
|
+
* **Progress.Label (aria-labelledby):** Names the bar.
|
|
2101
|
+
* **Progress.Value (aria-hidden):** Screen readers skip it and read the value text once.
|
|
2102
|
+
* **Indeterminate Bars (value={null}):** Reports no current value. Under reduced motion, the sliding segment becomes a dimmed full bar.
|
|
2103
|
+
|
|
2104
|
+
#### Your Responsibilities
|
|
2105
|
+
|
|
2106
|
+
* **Describe Units (getAriaValueText):** Use it for a value with units, such as "3 of 5 files".
|
|
2107
|
+
* **Announce Completion (SC 4.1.3):** Announce the result, such as "Upload complete", in a status message or toast.
|
|
2108
|
+
* **Keep Label and Value Visible (4px):** The track is thin. The label and value carry the information for anyone who cannot see the fill.
|
|
2109
|
+
|
|
2110
|
+
### Related
|
|
2111
|
+
|
|
2112
|
+
[Gauge](#gauge)
|
|
2113
|
+
|
|
2114
|
+
Use for a measurement within a range.
|
|
2115
|
+
|
|
2116
|
+
[Spinner](#spinner)
|
|
2117
|
+
|
|
2118
|
+
Use for a short wait of unknown length.
|
|
2119
|
+
|
|
2120
|
+
[Skeleton](#skeleton)
|
|
2121
|
+
|
|
2122
|
+
Use for content with a known shape.
|
|
2123
|
+
|
|
2124
|
+
[Loading](../patterns.md#loading)
|
|
2125
|
+
|
|
2126
|
+
Covers choosing a loading indicator.
|
|
2127
|
+
|
|
2128
|
+
### Examples
|
|
2129
|
+
|
|
2130
|
+
#### Basic
|
|
2131
|
+
|
|
2132
|
+
```tsx
|
|
2133
|
+
import { Progress, style } from '@tempoxyz/ds'
|
|
2134
|
+
|
|
2135
|
+
export const fill = true
|
|
2136
|
+
export function Demo() {
|
|
2137
|
+
return (
|
|
2138
|
+
<Progress.Root value={60} {...styles.progress()}>
|
|
2139
|
+
<Progress.Label>Uploading</Progress.Label>
|
|
2140
|
+
<Progress.Value />
|
|
2141
|
+
<Progress.Track>
|
|
2142
|
+
<Progress.Indicator />
|
|
2143
|
+
</Progress.Track>
|
|
2144
|
+
</Progress.Root>
|
|
2145
|
+
)
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
namespace styles {
|
|
2149
|
+
export const progress = style({ maxWidth: '24rem !custom' })
|
|
2150
|
+
}
|
|
2151
|
+
```
|
|
2152
|
+
|
|
2153
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Progress/Basic.tsx)
|
|
2154
|
+
|
|
2155
|
+
#### Intent
|
|
2156
|
+
|
|
2157
|
+
Set `intent` to `neutral` (default) or `positive`.
|
|
2158
|
+
|
|
2159
|
+
```tsx
|
|
2160
|
+
import { Progress, style } from '@tempoxyz/ds'
|
|
2161
|
+
|
|
2162
|
+
export const fill = true
|
|
2163
|
+
export function Demo() {
|
|
2164
|
+
return (
|
|
2165
|
+
<div {...styles.stack()}>
|
|
2166
|
+
{(['neutral', 'positive'] as const).map((intent, index) => (
|
|
2167
|
+
<Progress.Root intent={intent} key={intent} value={20 + index * 20}>
|
|
2168
|
+
<Progress.Label>{intent}</Progress.Label>
|
|
2169
|
+
<Progress.Value />
|
|
2170
|
+
<Progress.Track>
|
|
2171
|
+
<Progress.Indicator />
|
|
2172
|
+
</Progress.Track>
|
|
2173
|
+
</Progress.Root>
|
|
2174
|
+
))}
|
|
2175
|
+
</div>
|
|
2176
|
+
)
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
namespace styles {
|
|
2180
|
+
export const stack = style({
|
|
2181
|
+
display: 'flex',
|
|
2182
|
+
flexDirection: 'column',
|
|
2183
|
+
gap: '16',
|
|
2184
|
+
maxWidth: '24rem !custom',
|
|
2185
|
+
})
|
|
2186
|
+
}
|
|
2187
|
+
```
|
|
2188
|
+
|
|
2189
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Progress/Intent.tsx)
|
|
2190
|
+
|
|
2191
|
+
#### Value
|
|
2192
|
+
|
|
2193
|
+
If the remaining work is unknown, pass `value={null}` for an indeterminate bar.
|
|
2194
|
+
|
|
2195
|
+
```tsx
|
|
2196
|
+
import { Progress, style } from '@tempoxyz/ds'
|
|
2197
|
+
|
|
2198
|
+
export const fill = true
|
|
2199
|
+
export function Demo() {
|
|
2200
|
+
return (
|
|
2201
|
+
<Progress.Root value={null} {...styles.progress()}>
|
|
2202
|
+
<Progress.Label>Indeterminate</Progress.Label>
|
|
2203
|
+
<Progress.Track>
|
|
2204
|
+
<Progress.Indicator />
|
|
2205
|
+
</Progress.Track>
|
|
2206
|
+
</Progress.Root>
|
|
2207
|
+
)
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2210
|
+
namespace styles {
|
|
2211
|
+
export const progress = style({ maxWidth: '24rem !custom' })
|
|
2212
|
+
}
|
|
2213
|
+
```
|
|
2214
|
+
|
|
2215
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Progress/Value.tsx)
|
|
2216
|
+
|
|
2217
|
+
## Skeleton
|
|
2218
|
+
|
|
2219
|
+
Holds the place of content while it loads.
|
|
2220
|
+
|
|
2221
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Skeleton.tsx)
|
|
2222
|
+
|
|
2223
|
+
### Overview
|
|
2224
|
+
|
|
2225
|
+
Skeleton renders a loading placeholder at the size of the content it wraps.
|
|
2226
|
+
|
|
2227
|
+
### Anatomy
|
|
2228
|
+
|
|
2229
|
+
Import the component and assemble its parts.
|
|
2230
|
+
|
|
2231
|
+
```tsx
|
|
2232
|
+
import { Skeleton } from '@tempoxyz/ds'
|
|
2233
|
+
|
|
2234
|
+
<Skeleton />
|
|
2235
|
+
```
|
|
2236
|
+
|
|
2237
|
+
### Guidelines
|
|
2238
|
+
|
|
2239
|
+
#### When to Use
|
|
2240
|
+
|
|
2241
|
+
* Hold the place of content with a known layout, such as balances, activity rows, or metric tiles.
|
|
2242
|
+
* Fill table rows, cards, and lists on first load, with the expected or a typical item count.
|
|
2243
|
+
|
|
2244
|
+
#### When Not to Use
|
|
2245
|
+
|
|
2246
|
+
* Use [Spinner](#spinner) when the shape of the result is unknown, or for a busy control.
|
|
2247
|
+
* Use [Progress](#progress-1) for a long task with measurable work.
|
|
2248
|
+
* Use `loading` on a [Button](actions.md#button) while its action runs.
|
|
2249
|
+
* Use [Empty](#empty) when the request returns no records.
|
|
2250
|
+
|
|
2251
|
+
#### Match the Final Content's Shape
|
|
2252
|
+
|
|
2253
|
+
* **`circle`:** Avatars, identicons, and token icons.
|
|
2254
|
+
* **`pill`:** Pill-shaped controls, such as an extra-small button.
|
|
2255
|
+
* **`default`:** Text, blocks, badges, and buttons.
|
|
2256
|
+
|
|
2257
|
+
For a list, repeat each row's structure instead of one block.
|
|
2258
|
+
|
|
2259
|
+
**Do:** Mirror each row's icon, text lines, and amount.
|
|
2260
|
+
|
|
2261
|
+
```tsx
|
|
2262
|
+
/**
|
|
2263
|
+
* Do example for "Match the Final Content's Shape" on the Skeleton page.
|
|
2264
|
+
* Mirror each row's icon, text lines, and amount.
|
|
2265
|
+
* @module
|
|
2266
|
+
*/
|
|
2267
|
+
import { Skeleton, style } from '@tempoxyz/ds'
|
|
2268
|
+
|
|
2269
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2270
|
+
export function Demo() {
|
|
2271
|
+
return (
|
|
2272
|
+
<div {...styles.list()}>
|
|
2273
|
+
{['0x8f3c…a21b', '0x41d2…9c07', '0xb7e0…3f5a'].map((address) => (
|
|
2274
|
+
<div {...styles.row()} key={address}>
|
|
2275
|
+
<Skeleton shape="circle" style={{ height: 32, width: 32 }} />
|
|
2276
|
+
<div {...styles.text()}>
|
|
2277
|
+
<Skeleton>
|
|
2278
|
+
<div {...styles.title()}>{address}</div>
|
|
2279
|
+
</Skeleton>
|
|
2280
|
+
<Skeleton>
|
|
2281
|
+
<div {...styles.meta()}>Oct 18, 14:02</div>
|
|
2282
|
+
</Skeleton>
|
|
2283
|
+
</div>
|
|
2284
|
+
<Skeleton>
|
|
2285
|
+
<div {...styles.title()}>+50.00 USDC</div>
|
|
2286
|
+
</Skeleton>
|
|
2287
|
+
</div>
|
|
2288
|
+
))}
|
|
2289
|
+
</div>
|
|
2290
|
+
)
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
namespace styles {
|
|
2294
|
+
export const list = style({ display: 'flex', flexDirection: 'column', gap: '16' })
|
|
2295
|
+
|
|
2296
|
+
export const meta = style({ typography: 'body.b3' })
|
|
2297
|
+
|
|
2298
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
2299
|
+
|
|
2300
|
+
export const text = style({
|
|
2301
|
+
alignItems: 'flex-start',
|
|
2302
|
+
display: 'flex',
|
|
2303
|
+
flex: '1 !custom',
|
|
2304
|
+
flexDirection: 'column',
|
|
2305
|
+
gap: '4',
|
|
2306
|
+
})
|
|
2307
|
+
|
|
2308
|
+
export const title = style({ typography: 'body.b2' })
|
|
2309
|
+
}
|
|
2310
|
+
```
|
|
2311
|
+
|
|
2312
|
+
**Don't:** Cover a list with one block that hides its structure.
|
|
2313
|
+
|
|
2314
|
+
```tsx
|
|
2315
|
+
/**
|
|
2316
|
+
* Don't example for "Match the Final Content's Shape" on the Skeleton page.
|
|
2317
|
+
* Don't cover a list with one block that hides its structure.
|
|
2318
|
+
* @module
|
|
2319
|
+
*/
|
|
2320
|
+
import { Skeleton } from '@tempoxyz/ds'
|
|
2321
|
+
|
|
2322
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2323
|
+
export function Demo() {
|
|
2324
|
+
return <Skeleton style={{ height: 144, width: 256 }} />
|
|
2325
|
+
}
|
|
2326
|
+
```
|
|
2327
|
+
|
|
2328
|
+
#### Wrap the Real Content
|
|
2329
|
+
|
|
2330
|
+
Skeleton takes the size of its children and hides them with `visibility: hidden`. Set `show={false}` when the data arrives, so the content keeps its place in reading order.
|
|
2331
|
+
|
|
2332
|
+
```tsx
|
|
2333
|
+
<Skeleton show={loading}>
|
|
2334
|
+
<Amount currency="USD" value={balance} />
|
|
2335
|
+
</Skeleton>
|
|
2336
|
+
```
|
|
2337
|
+
|
|
2338
|
+
Size an empty skeleton with `style` only when there is nothing to wrap.
|
|
2339
|
+
|
|
2340
|
+
**Do:** Wrap the element that holds the data, with a placeholder of typical length.
|
|
2341
|
+
|
|
2342
|
+
```tsx
|
|
2343
|
+
/**
|
|
2344
|
+
* Do example for "Wrap the Real Content" on the Skeleton page.
|
|
2345
|
+
* Wrap the element that holds the data, with a placeholder of typical length.
|
|
2346
|
+
* @module
|
|
2347
|
+
*/
|
|
2348
|
+
import { Skeleton, style } from '@tempoxyz/ds'
|
|
2349
|
+
|
|
2350
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2351
|
+
export function Demo() {
|
|
2352
|
+
return (
|
|
2353
|
+
<div {...styles.card()}>
|
|
2354
|
+
<div {...styles.label()}>Balance</div>
|
|
2355
|
+
<Skeleton>
|
|
2356
|
+
<div {...styles.value()}>1,250.00 USDC</div>
|
|
2357
|
+
</Skeleton>
|
|
2358
|
+
</div>
|
|
2359
|
+
)
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
namespace styles {
|
|
2363
|
+
export const card = style({
|
|
2364
|
+
alignItems: 'flex-start',
|
|
2365
|
+
display: 'flex',
|
|
2366
|
+
flexDirection: 'column',
|
|
2367
|
+
gap: '4',
|
|
2368
|
+
})
|
|
2369
|
+
|
|
2370
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b3' })
|
|
2371
|
+
|
|
2372
|
+
export const value = style({ color: 'content.primary', typography: 'heading.h1' })
|
|
2373
|
+
}
|
|
2374
|
+
```
|
|
2375
|
+
|
|
2376
|
+
**Don't:** Swap in a separately sized block that doesn't match the content.
|
|
2377
|
+
|
|
2378
|
+
```tsx
|
|
2379
|
+
/**
|
|
2380
|
+
* Don't example for "Wrap the Real Content" on the Skeleton page.
|
|
2381
|
+
* Don't swap in a separately sized block that doesn't match the content.
|
|
2382
|
+
* @module
|
|
2383
|
+
*/
|
|
2384
|
+
import { Skeleton, style } from '@tempoxyz/ds'
|
|
2385
|
+
|
|
2386
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2387
|
+
export function Demo() {
|
|
2388
|
+
return (
|
|
2389
|
+
<div {...styles.card()}>
|
|
2390
|
+
<div {...styles.label()}>Balance</div>
|
|
2391
|
+
<Skeleton style={{ height: 12, width: 80 }} />
|
|
2392
|
+
</div>
|
|
2393
|
+
)
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
namespace styles {
|
|
2397
|
+
export const card = style({
|
|
2398
|
+
alignItems: 'flex-start',
|
|
2399
|
+
display: 'flex',
|
|
2400
|
+
flexDirection: 'column',
|
|
2401
|
+
gap: '4',
|
|
2402
|
+
})
|
|
2403
|
+
|
|
2404
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b3' })
|
|
2405
|
+
}
|
|
2406
|
+
```
|
|
2407
|
+
|
|
2408
|
+
#### Keep Labels and Controls Visible
|
|
2409
|
+
|
|
2410
|
+
Keep headings, labels, tabs, filters, and buttons that do not depend on the data on screen.
|
|
2411
|
+
|
|
2412
|
+
**Do:** Keep the label and actions, and hold the place of the amount.
|
|
2413
|
+
|
|
2414
|
+
```tsx
|
|
2415
|
+
/**
|
|
2416
|
+
* Do example for "Keep Labels and Controls Visible" on the Skeleton page.
|
|
2417
|
+
* Keep the label and actions, and hold the place of the amount.
|
|
2418
|
+
* @module
|
|
2419
|
+
*/
|
|
2420
|
+
import { Button, Skeleton, style } from '@tempoxyz/ds'
|
|
2421
|
+
|
|
2422
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2423
|
+
export function Demo() {
|
|
2424
|
+
return (
|
|
2425
|
+
<div {...styles.card()}>
|
|
2426
|
+
<div {...styles.label()}>Balance</div>
|
|
2427
|
+
<Skeleton>
|
|
2428
|
+
<div {...styles.value()}>$1,250.00</div>
|
|
2429
|
+
</Skeleton>
|
|
2430
|
+
<div {...styles.actions()}>
|
|
2431
|
+
<Button size="small">Send</Button>
|
|
2432
|
+
<Button size="small" variant="secondary">
|
|
2433
|
+
Receive
|
|
2434
|
+
</Button>
|
|
2435
|
+
</div>
|
|
2436
|
+
</div>
|
|
2437
|
+
)
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
namespace styles {
|
|
2441
|
+
export const actions = style({ display: 'flex', gap: '8', marginBlockStart: '12' })
|
|
2442
|
+
|
|
2443
|
+
export const card = style({
|
|
2444
|
+
alignItems: 'flex-start',
|
|
2445
|
+
display: 'flex',
|
|
2446
|
+
flexDirection: 'column',
|
|
2447
|
+
gap: '4',
|
|
2448
|
+
})
|
|
2449
|
+
|
|
2450
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b3' })
|
|
2451
|
+
|
|
2452
|
+
export const value = style({ color: 'content.primary', typography: 'heading.h1' })
|
|
2453
|
+
}
|
|
2454
|
+
```
|
|
2455
|
+
|
|
2456
|
+
**Don't:** Turn static labels and buttons into skeletons.
|
|
2457
|
+
|
|
2458
|
+
```tsx
|
|
2459
|
+
/**
|
|
2460
|
+
* Don't example for "Keep Labels and Controls Visible" on the Skeleton page.
|
|
2461
|
+
* Don't turn static labels and buttons into skeletons.
|
|
2462
|
+
* @module
|
|
2463
|
+
*/
|
|
2464
|
+
import { Button, Skeleton, style } from '@tempoxyz/ds'
|
|
2465
|
+
|
|
2466
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2467
|
+
export function Demo() {
|
|
2468
|
+
return (
|
|
2469
|
+
<div {...styles.card()}>
|
|
2470
|
+
<Skeleton>
|
|
2471
|
+
<div {...styles.label()}>Balance</div>
|
|
2472
|
+
</Skeleton>
|
|
2473
|
+
<Skeleton>
|
|
2474
|
+
<div {...styles.value()}>$1,250.00</div>
|
|
2475
|
+
</Skeleton>
|
|
2476
|
+
<div {...styles.actions()}>
|
|
2477
|
+
<Skeleton shape="pill">
|
|
2478
|
+
<Button size="small">Send</Button>
|
|
2479
|
+
</Skeleton>
|
|
2480
|
+
<Skeleton shape="pill">
|
|
2481
|
+
<Button size="small" variant="secondary">
|
|
2482
|
+
Receive
|
|
2483
|
+
</Button>
|
|
2484
|
+
</Skeleton>
|
|
2485
|
+
</div>
|
|
2486
|
+
</div>
|
|
2487
|
+
)
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
namespace styles {
|
|
2491
|
+
export const actions = style({ display: 'flex', gap: '8', marginBlockStart: '12' })
|
|
2492
|
+
|
|
2493
|
+
export const card = style({
|
|
2494
|
+
alignItems: 'flex-start',
|
|
2495
|
+
display: 'flex',
|
|
2496
|
+
flexDirection: 'column',
|
|
2497
|
+
gap: '4',
|
|
2498
|
+
})
|
|
2499
|
+
|
|
2500
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b3' })
|
|
2501
|
+
|
|
2502
|
+
export const value = style({ color: 'content.primary', typography: 'heading.h1' })
|
|
2503
|
+
}
|
|
2504
|
+
```
|
|
2505
|
+
|
|
2506
|
+
#### Keep Current Data During a Refresh
|
|
2507
|
+
|
|
2508
|
+
**Do:** Keep values on screen, such as a polled balance, until the new ones arrive.
|
|
2509
|
+
|
|
2510
|
+
```tsx
|
|
2511
|
+
/**
|
|
2512
|
+
* Do example for "Keep Current Data During a Refresh" on the Skeleton page.
|
|
2513
|
+
* Keep values on screen, such as a polled balance, until the new ones arrive.
|
|
2514
|
+
* @module
|
|
2515
|
+
*/
|
|
2516
|
+
import { style } from '@tempoxyz/ds'
|
|
2517
|
+
|
|
2518
|
+
const payments = [
|
|
2519
|
+
{ address: '0x8f3c…a21b', amount: '+50.00 USDC' },
|
|
2520
|
+
{ address: '0x41d2…9c07', amount: '-25.00 USDC' },
|
|
2521
|
+
]
|
|
2522
|
+
|
|
2523
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2524
|
+
export function Demo() {
|
|
2525
|
+
return (
|
|
2526
|
+
<div {...styles.list()}>
|
|
2527
|
+
<div {...styles.heading()}>Activity</div>
|
|
2528
|
+
{payments.map((payment) => (
|
|
2529
|
+
<div {...styles.row()} key={payment.address}>
|
|
2530
|
+
<div>{payment.address}</div>
|
|
2531
|
+
<div>{payment.amount}</div>
|
|
2532
|
+
</div>
|
|
2533
|
+
))}
|
|
2534
|
+
</div>
|
|
2535
|
+
)
|
|
2536
|
+
}
|
|
2537
|
+
|
|
2538
|
+
namespace styles {
|
|
2539
|
+
export const heading = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
2540
|
+
|
|
2541
|
+
export const list = style({
|
|
2542
|
+
display: 'flex',
|
|
2543
|
+
flexDirection: 'column',
|
|
2544
|
+
gap: '12',
|
|
2545
|
+
width: '100% !custom',
|
|
2546
|
+
})
|
|
2547
|
+
|
|
2548
|
+
export const row = style({
|
|
2549
|
+
alignItems: 'center',
|
|
2550
|
+
display: 'flex',
|
|
2551
|
+
justifyContent: 'space-between',
|
|
2552
|
+
typography: 'body.b2',
|
|
2553
|
+
})
|
|
2554
|
+
}
|
|
2555
|
+
```
|
|
2556
|
+
|
|
2557
|
+
**Don't:** Return to skeletons on every refresh.
|
|
2558
|
+
|
|
2559
|
+
```tsx
|
|
2560
|
+
/**
|
|
2561
|
+
* Don't example for "Keep Current Data During a Refresh" on the Skeleton page.
|
|
2562
|
+
* Don't return to skeletons on every refresh.
|
|
2563
|
+
* @module
|
|
2564
|
+
*/
|
|
2565
|
+
import { Skeleton, style } from '@tempoxyz/ds'
|
|
2566
|
+
|
|
2567
|
+
const payments = [
|
|
2568
|
+
{ address: '0x8f3c…a21b', amount: '+50.00 USDC' },
|
|
2569
|
+
{ address: '0x41d2…9c07', amount: '-25.00 USDC' },
|
|
2570
|
+
]
|
|
2571
|
+
|
|
2572
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2573
|
+
export function Demo() {
|
|
2574
|
+
return (
|
|
2575
|
+
<div {...styles.list()}>
|
|
2576
|
+
<div {...styles.heading()}>Activity</div>
|
|
2577
|
+
{payments.map((payment) => (
|
|
2578
|
+
<div {...styles.row()} key={payment.address}>
|
|
2579
|
+
<Skeleton>
|
|
2580
|
+
<div>{payment.address}</div>
|
|
2581
|
+
</Skeleton>
|
|
2582
|
+
<Skeleton>
|
|
2583
|
+
<div>{payment.amount}</div>
|
|
2584
|
+
</Skeleton>
|
|
2585
|
+
</div>
|
|
2586
|
+
))}
|
|
2587
|
+
</div>
|
|
2588
|
+
)
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
namespace styles {
|
|
2592
|
+
export const heading = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
2593
|
+
|
|
2594
|
+
export const list = style({
|
|
2595
|
+
display: 'flex',
|
|
2596
|
+
flexDirection: 'column',
|
|
2597
|
+
gap: '12',
|
|
2598
|
+
width: '100% !custom',
|
|
2599
|
+
})
|
|
2600
|
+
|
|
2601
|
+
export const row = style({
|
|
2602
|
+
alignItems: 'center',
|
|
2603
|
+
display: 'flex',
|
|
2604
|
+
justifyContent: 'space-between',
|
|
2605
|
+
typography: 'body.b2',
|
|
2606
|
+
})
|
|
2607
|
+
}
|
|
2608
|
+
```
|
|
2609
|
+
|
|
2610
|
+
#### Skip It for Fast Responses
|
|
2611
|
+
|
|
2612
|
+
* **Fast Responses (Under 300 ms):** Delay the skeleton, so the content renders without a flash.
|
|
2613
|
+
* **Typical Waits (300 ms to 10 s):** Show the skeleton.
|
|
2614
|
+
* **Long Waits (Over 10 s):** Show [Progress](#progress-1). See [Loading](../patterns.md#loading).
|
|
2615
|
+
|
|
2616
|
+
### Accessibility
|
|
2617
|
+
|
|
2618
|
+
Skeleton renders a `div` that marks its content busy and hides it until `show={false}`. It has no live region, and most screen readers ignore `aria-busy` on a plain `div`.
|
|
2619
|
+
|
|
2620
|
+
#### Semantics
|
|
2621
|
+
|
|
2622
|
+
* **Busy State (aria-busy):** Marks the region busy while `show` is true.
|
|
2623
|
+
* **Hidden Content (visibility: hidden):** Screen readers skip the placeholder text, and focus cannot reach hidden controls.
|
|
2624
|
+
* **Pointer Events:** The root blocks pointer events while it shows, so placeholder buttons are inert.
|
|
2625
|
+
* **Reduced Motion (prefers-reduced-motion):** The sweep stops, and the placeholder stays a static tint.
|
|
2626
|
+
|
|
2627
|
+
#### Your Responsibilities
|
|
2628
|
+
|
|
2629
|
+
* **Announce Long Loads (status):** For main content, state what loads in a status message, such as "Loading activity".
|
|
2630
|
+
* **Handle Failures:** If loading fails, show an error message. Never leave a skeleton that does not resolve.
|
|
2631
|
+
|
|
2632
|
+
### Related
|
|
2633
|
+
|
|
2634
|
+
[Spinner](#spinner)
|
|
2635
|
+
|
|
2636
|
+
Use for loading with an unknown shape.
|
|
2637
|
+
|
|
2638
|
+
[Progress](#progress-1)
|
|
2639
|
+
|
|
2640
|
+
Use for measurable work.
|
|
2641
|
+
|
|
2642
|
+
[Empty](#empty)
|
|
2643
|
+
|
|
2644
|
+
Use for a region with nothing to show.
|
|
2645
|
+
|
|
2646
|
+
[Loading](../patterns.md#loading)
|
|
2647
|
+
|
|
2648
|
+
Covers choosing a loading indicator.
|
|
2649
|
+
|
|
2650
|
+
### Examples
|
|
2651
|
+
|
|
2652
|
+
#### Basic
|
|
2653
|
+
|
|
2654
|
+
```tsx
|
|
2655
|
+
import { Skeleton, style } from '@tempoxyz/ds'
|
|
2656
|
+
|
|
2657
|
+
export function Demo() {
|
|
2658
|
+
return (
|
|
2659
|
+
<div {...styles.row()}>
|
|
2660
|
+
<div {...styles.column()}>
|
|
2661
|
+
<Skeleton style={{ height: 14, width: 160 }} />
|
|
2662
|
+
<Skeleton style={{ height: 14, width: 96 }} />
|
|
2663
|
+
</div>
|
|
2664
|
+
<Skeleton>
|
|
2665
|
+
<p {...styles.text()}>Keeps the size of its content</p>
|
|
2666
|
+
</Skeleton>
|
|
2667
|
+
</div>
|
|
2668
|
+
)
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
namespace styles {
|
|
2672
|
+
export const column = style({ display: 'flex', flexDirection: 'column', gap: '8' })
|
|
2673
|
+
|
|
2674
|
+
export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '16' })
|
|
2675
|
+
|
|
2676
|
+
export const text = style({ margin: '0', typography: 'body.b2' })
|
|
2677
|
+
}
|
|
2678
|
+
```
|
|
2679
|
+
|
|
2680
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Skeleton/Basic.tsx)
|
|
2681
|
+
|
|
2682
|
+
#### Shape
|
|
2683
|
+
|
|
2684
|
+
Set `shape` to `default` (default), `pill`, or `circle`.
|
|
2685
|
+
|
|
2686
|
+
```tsx
|
|
2687
|
+
import { Skeleton, style } from '@tempoxyz/ds'
|
|
2688
|
+
|
|
2689
|
+
export function Demo() {
|
|
2690
|
+
return (
|
|
2691
|
+
<div {...styles.row()}>
|
|
2692
|
+
<Skeleton shape="circle" style={{ height: 40, width: 40 }} />
|
|
2693
|
+
<Skeleton shape="default" style={{ height: 14, width: 160 }} />
|
|
2694
|
+
<Skeleton shape="pill" style={{ height: 32, width: 96 }} />
|
|
2695
|
+
</div>
|
|
2696
|
+
)
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
namespace styles {
|
|
2700
|
+
export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '16' })
|
|
2701
|
+
}
|
|
2702
|
+
```
|
|
2703
|
+
|
|
2704
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Skeleton/Shape.tsx)
|
|
2705
|
+
|
|
2706
|
+
#### Show
|
|
2707
|
+
|
|
2708
|
+
Set `show={false}` when data arrives to reveal the content. `show` defaults to `true`.
|
|
2709
|
+
|
|
2710
|
+
```tsx
|
|
2711
|
+
import { Skeleton, style } from '@tempoxyz/ds'
|
|
2712
|
+
|
|
2713
|
+
export function Demo() {
|
|
2714
|
+
return (
|
|
2715
|
+
<div {...styles.row()}>
|
|
2716
|
+
<Skeleton>
|
|
2717
|
+
<p {...styles.text()}>Loading content</p>
|
|
2718
|
+
</Skeleton>
|
|
2719
|
+
<Skeleton show={false}>
|
|
2720
|
+
<p {...styles.text()}>Loaded content</p>
|
|
2721
|
+
</Skeleton>
|
|
2722
|
+
</div>
|
|
2723
|
+
)
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2726
|
+
namespace styles {
|
|
2727
|
+
export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '16' })
|
|
2728
|
+
|
|
2729
|
+
export const text = style({ margin: '0', typography: 'body.b2' })
|
|
2730
|
+
}
|
|
2731
|
+
```
|
|
2732
|
+
|
|
2733
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Skeleton/Show.tsx)
|
|
2734
|
+
|
|
2735
|
+
## Spinner
|
|
2736
|
+
|
|
2737
|
+
Shows that something is loading.
|
|
2738
|
+
|
|
2739
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Spinner.tsx)
|
|
2740
|
+
|
|
2741
|
+
Figma: [Spinner](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=1186-3872)
|
|
2742
|
+
|
|
2743
|
+
### Overview
|
|
2744
|
+
|
|
2745
|
+
An indeterminate loading indicator whose arc draws in the current text color, optionally on an elevated tile. Pass `aria-label` to name what loads.
|
|
2746
|
+
|
|
2747
|
+
### Anatomy
|
|
2748
|
+
|
|
2749
|
+
Import the component and assemble its parts.
|
|
2750
|
+
|
|
2751
|
+
```tsx
|
|
2752
|
+
import { Spinner } from '@tempoxyz/ds'
|
|
2753
|
+
|
|
2754
|
+
<Spinner />
|
|
2755
|
+
```
|
|
2756
|
+
|
|
2757
|
+
### Guidelines
|
|
2758
|
+
|
|
2759
|
+
#### When to Use
|
|
2760
|
+
|
|
2761
|
+
* Mark a region busy for a short, unknown time, such as a table that refreshes after a filter change.
|
|
2762
|
+
* Mark a small area that fetches data, such as a quote card or an address lookup.
|
|
2763
|
+
* Hold the place of a result with no predictable shape, such as a quote that returns a price or an error.
|
|
2764
|
+
|
|
2765
|
+
#### When Not to Use
|
|
2766
|
+
|
|
2767
|
+
* Use `loading` on a [Button](actions.md#button) while its action runs, not a spinner beside it.
|
|
2768
|
+
* Use [Skeleton](#skeleton) for content with a known shape, such as activity rows or metric tiles.
|
|
2769
|
+
* Use [Progress](#progress-1) for measurable work, or any wait over about 10 seconds.
|
|
2770
|
+
* Use [LoadingDots](#loadingdots) for a short wait inside a line of text.
|
|
2771
|
+
|
|
2772
|
+
#### Match the Indicator to the Wait
|
|
2773
|
+
|
|
2774
|
+
* **Under About 300 ms (nothing):** Show nothing. Render the result when it arrives.
|
|
2775
|
+
* **About 300 ms to 10 Seconds (Spinner):** Mark the busy region or control.
|
|
2776
|
+
* **Over About 10 Seconds (Progress):** Show a value for measurable work.
|
|
2777
|
+
|
|
2778
|
+
Once a spinner appears, keep it for at least about 500 ms so it doesn't flash. For whole pages, see [Loading](../patterns.md#loading).
|
|
2779
|
+
|
|
2780
|
+
#### Use One Spinner per Region
|
|
2781
|
+
|
|
2782
|
+
**Do:** Center one spinner where the content will appear, and keep loaded content visible.
|
|
2783
|
+
|
|
2784
|
+
```tsx
|
|
2785
|
+
/**
|
|
2786
|
+
* Do example for "Use One Spinner per Region" on the Spinner page.
|
|
2787
|
+
* Center one spinner where the content will appear, and keep loaded content visible.
|
|
2788
|
+
* @module
|
|
2789
|
+
*/
|
|
2790
|
+
import { Spinner, style, Surface } from '@tempoxyz/ds'
|
|
2791
|
+
|
|
2792
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2793
|
+
export function Demo() {
|
|
2794
|
+
return (
|
|
2795
|
+
<div {...styles.page()}>
|
|
2796
|
+
<Surface size="small" {...styles.card()}>
|
|
2797
|
+
<div {...styles.label()}>Balance</div>
|
|
2798
|
+
<div {...styles.value()}>1,250.00 USDC</div>
|
|
2799
|
+
</Surface>
|
|
2800
|
+
<Surface size="small" {...styles.region()}>
|
|
2801
|
+
<Spinner aria-label="Loading activity" />
|
|
2802
|
+
</Surface>
|
|
2803
|
+
</div>
|
|
2804
|
+
)
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
namespace styles {
|
|
2808
|
+
export const card = style({ display: 'flex', flexDirection: 'column', gap: '4' })
|
|
2809
|
+
|
|
2810
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b3' })
|
|
2811
|
+
|
|
2812
|
+
export const page = style({
|
|
2813
|
+
display: 'flex',
|
|
2814
|
+
flexDirection: 'column',
|
|
2815
|
+
gap: '12',
|
|
2816
|
+
width: '100% !custom',
|
|
2817
|
+
})
|
|
2818
|
+
|
|
2819
|
+
export const region = style({
|
|
2820
|
+
alignItems: 'center',
|
|
2821
|
+
display: 'flex',
|
|
2822
|
+
height: '6rem !custom',
|
|
2823
|
+
justifyContent: 'center',
|
|
2824
|
+
})
|
|
2825
|
+
|
|
2826
|
+
export const value = style({ color: 'content.primary', typography: 'heading.h2' })
|
|
2827
|
+
}
|
|
2828
|
+
```
|
|
2829
|
+
|
|
2830
|
+
**Don't:** Cover the whole page, which blocks content that already loaded.
|
|
2831
|
+
|
|
2832
|
+
```tsx
|
|
2833
|
+
/**
|
|
2834
|
+
* Don't example for "Use One Spinner per Region" on the Spinner page.
|
|
2835
|
+
* Don't cover the whole page, which blocks content that already loaded.
|
|
2836
|
+
* @module
|
|
2837
|
+
*/
|
|
2838
|
+
import { Spinner, style, Surface } from '@tempoxyz/ds'
|
|
2839
|
+
|
|
2840
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2841
|
+
export function Demo() {
|
|
2842
|
+
return (
|
|
2843
|
+
<Surface size="small" {...styles.page()}>
|
|
2844
|
+
<Spinner aria-label="Loading" />
|
|
2845
|
+
</Surface>
|
|
2846
|
+
)
|
|
2847
|
+
}
|
|
2848
|
+
|
|
2849
|
+
namespace styles {
|
|
2850
|
+
export const page = style({
|
|
2851
|
+
alignItems: 'center',
|
|
2852
|
+
boxSizing: 'border-box',
|
|
2853
|
+
display: 'flex',
|
|
2854
|
+
height: '10rem !custom',
|
|
2855
|
+
justifyContent: 'center',
|
|
2856
|
+
width: '100% !custom',
|
|
2857
|
+
})
|
|
2858
|
+
}
|
|
2859
|
+
```
|
|
2860
|
+
|
|
2861
|
+
#### Place It Beside a Status Line
|
|
2862
|
+
|
|
2863
|
+
Show the spinner inline beside a short status line, such as Approving. For a pending action, use `loading` on a [Button](actions.md#button).
|
|
2864
|
+
|
|
2865
|
+
### Accessibility
|
|
2866
|
+
|
|
2867
|
+
A spinner renders an indeterminate `progressbar` named "Loading". It is not a live region, so it is read only when the reader reaches it.
|
|
2868
|
+
|
|
2869
|
+
#### Semantics
|
|
2870
|
+
|
|
2871
|
+
* **Root (progressbar):** Named "Loading", with no value, so it reads as indeterminate.
|
|
2872
|
+
* **Custom Name (aria-label):** Replaces the default name.
|
|
2873
|
+
* **Ring (aria-hidden):** A hidden SVG that stops rotating under reduced motion.
|
|
2874
|
+
* **Color (3:1):** Uses the text color. Keep 3:1 contrast against the background.
|
|
2875
|
+
|
|
2876
|
+
#### Your Responsibilities
|
|
2877
|
+
|
|
2878
|
+
* **Say What Is Loading (aria-label):** Name what loads, such as "Loading transactions". Several spinners named "Loading" are indistinguishable.
|
|
2879
|
+
* **Announce the Result (SC 4.1.3):** A spinner isn't announced. Announce the result or an error in a status message or a [Toast](#toast).
|
|
2880
|
+
* **Mark the Region Busy (aria-busy):** Set `aria-busy` on the loading region, so assistive technology waits for its content.
|
|
2881
|
+
|
|
2882
|
+
### Related
|
|
2883
|
+
|
|
2884
|
+
[Skeleton](#skeleton)
|
|
2885
|
+
|
|
2886
|
+
Use for content with a known shape.
|
|
2887
|
+
|
|
2888
|
+
[Progress](#progress-1)
|
|
2889
|
+
|
|
2890
|
+
Use for measurable work.
|
|
2891
|
+
|
|
2892
|
+
[LoadingDots](#loadingdots)
|
|
2893
|
+
|
|
2894
|
+
Use for a wait inside a line of text.
|
|
2895
|
+
|
|
2896
|
+
[Button](actions.md#button)
|
|
2897
|
+
|
|
2898
|
+
Use for an action's loading state.
|
|
2899
|
+
|
|
2900
|
+
[Loading](../patterns.md#loading)
|
|
2901
|
+
|
|
2902
|
+
Covers choosing a loading indicator.
|
|
2903
|
+
|
|
2904
|
+
### Examples
|
|
2905
|
+
|
|
2906
|
+
#### Basic
|
|
2907
|
+
|
|
2908
|
+
```tsx
|
|
2909
|
+
import { Spinner } from '@tempoxyz/ds'
|
|
2910
|
+
|
|
2911
|
+
export function Demo() {
|
|
2912
|
+
return <Spinner aria-label="Loading transactions" />
|
|
2913
|
+
}
|
|
2914
|
+
```
|
|
2915
|
+
|
|
2916
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Spinner/Basic.tsx)
|
|
2917
|
+
|
|
2918
|
+
#### Elevated
|
|
2919
|
+
|
|
2920
|
+
Set `elevated` to place the spinner on a 44px raised tile with a shadow.
|
|
2921
|
+
|
|
2922
|
+
```tsx
|
|
2923
|
+
import { Spinner } from '@tempoxyz/ds'
|
|
2924
|
+
|
|
2925
|
+
export function Demo() {
|
|
2926
|
+
return <Spinner aria-label="Loading quote" elevated />
|
|
2927
|
+
}
|
|
2928
|
+
```
|
|
2929
|
+
|
|
2930
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Spinner/Elevated.tsx)
|
|
2931
|
+
|
|
2932
|
+
#### Size
|
|
2933
|
+
|
|
2934
|
+
Set `size="40"` for a 40px ring with a thicker stroke, such as a spinner that fills an empty panel.
|
|
2935
|
+
|
|
2936
|
+
```tsx
|
|
2937
|
+
/** Renders the 16px and 40px spinner rings side by side. @module */
|
|
2938
|
+
import { Spinner } from '@tempoxyz/ds'
|
|
2939
|
+
|
|
2940
|
+
export function Demo() {
|
|
2941
|
+
return (
|
|
2942
|
+
<div style={{ alignItems: 'center', display: 'flex', gap: 24 }}>
|
|
2943
|
+
<Spinner aria-label="Loading balance" />
|
|
2944
|
+
<Spinner aria-label="Loading activity" size="40" />
|
|
2945
|
+
</div>
|
|
2946
|
+
)
|
|
2947
|
+
}
|
|
2948
|
+
```
|
|
2949
|
+
|
|
2950
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Spinner/Size.tsx)
|
|
2951
|
+
|
|
2952
|
+
## StatusChip
|
|
2953
|
+
|
|
2954
|
+
Names the status of a payment, an authorization, or a network.
|
|
2955
|
+
|
|
2956
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/StatusChip.tsx)
|
|
2957
|
+
|
|
2958
|
+
Figma: [Elements/Network Chip](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-3090), [Messaging/Status Chip](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-3776)
|
|
2959
|
+
|
|
2960
|
+
### Overview
|
|
2961
|
+
|
|
2962
|
+
A status chip renders a short label in a tinted pill, led by a dot in the color of its `intent`. A loading chip replaces the dot with a spinner, for a status that is still in progress. A network chip names a network at a fixed minimum width.
|
|
2963
|
+
|
|
2964
|
+
### Anatomy
|
|
2965
|
+
|
|
2966
|
+
Import the component and assemble its parts.
|
|
2967
|
+
|
|
2968
|
+
```tsx
|
|
2969
|
+
import { StatusChip } from '@tempoxyz/ds'
|
|
2970
|
+
|
|
2971
|
+
<StatusChip />
|
|
2972
|
+
```
|
|
2973
|
+
|
|
2974
|
+
### Guidelines
|
|
2975
|
+
|
|
2976
|
+
#### When to Use
|
|
2977
|
+
|
|
2978
|
+
* Show where a payment, a deposit, or an authorization stands, such as Pending or Authorized.
|
|
2979
|
+
* Show whether a network is live or a testnet, with `network`.
|
|
2980
|
+
|
|
2981
|
+
#### When Not to Use
|
|
2982
|
+
|
|
2983
|
+
* Use [Badge](data-display.md#badge) for a category or an attribute that is not a status.
|
|
2984
|
+
* Use [Alert](#alert) to explain a status and what to do next.
|
|
2985
|
+
* Use [AssetChip](blockchain.md#assetchip) for the assets a row supports.
|
|
2986
|
+
|
|
2987
|
+
#### Pick the Intent From the Outcome
|
|
2988
|
+
|
|
2989
|
+
* **Positive:** The action is done, or the item is live.
|
|
2990
|
+
* **Warning:** The item waits on a person or a later step.
|
|
2991
|
+
* **Negative:** The action failed and needs attention.
|
|
2992
|
+
* **Neutral:** The item ended without an outcome.
|
|
2993
|
+
|
|
2994
|
+
#### Name Only Statuses
|
|
2995
|
+
|
|
2996
|
+
**Do:** Place the chip at the end of the row whose status it names.
|
|
2997
|
+
|
|
2998
|
+
```tsx
|
|
2999
|
+
import { ListGroup, StatusChip } from '@tempoxyz/ds'
|
|
3000
|
+
|
|
3001
|
+
export function Demo() {
|
|
3002
|
+
return (
|
|
3003
|
+
<ListGroup variant="boxed">
|
|
3004
|
+
<ListGroup.Row>
|
|
3005
|
+
<ListGroup.Info>
|
|
3006
|
+
<ListGroup.Title>Claude</ListGroup.Title>
|
|
3007
|
+
<ListGroup.Description>$10.00 a month</ListGroup.Description>
|
|
3008
|
+
</ListGroup.Info>
|
|
3009
|
+
<StatusChip intent="positive" size="small">
|
|
3010
|
+
Authorized
|
|
3011
|
+
</StatusChip>
|
|
3012
|
+
</ListGroup.Row>
|
|
3013
|
+
</ListGroup>
|
|
3014
|
+
)
|
|
3015
|
+
}
|
|
3016
|
+
```
|
|
3017
|
+
|
|
3018
|
+
**Don't:** Use a status chip for a category. Use a [Badge](data-display.md#badge).
|
|
3019
|
+
|
|
3020
|
+
```tsx
|
|
3021
|
+
import { ListGroup, StatusChip } from '@tempoxyz/ds'
|
|
3022
|
+
|
|
3023
|
+
export function Demo() {
|
|
3024
|
+
return (
|
|
3025
|
+
<ListGroup variant="boxed">
|
|
3026
|
+
<ListGroup.Row>
|
|
3027
|
+
<ListGroup.Info>
|
|
3028
|
+
<ListGroup.Title>Claude</ListGroup.Title>
|
|
3029
|
+
<ListGroup.Description>$10.00 a month</ListGroup.Description>
|
|
3030
|
+
</ListGroup.Info>
|
|
3031
|
+
<StatusChip intent="positive" size="small">
|
|
3032
|
+
Agent
|
|
3033
|
+
</StatusChip>
|
|
3034
|
+
</ListGroup.Row>
|
|
3035
|
+
</ListGroup>
|
|
3036
|
+
)
|
|
3037
|
+
}
|
|
3038
|
+
```
|
|
3039
|
+
|
|
3040
|
+
### Content
|
|
3041
|
+
|
|
3042
|
+
#### Write the Status
|
|
3043
|
+
|
|
3044
|
+
Write one or two words that name the state, such as Pending, Live, or Needs approval. Use sentence case, and leave out words such as Status.
|
|
3045
|
+
|
|
3046
|
+
### Accessibility
|
|
3047
|
+
|
|
3048
|
+
A status chip renders a `<span>` that screen readers read as text in place. The dot and the spinner are hidden, so the label alone carries the status.
|
|
3049
|
+
|
|
3050
|
+
#### Semantics
|
|
3051
|
+
|
|
3052
|
+
* **Root (span):** Screen readers read the label in place, without the dot.
|
|
3053
|
+
* **Loading (aria-hidden):** The spinner is hidden, so screen readers read the label once.
|
|
3054
|
+
|
|
3055
|
+
#### Your Responsibilities
|
|
3056
|
+
|
|
3057
|
+
* **Name the Status in Text (SC 1.4.1):** The intent color is decorative, so the label must name the status.
|
|
3058
|
+
* **Announce a Change (aria-live):** Wrap a chip that changes in place in a polite live region.
|
|
3059
|
+
|
|
3060
|
+
### Related
|
|
3061
|
+
|
|
3062
|
+
[Badge](data-display.md#badge)
|
|
3063
|
+
|
|
3064
|
+
Use for categories and attributes.
|
|
3065
|
+
|
|
3066
|
+
[Alert](#alert)
|
|
3067
|
+
|
|
3068
|
+
Use for a status that needs an explanation.
|
|
3069
|
+
|
|
3070
|
+
[StatusRow](#statusrow)
|
|
3071
|
+
|
|
3072
|
+
Use for a status that follows a payment in a row.
|
|
3073
|
+
|
|
3074
|
+
### Examples
|
|
3075
|
+
|
|
3076
|
+
#### Basic
|
|
3077
|
+
|
|
3078
|
+
```tsx
|
|
3079
|
+
import { StatusChip } from '@tempoxyz/ds'
|
|
3080
|
+
|
|
3081
|
+
export function Demo() {
|
|
3082
|
+
return <StatusChip intent="warning">Pending</StatusChip>
|
|
3083
|
+
}
|
|
3084
|
+
```
|
|
3085
|
+
|
|
3086
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/StatusChip/Basic.tsx)
|
|
3087
|
+
|
|
3088
|
+
#### Intent
|
|
3089
|
+
|
|
3090
|
+
Set `intent` to `neutral` (default), `positive`, `warning`, or `negative`.
|
|
3091
|
+
|
|
3092
|
+
```tsx
|
|
3093
|
+
import { StatusChip, style } from '@tempoxyz/ds'
|
|
3094
|
+
|
|
3095
|
+
export function Demo() {
|
|
3096
|
+
return (
|
|
3097
|
+
<div {...styles.row()}>
|
|
3098
|
+
<StatusChip intent="positive">Authorized</StatusChip>
|
|
3099
|
+
<StatusChip intent="warning">Needs approval</StatusChip>
|
|
3100
|
+
<StatusChip intent="negative">Failed</StatusChip>
|
|
3101
|
+
<StatusChip intent="neutral">Expired</StatusChip>
|
|
3102
|
+
</div>
|
|
3103
|
+
)
|
|
3104
|
+
}
|
|
3105
|
+
|
|
3106
|
+
namespace styles {
|
|
3107
|
+
export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '8' })
|
|
3108
|
+
}
|
|
3109
|
+
```
|
|
3110
|
+
|
|
3111
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/StatusChip/Intent.tsx)
|
|
3112
|
+
|
|
3113
|
+
#### Size
|
|
3114
|
+
|
|
3115
|
+
Set `size` to `medium` (28px, default) or `small` (24px).
|
|
3116
|
+
|
|
3117
|
+
```tsx
|
|
3118
|
+
import { StatusChip, style } from '@tempoxyz/ds'
|
|
3119
|
+
|
|
3120
|
+
export function Demo() {
|
|
3121
|
+
return (
|
|
3122
|
+
<div {...styles.row()}>
|
|
3123
|
+
<StatusChip intent="positive">Live</StatusChip>
|
|
3124
|
+
<StatusChip intent="positive" size="small">
|
|
3125
|
+
Live
|
|
3126
|
+
</StatusChip>
|
|
3127
|
+
</div>
|
|
3128
|
+
)
|
|
3129
|
+
}
|
|
3130
|
+
|
|
3131
|
+
namespace styles {
|
|
3132
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '8' })
|
|
3133
|
+
}
|
|
3134
|
+
```
|
|
3135
|
+
|
|
3136
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/StatusChip/Size.tsx)
|
|
3137
|
+
|
|
3138
|
+
#### Loading
|
|
3139
|
+
|
|
3140
|
+
Set `loading` for a status in progress, such as Processing.
|
|
3141
|
+
|
|
3142
|
+
```tsx
|
|
3143
|
+
import { StatusChip } from '@tempoxyz/ds'
|
|
3144
|
+
|
|
3145
|
+
export function Demo() {
|
|
3146
|
+
return <StatusChip loading>Processing</StatusChip>
|
|
3147
|
+
}
|
|
3148
|
+
```
|
|
3149
|
+
|
|
3150
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/StatusChip/Loading.tsx)
|
|
3151
|
+
|
|
3152
|
+
#### Network
|
|
3153
|
+
|
|
3154
|
+
Set `network` for a chip that names a network, such as Mainnet or Testnet. It keeps an 80px minimum width, with the dot closer to the label.
|
|
3155
|
+
|
|
3156
|
+
```tsx
|
|
3157
|
+
import { StatusChip, style } from '@tempoxyz/ds'
|
|
3158
|
+
|
|
3159
|
+
export function Demo() {
|
|
3160
|
+
return (
|
|
3161
|
+
<div {...styles.row()}>
|
|
3162
|
+
<StatusChip intent="positive" network>
|
|
3163
|
+
Mainnet
|
|
3164
|
+
</StatusChip>
|
|
3165
|
+
<StatusChip intent="warning" network>
|
|
3166
|
+
Testnet
|
|
3167
|
+
</StatusChip>
|
|
3168
|
+
</div>
|
|
3169
|
+
)
|
|
3170
|
+
}
|
|
3171
|
+
|
|
3172
|
+
namespace styles {
|
|
3173
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '8' })
|
|
3174
|
+
}
|
|
3175
|
+
```
|
|
3176
|
+
|
|
3177
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/StatusChip/Network.tsx)
|
|
3178
|
+
|
|
3179
|
+
## StatusIndicator
|
|
3180
|
+
|
|
3181
|
+
Names the status of a system or a service with a dot and a label.
|
|
3182
|
+
|
|
3183
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/StatusIndicator.tsx)
|
|
3184
|
+
|
|
3185
|
+
Figma: [Status indicator](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=3065-474)
|
|
3186
|
+
|
|
3187
|
+
### Overview
|
|
3188
|
+
|
|
3189
|
+
A status indicator renders a short secondary label, led by an 8px dot in the color of its `intent`. It has no fill, so it sits quietly beside a title or in a list of services.
|
|
3190
|
+
|
|
3191
|
+
### Anatomy
|
|
3192
|
+
|
|
3193
|
+
Import the component and assemble its parts.
|
|
3194
|
+
|
|
3195
|
+
```tsx
|
|
3196
|
+
import { StatusIndicator } from '@tempoxyz/ds'
|
|
3197
|
+
|
|
3198
|
+
<StatusIndicator />
|
|
3199
|
+
```
|
|
3200
|
+
|
|
3201
|
+
### Guidelines
|
|
3202
|
+
|
|
3203
|
+
#### When to Use
|
|
3204
|
+
|
|
3205
|
+
* Show the live status of a system, a service, or a connection, such as Operational or Degraded.
|
|
3206
|
+
|
|
3207
|
+
#### When Not to Use
|
|
3208
|
+
|
|
3209
|
+
* Use a [StatusChip](#statuschip) for the status of a payment or an authorization.
|
|
3210
|
+
* Use a [Badge](data-display.md#badge) for a category or an attribute.
|
|
3211
|
+
* Use an [Alert](#alert) for a status that needs an explanation.
|
|
3212
|
+
|
|
3213
|
+
#### Match the Intent to the Status
|
|
3214
|
+
|
|
3215
|
+
* **Healthy (positive):** A service that works as expected, such as an online validator.
|
|
3216
|
+
* **Degraded (warning):** A service that works with delays or reduced capacity right now.
|
|
3217
|
+
* **Down (negative):** A service that fails or can't be reached, such as an offline node.
|
|
3218
|
+
* **Idle (neutral):** A service that is paused, idle, or in a state that isn't known yet.
|
|
3219
|
+
|
|
3220
|
+
#### Name the Status in the Label
|
|
3221
|
+
|
|
3222
|
+
**Do:** Name the status in a word, so it doesn't depend on the dot color.
|
|
3223
|
+
|
|
3224
|
+
```tsx
|
|
3225
|
+
<StatusIndicator intent="negative">Down</StatusIndicator>
|
|
3226
|
+
```
|
|
3227
|
+
|
|
3228
|
+
**Don't:** Label the dot with the name of the service alone.
|
|
3229
|
+
|
|
3230
|
+
```tsx
|
|
3231
|
+
<StatusIndicator intent="negative">API</StatusIndicator>
|
|
3232
|
+
```
|
|
3233
|
+
|
|
3234
|
+
### Content
|
|
3235
|
+
|
|
3236
|
+
* Keep the label to one or two words in sentence case, such as Operational or Partial outage.
|
|
3237
|
+
* Use one word for one status across a product.
|
|
3238
|
+
|
|
3239
|
+
### Accessibility
|
|
3240
|
+
|
|
3241
|
+
A status indicator renders a `<span>` with no role. The dot is hidden, so screen readers read the label alone.
|
|
3242
|
+
|
|
3243
|
+
* **Dot (aria-hidden):** Hides the dot from screen readers, so the label carries the status.
|
|
3244
|
+
* **Live Updates (role):** If the status changes in place, set `role="status"` so the change is announced.
|
|
3245
|
+
|
|
3246
|
+
### Related
|
|
3247
|
+
|
|
3248
|
+
[StatusChip](#statuschip)
|
|
3249
|
+
|
|
3250
|
+
Use for the status of a payment or an authorization.
|
|
3251
|
+
|
|
3252
|
+
[Badge](data-display.md#badge)
|
|
3253
|
+
|
|
3254
|
+
Use for categories and attributes.
|
|
3255
|
+
|
|
3256
|
+
[Alert](#alert)
|
|
3257
|
+
|
|
3258
|
+
Use for a status that needs an explanation.
|
|
3259
|
+
|
|
3260
|
+
### Examples
|
|
3261
|
+
|
|
3262
|
+
#### Basic
|
|
3263
|
+
|
|
3264
|
+
```tsx
|
|
3265
|
+
import { StatusIndicator } from '@tempoxyz/ds'
|
|
3266
|
+
|
|
3267
|
+
export function Demo() {
|
|
3268
|
+
return <StatusIndicator intent="positive">Operational</StatusIndicator>
|
|
3269
|
+
}
|
|
3270
|
+
```
|
|
3271
|
+
|
|
3272
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/StatusIndicator/Basic.tsx)
|
|
3273
|
+
|
|
3274
|
+
#### Intent
|
|
3275
|
+
|
|
3276
|
+
Set `intent` to `neutral` (default), `positive`, `warning`, or `negative`. Each colors the dot.
|
|
3277
|
+
|
|
3278
|
+
```tsx
|
|
3279
|
+
import { StatusIndicator, style } from '@tempoxyz/ds'
|
|
3280
|
+
|
|
3281
|
+
export function Demo() {
|
|
3282
|
+
return (
|
|
3283
|
+
<div {...styles.row()}>
|
|
3284
|
+
<StatusIndicator intent="neutral">Idle</StatusIndicator>
|
|
3285
|
+
<StatusIndicator intent="positive">Operational</StatusIndicator>
|
|
3286
|
+
<StatusIndicator intent="warning">Degraded</StatusIndicator>
|
|
3287
|
+
<StatusIndicator intent="negative">Down</StatusIndicator>
|
|
3288
|
+
</div>
|
|
3289
|
+
)
|
|
3290
|
+
}
|
|
3291
|
+
|
|
3292
|
+
namespace styles {
|
|
3293
|
+
export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '16' })
|
|
3294
|
+
}
|
|
3295
|
+
```
|
|
3296
|
+
|
|
3297
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/StatusIndicator/Intent.tsx)
|
|
3298
|
+
|
|
3299
|
+
## StatusRow
|
|
3300
|
+
|
|
3301
|
+
Follows the status of one payment or task while it runs.
|
|
3302
|
+
|
|
3303
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/StatusRow.tsx)
|
|
3304
|
+
|
|
3305
|
+
Figma: [Messaging/Status Row](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-3981)
|
|
3306
|
+
|
|
3307
|
+
### Overview
|
|
3308
|
+
|
|
3309
|
+
A status row renders a tinted row with a leading mark, a title over a description, and an optional trailing [StatusChip](#statuschip). It announces a change of its text to screen readers, so it can update in place as the task moves on.
|
|
3310
|
+
|
|
3311
|
+
### Anatomy
|
|
3312
|
+
|
|
3313
|
+
Import the component and assemble its parts.
|
|
3314
|
+
|
|
3315
|
+
```tsx
|
|
3316
|
+
import { StatusRow } from '@tempoxyz/ds'
|
|
3317
|
+
|
|
3318
|
+
<StatusRow>
|
|
3319
|
+
<StatusRow.Icon />
|
|
3320
|
+
<StatusRow.Content>
|
|
3321
|
+
<StatusRow.Title />
|
|
3322
|
+
<StatusRow.Description />
|
|
3323
|
+
</StatusRow.Content>
|
|
3324
|
+
</StatusRow>
|
|
3325
|
+
```
|
|
3326
|
+
|
|
3327
|
+
### Guidelines
|
|
3328
|
+
|
|
3329
|
+
#### When to Use
|
|
3330
|
+
|
|
3331
|
+
* Follow a deposit, a payment, or an authorization that completes within minutes.
|
|
3332
|
+
* Confirm in place that the task finished.
|
|
3333
|
+
|
|
3334
|
+
#### When Not to Use
|
|
3335
|
+
|
|
3336
|
+
* Use [Alert](#alert) for guidance that is not tied to a running task.
|
|
3337
|
+
* Use [Toast](#toast) to confirm an action briefly and out of the flow.
|
|
3338
|
+
* Use [ListGroup](data-display.md#listgroup) for a list of finished payments.
|
|
3339
|
+
|
|
3340
|
+
#### Match the Mark to the State
|
|
3341
|
+
|
|
3342
|
+
* **Running (neutral):** A spinner, with a chip that names the step.
|
|
3343
|
+
* **Done (positive):** A check in the positive color, without a chip.
|
|
3344
|
+
|
|
3345
|
+
#### State the Task and the Wait
|
|
3346
|
+
|
|
3347
|
+
**Do:** Name the amount in the title and the expected wait in the description.
|
|
3348
|
+
|
|
3349
|
+
```tsx
|
|
3350
|
+
import { Spinner, StatusRow } from '@tempoxyz/ds'
|
|
3351
|
+
|
|
3352
|
+
export function Demo() {
|
|
3353
|
+
return (
|
|
3354
|
+
<StatusRow>
|
|
3355
|
+
<StatusRow.Icon>
|
|
3356
|
+
<Spinner />
|
|
3357
|
+
</StatusRow.Icon>
|
|
3358
|
+
<StatusRow.Content>
|
|
3359
|
+
<StatusRow.Title>Waiting for $10.00</StatusRow.Title>
|
|
3360
|
+
<StatusRow.Description>Usually under a minute on Tempo.</StatusRow.Description>
|
|
3361
|
+
</StatusRow.Content>
|
|
3362
|
+
</StatusRow>
|
|
3363
|
+
)
|
|
3364
|
+
}
|
|
3365
|
+
```
|
|
3366
|
+
|
|
3367
|
+
**Don't:** Ask people to wait without saying for what or for how long.
|
|
3368
|
+
|
|
3369
|
+
```tsx
|
|
3370
|
+
import { Spinner, StatusRow } from '@tempoxyz/ds'
|
|
3371
|
+
|
|
3372
|
+
export function Demo() {
|
|
3373
|
+
return (
|
|
3374
|
+
<StatusRow>
|
|
3375
|
+
<StatusRow.Icon>
|
|
3376
|
+
<Spinner />
|
|
3377
|
+
</StatusRow.Icon>
|
|
3378
|
+
<StatusRow.Content>
|
|
3379
|
+
<StatusRow.Title>Please wait</StatusRow.Title>
|
|
3380
|
+
<StatusRow.Description>Something is happening.</StatusRow.Description>
|
|
3381
|
+
</StatusRow.Content>
|
|
3382
|
+
</StatusRow>
|
|
3383
|
+
)
|
|
3384
|
+
}
|
|
3385
|
+
```
|
|
3386
|
+
|
|
3387
|
+
### Content
|
|
3388
|
+
|
|
3389
|
+
#### Write the Title and the Description
|
|
3390
|
+
|
|
3391
|
+
Start the title with the state and the amount, such as Waiting for $10.00. In the description, give the expected wait and whether people can leave the page.
|
|
3392
|
+
|
|
3393
|
+
### Accessibility
|
|
3394
|
+
|
|
3395
|
+
A status row renders a `<div>` with the `status` role, so screen readers announce a change of its text politely. The leading mark is hidden.
|
|
3396
|
+
|
|
3397
|
+
#### Semantics
|
|
3398
|
+
|
|
3399
|
+
* **Root (status):** Screen readers announce a change of the text without moving focus.
|
|
3400
|
+
* **Icon (aria-hidden):** The spinner and the check are hidden, so the title carries the state.
|
|
3401
|
+
|
|
3402
|
+
#### Your Responsibilities
|
|
3403
|
+
|
|
3404
|
+
* **Update the Row in Place (SC 4.1.3):** Change the text of the mounted row, so the status role announces it.
|
|
3405
|
+
|
|
3406
|
+
### Related
|
|
3407
|
+
|
|
3408
|
+
[StatusChip](#statuschip)
|
|
3409
|
+
|
|
3410
|
+
Use for the status at the end of the row.
|
|
3411
|
+
|
|
3412
|
+
[Spinner](#spinner)
|
|
3413
|
+
|
|
3414
|
+
Use for the leading mark while the task runs.
|
|
3415
|
+
|
|
3416
|
+
[Alert](#alert)
|
|
3417
|
+
|
|
3418
|
+
Use for guidance that is not tied to a running task.
|
|
3419
|
+
|
|
3420
|
+
### Examples
|
|
3421
|
+
|
|
3422
|
+
#### Basic
|
|
3423
|
+
|
|
3424
|
+
```tsx
|
|
3425
|
+
import { Spinner, StatusChip, StatusRow } from '@tempoxyz/ds'
|
|
3426
|
+
|
|
3427
|
+
export function Demo() {
|
|
3428
|
+
return (
|
|
3429
|
+
<StatusRow>
|
|
3430
|
+
<StatusRow.Icon>
|
|
3431
|
+
<Spinner />
|
|
3432
|
+
</StatusRow.Icon>
|
|
3433
|
+
<StatusRow.Content>
|
|
3434
|
+
<StatusRow.Title>Waiting for $10.00</StatusRow.Title>
|
|
3435
|
+
<StatusRow.Description>
|
|
3436
|
+
Usually under a minute on Tempo. You can leave this page.
|
|
3437
|
+
</StatusRow.Description>
|
|
3438
|
+
</StatusRow.Content>
|
|
3439
|
+
<StatusChip intent="warning" size="small">
|
|
3440
|
+
Pending
|
|
3441
|
+
</StatusChip>
|
|
3442
|
+
</StatusRow>
|
|
3443
|
+
)
|
|
3444
|
+
}
|
|
3445
|
+
```
|
|
3446
|
+
|
|
3447
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/StatusRow/Basic.tsx)
|
|
3448
|
+
|
|
3449
|
+
#### Intent
|
|
3450
|
+
|
|
3451
|
+
Set `intent` to `neutral` (default) while the task runs, or `positive` once it is done.
|
|
3452
|
+
|
|
3453
|
+
```tsx
|
|
3454
|
+
import { StatusRow } from '@tempoxyz/ds'
|
|
3455
|
+
import { CheckCircle } from '@tempoxyz/ds/icons'
|
|
3456
|
+
|
|
3457
|
+
export function Demo() {
|
|
3458
|
+
return (
|
|
3459
|
+
<StatusRow intent="positive">
|
|
3460
|
+
<StatusRow.Icon>
|
|
3461
|
+
<CheckCircle />
|
|
3462
|
+
</StatusRow.Icon>
|
|
3463
|
+
<StatusRow.Content>
|
|
3464
|
+
<StatusRow.Title>Received $10.00</StatusRow.Title>
|
|
3465
|
+
<StatusRow.Description>The funds are in your wallet.</StatusRow.Description>
|
|
3466
|
+
</StatusRow.Content>
|
|
3467
|
+
</StatusRow>
|
|
3468
|
+
)
|
|
3469
|
+
}
|
|
3470
|
+
```
|
|
3471
|
+
|
|
3472
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/StatusRow/Intent.tsx)
|
|
3473
|
+
|
|
3474
|
+
## Toast
|
|
3475
|
+
|
|
3476
|
+
Shows a brief notification that dismisses itself.
|
|
3477
|
+
|
|
3478
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Toast.tsx)
|
|
3479
|
+
|
|
3480
|
+
Figma: [Toast](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=1186-3381) (`Toast.Item`)
|
|
3481
|
+
|
|
3482
|
+
### Overview
|
|
3483
|
+
|
|
3484
|
+
Toasts are queued with a hook and render in a live region at the edge of the viewport.
|
|
3485
|
+
|
|
3486
|
+
### Anatomy
|
|
3487
|
+
|
|
3488
|
+
Import the component and assemble its parts.
|
|
3489
|
+
|
|
3490
|
+
```tsx
|
|
3491
|
+
import { Toast } from '@tempoxyz/ds'
|
|
3492
|
+
|
|
3493
|
+
<Toast.Provider>
|
|
3494
|
+
<Toast.Viewport />
|
|
3495
|
+
<Toast.Item />
|
|
3496
|
+
</Toast.Provider>
|
|
3497
|
+
```
|
|
3498
|
+
|
|
3499
|
+
### Guidelines
|
|
3500
|
+
|
|
3501
|
+
#### When to Use
|
|
3502
|
+
|
|
3503
|
+
* Confirm that a user action finished, such as Payment sent or Webhook saved.
|
|
3504
|
+
* Report a background event that needs no response, such as a deposit that arrived while the user was on another page.
|
|
3505
|
+
* Offer a short Undo after a reversible action, such as Archived, when the same result is reachable elsewhere.
|
|
3506
|
+
|
|
3507
|
+
#### When Not to Use
|
|
3508
|
+
|
|
3509
|
+
* Use an [Alert](#alert) for an error or warning that must stay beside its content, such as a failed payment.
|
|
3510
|
+
* Use a [Banner](#banner) for a condition that affects the whole product, such as an outage.
|
|
3511
|
+
* Use an [AlertDialog](overlays.md#alertdialog) for a decision before an action continues.
|
|
3512
|
+
* Use `Field.Error` from [Field](forms-and-inputs.md#field-1) for validation messages on an input.
|
|
3513
|
+
* Use `loading` on a [Button](actions.md#button), or [Progress](#progress-1), for work that still runs.
|
|
3514
|
+
|
|
3515
|
+
#### Keep Required Actions Out of Toasts
|
|
3516
|
+
|
|
3517
|
+
A toast dismisses itself, and keyboard users must press F6 to reach it. Put required steps in the page or in an [AlertDialog](overlays.md#alertdialog).
|
|
3518
|
+
|
|
3519
|
+
**Do:** Confirm a finished action and include the detail that identifies it.
|
|
3520
|
+
|
|
3521
|
+
```tsx
|
|
3522
|
+
/**
|
|
3523
|
+
* Do example for "Keep Required Actions Out of Toasts" on the Toast page.
|
|
3524
|
+
* Confirm a finished action and include the detail that identifies it.
|
|
3525
|
+
* @module
|
|
3526
|
+
*/
|
|
3527
|
+
import { CheckCircle, Close } from '@tempoxyz/ds/icons'
|
|
3528
|
+
import { style } from '@tempoxyz/ds'
|
|
3529
|
+
|
|
3530
|
+
// Toasts render in a portal, so this preview draws one in place with the toast's styles.
|
|
3531
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
3532
|
+
export function Demo() {
|
|
3533
|
+
return (
|
|
3534
|
+
<div {...styles.toast()}>
|
|
3535
|
+
<CheckCircle {...styles.icon()} />
|
|
3536
|
+
<div {...styles.body()}>
|
|
3537
|
+
<div {...styles.title()}>Payment sent</div>
|
|
3538
|
+
<div {...styles.description()}>50.00 USDC to 0x8f3c…a21b</div>
|
|
3539
|
+
</div>
|
|
3540
|
+
<Close {...styles.close()} />
|
|
3541
|
+
</div>
|
|
3542
|
+
)
|
|
3543
|
+
}
|
|
3544
|
+
|
|
3545
|
+
namespace styles {
|
|
3546
|
+
export const body = style({
|
|
3547
|
+
display: 'flex',
|
|
3548
|
+
flex: '1 !custom',
|
|
3549
|
+
flexDirection: 'column',
|
|
3550
|
+
minWidth: '0px !custom',
|
|
3551
|
+
rowGap: '4',
|
|
3552
|
+
})
|
|
3553
|
+
|
|
3554
|
+
export const close = style({ color: 'content.tertiary', flexShrink: '0 !custom', fontSize: '16' })
|
|
3555
|
+
|
|
3556
|
+
export const description = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
3557
|
+
|
|
3558
|
+
export const icon = style({ color: 'content.positive', flexShrink: '0 !custom', fontSize: '20' })
|
|
3559
|
+
|
|
3560
|
+
export const title = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
3561
|
+
|
|
3562
|
+
export const toast = style({
|
|
3563
|
+
alignItems: 'center',
|
|
3564
|
+
backgroundColor: 'background.elevated',
|
|
3565
|
+
borderRadius: 'sm',
|
|
3566
|
+
boxShadow: 'regular',
|
|
3567
|
+
boxSizing: 'border-box',
|
|
3568
|
+
columnGap: '12',
|
|
3569
|
+
display: 'flex',
|
|
3570
|
+
paddingBlock: '16',
|
|
3571
|
+
paddingInline: '20',
|
|
3572
|
+
width: '100% !custom',
|
|
3573
|
+
})
|
|
3574
|
+
}
|
|
3575
|
+
```
|
|
3576
|
+
|
|
3577
|
+
**Don't:** Ask for a confirmation or another required step in a toast.
|
|
3578
|
+
|
|
3579
|
+
```tsx
|
|
3580
|
+
/**
|
|
3581
|
+
* Don't example for "Keep Required Actions Out of Toasts" on the Toast page.
|
|
3582
|
+
* Don't ask for a confirmation or another required step in a toast.
|
|
3583
|
+
* @module
|
|
3584
|
+
*/
|
|
3585
|
+
import { AlertTriangle, Close } from '@tempoxyz/ds/icons'
|
|
3586
|
+
import { style } from '@tempoxyz/ds'
|
|
3587
|
+
|
|
3588
|
+
// Toasts render in a portal, so this preview draws one in place with the toast's styles.
|
|
3589
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
3590
|
+
export function Demo() {
|
|
3591
|
+
return (
|
|
3592
|
+
<div {...styles.toast()}>
|
|
3593
|
+
<AlertTriangle {...styles.icon()} />
|
|
3594
|
+
<div {...styles.body()}>
|
|
3595
|
+
<div {...styles.title()}>Confirm payment</div>
|
|
3596
|
+
<div {...styles.description()}>50.00 USDC to 0x8f3c…a21b</div>
|
|
3597
|
+
</div>
|
|
3598
|
+
<span {...styles.action()}>Confirm</span>
|
|
3599
|
+
<Close {...styles.close()} />
|
|
3600
|
+
</div>
|
|
3601
|
+
)
|
|
3602
|
+
}
|
|
3603
|
+
|
|
3604
|
+
namespace styles {
|
|
3605
|
+
export const action = style({
|
|
3606
|
+
alignItems: 'center',
|
|
3607
|
+
backgroundColor: 'container.regular',
|
|
3608
|
+
borderRadius: 'full',
|
|
3609
|
+
color: 'content.primary',
|
|
3610
|
+
cornerShape: 'round',
|
|
3611
|
+
display: 'inline-flex',
|
|
3612
|
+
flexShrink: '0 !custom',
|
|
3613
|
+
height: '32',
|
|
3614
|
+
paddingInline: '12',
|
|
3615
|
+
typography: 'body.b3Strong',
|
|
3616
|
+
})
|
|
3617
|
+
|
|
3618
|
+
export const body = style({
|
|
3619
|
+
display: 'flex',
|
|
3620
|
+
flex: '1 !custom',
|
|
3621
|
+
flexDirection: 'column',
|
|
3622
|
+
minWidth: '0px !custom',
|
|
3623
|
+
rowGap: '4',
|
|
3624
|
+
})
|
|
3625
|
+
|
|
3626
|
+
export const close = style({ color: 'content.tertiary', flexShrink: '0 !custom', fontSize: '16' })
|
|
3627
|
+
|
|
3628
|
+
export const description = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
3629
|
+
|
|
3630
|
+
export const icon = style({ color: 'content.warning', flexShrink: '0 !custom', fontSize: '20' })
|
|
3631
|
+
|
|
3632
|
+
export const title = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
3633
|
+
|
|
3634
|
+
export const toast = style({
|
|
3635
|
+
alignItems: 'center',
|
|
3636
|
+
backgroundColor: 'background.elevated',
|
|
3637
|
+
borderRadius: 'sm',
|
|
3638
|
+
boxShadow: 'regular',
|
|
3639
|
+
boxSizing: 'border-box',
|
|
3640
|
+
columnGap: '12',
|
|
3641
|
+
display: 'flex',
|
|
3642
|
+
paddingBlock: '16',
|
|
3643
|
+
paddingInline: '20',
|
|
3644
|
+
width: '100% !custom',
|
|
3645
|
+
})
|
|
3646
|
+
}
|
|
3647
|
+
```
|
|
3648
|
+
|
|
3649
|
+
An Undo action is fine if the page also reverses the change, such as an Archive tab that restores an archived key.
|
|
3650
|
+
|
|
3651
|
+
#### Choose an Intent
|
|
3652
|
+
|
|
3653
|
+
* **Neutral (neutral):** The default, with no icon. Updates with no outcome to judge, such as Signed out.
|
|
3654
|
+
* **Info (info):** Events the user didn't start, such as a deposit that arrived.
|
|
3655
|
+
* **Positive (positive):** An action that succeeded, such as a confirmation that reads Payment sent.
|
|
3656
|
+
* **Warning (warning):** An action that finished with a caveat, such as a test delivery that timed out.
|
|
3657
|
+
* **Negative (negative):** A non-critical action that failed and that the user can try again.
|
|
3658
|
+
|
|
3659
|
+
#### Set Duration by Content
|
|
3660
|
+
|
|
3661
|
+
* **Short Content (5 seconds):** The default, for a title and a short description.
|
|
3662
|
+
* **Longer Description (timeout):** Raise `timeout`, or set it app-wide on `Toast.Provider`.
|
|
3663
|
+
* **Action (timeout: 0):** Keeps the toast open until dismissed ([SC 2.2.1](https://www.w3.org/WAI/WCAG22/Understanding/timing-adjustable.html)).
|
|
3664
|
+
|
|
3665
|
+
#### Send One Toast per Outcome
|
|
3666
|
+
|
|
3667
|
+
`Toast.Provider` shows up to three toasts by default, and hides older ones past its `limit`. Combine related results into one toast.
|
|
3668
|
+
|
|
3669
|
+
**Do:** Combine related results into one toast, such as 3 payments sent.
|
|
3670
|
+
|
|
3671
|
+
```tsx
|
|
3672
|
+
/**
|
|
3673
|
+
* Do example for "Send One Toast per Outcome" on the Toast page.
|
|
3674
|
+
* Combine related results into one toast, such as 3 payments sent.
|
|
3675
|
+
* @module
|
|
3676
|
+
*/
|
|
3677
|
+
import { CheckCircle, Close } from '@tempoxyz/ds/icons'
|
|
3678
|
+
import { style } from '@tempoxyz/ds'
|
|
3679
|
+
|
|
3680
|
+
// Toasts render in a portal, so this preview draws one in place with the toast's styles.
|
|
3681
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
3682
|
+
export function Demo() {
|
|
3683
|
+
return (
|
|
3684
|
+
<div {...styles.toast()}>
|
|
3685
|
+
<CheckCircle {...styles.icon()} />
|
|
3686
|
+
<div {...styles.body()}>
|
|
3687
|
+
<div {...styles.title()}>3 payments sent</div>
|
|
3688
|
+
<div {...styles.description()}>150.00 USDC to 3 recipients</div>
|
|
3689
|
+
</div>
|
|
3690
|
+
<Close {...styles.close()} />
|
|
3691
|
+
</div>
|
|
3692
|
+
)
|
|
3693
|
+
}
|
|
3694
|
+
|
|
3695
|
+
namespace styles {
|
|
3696
|
+
export const body = style({
|
|
3697
|
+
display: 'flex',
|
|
3698
|
+
flex: '1 !custom',
|
|
3699
|
+
flexDirection: 'column',
|
|
3700
|
+
minWidth: '0px !custom',
|
|
3701
|
+
rowGap: '4',
|
|
3702
|
+
})
|
|
3703
|
+
|
|
3704
|
+
export const close = style({ color: 'content.tertiary', flexShrink: '0 !custom', fontSize: '16' })
|
|
3705
|
+
|
|
3706
|
+
export const description = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
3707
|
+
|
|
3708
|
+
export const icon = style({ color: 'content.positive', flexShrink: '0 !custom', fontSize: '20' })
|
|
3709
|
+
|
|
3710
|
+
export const title = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
3711
|
+
|
|
3712
|
+
export const toast = style({
|
|
3713
|
+
alignItems: 'center',
|
|
3714
|
+
backgroundColor: 'background.elevated',
|
|
3715
|
+
borderRadius: 'sm',
|
|
3716
|
+
boxShadow: 'regular',
|
|
3717
|
+
boxSizing: 'border-box',
|
|
3718
|
+
columnGap: '12',
|
|
3719
|
+
display: 'flex',
|
|
3720
|
+
paddingBlock: '16',
|
|
3721
|
+
paddingInline: '20',
|
|
3722
|
+
width: '100% !custom',
|
|
3723
|
+
})
|
|
3724
|
+
}
|
|
3725
|
+
```
|
|
3726
|
+
|
|
3727
|
+
**Don't:** Send a separate toast for each result of one action.
|
|
3728
|
+
|
|
3729
|
+
```tsx
|
|
3730
|
+
/**
|
|
3731
|
+
* Don't example for "Send One Toast per Outcome" on the Toast page.
|
|
3732
|
+
* Don't send a separate toast for each result of one action.
|
|
3733
|
+
* @module
|
|
3734
|
+
*/
|
|
3735
|
+
import { CheckCircle, Close } from '@tempoxyz/ds/icons'
|
|
3736
|
+
import { style } from '@tempoxyz/ds'
|
|
3737
|
+
|
|
3738
|
+
const payments = ['0x8f3c…a21b', '0x41d0…9c7e', '0xb27a…04f5']
|
|
3739
|
+
|
|
3740
|
+
// Toasts render in a portal, so this preview draws them in place with the toast's styles.
|
|
3741
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
3742
|
+
export function Demo() {
|
|
3743
|
+
return (
|
|
3744
|
+
<div {...styles.stack()}>
|
|
3745
|
+
{payments.map((address) => (
|
|
3746
|
+
<div key={address} {...styles.toast()}>
|
|
3747
|
+
<CheckCircle {...styles.icon()} />
|
|
3748
|
+
<div {...styles.body()}>
|
|
3749
|
+
<div {...styles.title()}>Payment sent</div>
|
|
3750
|
+
<div {...styles.description()}>50.00 USDC to {address}</div>
|
|
3751
|
+
</div>
|
|
3752
|
+
<Close {...styles.close()} />
|
|
3753
|
+
</div>
|
|
3754
|
+
))}
|
|
3755
|
+
</div>
|
|
3756
|
+
)
|
|
3757
|
+
}
|
|
3758
|
+
|
|
3759
|
+
namespace styles {
|
|
3760
|
+
export const body = style({
|
|
3761
|
+
display: 'flex',
|
|
3762
|
+
flex: '1 !custom',
|
|
3763
|
+
flexDirection: 'column',
|
|
3764
|
+
minWidth: '0px !custom',
|
|
3765
|
+
rowGap: '4',
|
|
3766
|
+
})
|
|
3767
|
+
|
|
3768
|
+
export const close = style({ color: 'content.tertiary', flexShrink: '0 !custom', fontSize: '16' })
|
|
3769
|
+
|
|
3770
|
+
export const description = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
3771
|
+
|
|
3772
|
+
export const icon = style({ color: 'content.positive', flexShrink: '0 !custom', fontSize: '20' })
|
|
3773
|
+
|
|
3774
|
+
export const stack = style({
|
|
3775
|
+
display: 'flex',
|
|
3776
|
+
flexDirection: 'column',
|
|
3777
|
+
gap: '8',
|
|
3778
|
+
width: '100% !custom',
|
|
3779
|
+
})
|
|
3780
|
+
|
|
3781
|
+
export const title = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
3782
|
+
|
|
3783
|
+
export const toast = style({
|
|
3784
|
+
alignItems: 'center',
|
|
3785
|
+
backgroundColor: 'background.elevated',
|
|
3786
|
+
borderRadius: 'sm',
|
|
3787
|
+
boxShadow: 'regular',
|
|
3788
|
+
boxSizing: 'border-box',
|
|
3789
|
+
columnGap: '12',
|
|
3790
|
+
display: 'flex',
|
|
3791
|
+
paddingBlock: '16',
|
|
3792
|
+
paddingInline: '20',
|
|
3793
|
+
width: '100% !custom',
|
|
3794
|
+
})
|
|
3795
|
+
}
|
|
3796
|
+
```
|
|
3797
|
+
|
|
3798
|
+
### Content
|
|
3799
|
+
|
|
3800
|
+
* Write the title as the result in a few words, usually past tense: Payment sent, Key revoked, Webhook saved.
|
|
3801
|
+
* Add a description only for the detail that identifies the action, such as 50.00 USDC to 0x8f3c…a21b.
|
|
3802
|
+
* Leave out exclamation marks and filler such as Success or Done.
|
|
3803
|
+
* Label the action with one verb, such as Undo or Retry.
|
|
3804
|
+
|
|
3805
|
+
### Accessibility
|
|
3806
|
+
|
|
3807
|
+
Toasts never take focus on their own. Don't move focus to a new toast yourself.
|
|
3808
|
+
|
|
3809
|
+
#### Semantics
|
|
3810
|
+
|
|
3811
|
+
* **Toast.Viewport (region):** A landmark named "Notifications". Announces new toasts without moving focus.
|
|
3812
|
+
* **Toast (dialog):** A non-modal dialog, named by its title and described by its description.
|
|
3813
|
+
* **High Priority (alertdialog):** With `priority: 'high'`, a separate alert interrupts current speech. Intent alone never does.
|
|
3814
|
+
* **Action and Dismiss (button):** The action is named by `action.label`. Every toast also has a Dismiss button.
|
|
3815
|
+
* **Intent Icon (aria-hidden):** Hidden from assistive technology, so the title must carry the outcome.
|
|
3816
|
+
|
|
3817
|
+
#### Keyboard
|
|
3818
|
+
|
|
3819
|
+
* **Reach the Viewport (F6):** Moves focus to the toast viewport from anywhere on the page.
|
|
3820
|
+
* **Move Through the Toast (Tab):** Moves focus to the newest toast, then to its action and Dismiss button.
|
|
3821
|
+
* **Move Back (Shift+Tab):** Moves focus back. From the viewport, returns focus to where it was before F6.
|
|
3822
|
+
* **Activate a Button (Enter or Space):** Activates the action or the Dismiss button that holds focus.
|
|
3823
|
+
* **Dismiss the Toast (Escape):** Dismisses the toast that holds focus, the same as its Dismiss button.
|
|
3824
|
+
|
|
3825
|
+
#### Dismissal
|
|
3826
|
+
|
|
3827
|
+
* **Pausing:** Hover or focus in the viewport pauses all dismiss timers, as does a background window.
|
|
3828
|
+
* **Swiping:** On touch screens, a swipe down or to the right dismisses a toast.
|
|
3829
|
+
|
|
3830
|
+
#### Your Responsibilities
|
|
3831
|
+
|
|
3832
|
+
* **Reserve High Priority (priority: 'high'):** Use it only for urgent messages. Show critical errors inline or in a [Dialog](overlays.md#dialog).
|
|
3833
|
+
* **Render One Viewport (F6):** Render one viewport per app, so the shortcut always reaches it.
|
|
3834
|
+
|
|
3835
|
+
### Related
|
|
3836
|
+
|
|
3837
|
+
[Alert](#alert)
|
|
3838
|
+
|
|
3839
|
+
Use for messages that stay beside their content.
|
|
3840
|
+
|
|
3841
|
+
[Banner](#banner)
|
|
3842
|
+
|
|
3843
|
+
Use for messages about the whole product.
|
|
3844
|
+
|
|
3845
|
+
[AlertDialog](overlays.md#alertdialog)
|
|
3846
|
+
|
|
3847
|
+
Use for decisions before an action continues.
|
|
3848
|
+
|
|
3849
|
+
[Feedback and Status](../patterns.md#feedback-and-status)
|
|
3850
|
+
|
|
3851
|
+
Covers choosing a message component.
|
|
3852
|
+
|
|
3853
|
+
### Examples
|
|
3854
|
+
|
|
3855
|
+
#### Basic
|
|
3856
|
+
|
|
3857
|
+
```tsx
|
|
3858
|
+
import { Button, Toast } from '@tempoxyz/ds'
|
|
3859
|
+
|
|
3860
|
+
function Trigger() {
|
|
3861
|
+
const toast = Toast.useToast()
|
|
3862
|
+
|
|
3863
|
+
return (
|
|
3864
|
+
<Button
|
|
3865
|
+
onClick={() =>
|
|
3866
|
+
toast.add({ description: 'Transfers settle in seconds.', title: 'Payment sent' })
|
|
3867
|
+
}
|
|
3868
|
+
size="small"
|
|
3869
|
+
variant="secondary"
|
|
3870
|
+
>
|
|
3871
|
+
Show toast
|
|
3872
|
+
</Button>
|
|
3873
|
+
)
|
|
3874
|
+
}
|
|
3875
|
+
|
|
3876
|
+
export function Demo() {
|
|
3877
|
+
return (
|
|
3878
|
+
<Toast.Provider>
|
|
3879
|
+
<Trigger />
|
|
3880
|
+
<Toast.Viewport />
|
|
3881
|
+
</Toast.Provider>
|
|
3882
|
+
)
|
|
3883
|
+
}
|
|
3884
|
+
```
|
|
3885
|
+
|
|
3886
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Toast/Basic.tsx)
|
|
3887
|
+
|
|
3888
|
+
#### Intent
|
|
3889
|
+
|
|
3890
|
+
Pass `intent` to `toast.add` as `neutral` (default), `info`, `positive`, `warning`, or `negative`.
|
|
3891
|
+
|
|
3892
|
+
```tsx
|
|
3893
|
+
import { Button, style, Toast } from '@tempoxyz/ds'
|
|
3894
|
+
|
|
3895
|
+
const intents = ['neutral', 'info', 'positive', 'warning', 'negative'] as const
|
|
3896
|
+
|
|
3897
|
+
function Triggers() {
|
|
3898
|
+
const toast = Toast.useToast()
|
|
3899
|
+
|
|
3900
|
+
return (
|
|
3901
|
+
<div {...styles.row()}>
|
|
3902
|
+
{intents.map((intent) => (
|
|
3903
|
+
<Button
|
|
3904
|
+
key={intent}
|
|
3905
|
+
onClick={() =>
|
|
3906
|
+
toast.add({
|
|
3907
|
+
description: 'Transfers settle in seconds.',
|
|
3908
|
+
intent,
|
|
3909
|
+
title: `${intent} toast`,
|
|
3910
|
+
})
|
|
3911
|
+
}
|
|
3912
|
+
size="small"
|
|
3913
|
+
variant="secondary"
|
|
3914
|
+
>
|
|
3915
|
+
{intent}
|
|
3916
|
+
</Button>
|
|
3917
|
+
))}
|
|
3918
|
+
</div>
|
|
3919
|
+
)
|
|
3920
|
+
}
|
|
3921
|
+
|
|
3922
|
+
export function Demo() {
|
|
3923
|
+
return (
|
|
3924
|
+
<Toast.Provider>
|
|
3925
|
+
<Triggers />
|
|
3926
|
+
<Toast.Viewport />
|
|
3927
|
+
</Toast.Provider>
|
|
3928
|
+
)
|
|
3929
|
+
}
|
|
3930
|
+
|
|
3931
|
+
namespace styles {
|
|
3932
|
+
export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
|
|
3933
|
+
}
|
|
3934
|
+
```
|
|
3935
|
+
|
|
3936
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Toast/Intent.tsx)
|
|
3937
|
+
|
|
3938
|
+
#### Action
|
|
3939
|
+
|
|
3940
|
+
Pass an `action` with a `label` to add a button. Set `timeout: 0` to keep the toast open until dismissed.
|
|
3941
|
+
|
|
3942
|
+
```tsx
|
|
3943
|
+
import { Button, Toast } from '@tempoxyz/ds'
|
|
3944
|
+
|
|
3945
|
+
function Trigger() {
|
|
3946
|
+
const toast = Toast.useToast()
|
|
3947
|
+
|
|
3948
|
+
return (
|
|
3949
|
+
<Button
|
|
3950
|
+
onClick={() =>
|
|
3951
|
+
toast.add({
|
|
3952
|
+
action: { label: 'Undo' },
|
|
3953
|
+
intent: 'positive',
|
|
3954
|
+
timeout: 0,
|
|
3955
|
+
title: 'Archived',
|
|
3956
|
+
})
|
|
3957
|
+
}
|
|
3958
|
+
size="small"
|
|
3959
|
+
variant="secondary"
|
|
3960
|
+
>
|
|
3961
|
+
With action
|
|
3962
|
+
</Button>
|
|
3963
|
+
)
|
|
3964
|
+
}
|
|
3965
|
+
|
|
3966
|
+
export function Demo() {
|
|
3967
|
+
return (
|
|
3968
|
+
<Toast.Provider>
|
|
3969
|
+
<Trigger />
|
|
3970
|
+
<Toast.Viewport />
|
|
3971
|
+
</Toast.Provider>
|
|
3972
|
+
)
|
|
3973
|
+
}
|
|
3974
|
+
```
|
|
3975
|
+
|
|
3976
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Toast/Action.tsx)
|
|
3977
|
+
|
|
3978
|
+
#### Item
|
|
3979
|
+
|
|
3980
|
+
`Toast.Viewport` renders a `Toast.Item` for each queued toast. Render an item yourself only in a custom viewport under `Toast.Provider`, and pass it a toast object, whose `type` sets the intent.
|
|
3981
|
+
|
|
3982
|
+
```tsx
|
|
3983
|
+
import { style, Toast } from '@tempoxyz/ds'
|
|
3984
|
+
|
|
3985
|
+
export function Demo() {
|
|
3986
|
+
return (
|
|
3987
|
+
<Toast.Provider>
|
|
3988
|
+
<div {...styles.frame()}>
|
|
3989
|
+
<Toast.Item
|
|
3990
|
+
toast={{
|
|
3991
|
+
description: 'Sent 25.00 USDC to Alice',
|
|
3992
|
+
id: 'sent',
|
|
3993
|
+
title: 'Payment sent',
|
|
3994
|
+
type: 'positive',
|
|
3995
|
+
}}
|
|
3996
|
+
/>
|
|
3997
|
+
</div>
|
|
3998
|
+
</Toast.Provider>
|
|
3999
|
+
)
|
|
4000
|
+
}
|
|
4001
|
+
|
|
4002
|
+
namespace styles {
|
|
4003
|
+
// The item sits at the bottom of its containing block, as the viewport places it.
|
|
4004
|
+
export const frame = style({ height: '72', position: 'relative', width: '320' })
|
|
4005
|
+
}
|
|
4006
|
+
```
|
|
4007
|
+
|
|
4008
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Toast/Item.tsx)
|