@tempoxyz/ds 0.3.14 → 0.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/docs/AGENTS.md +73 -10
  2. package/dist/docs/{marketing/introduction/getting-started.md → marketing.md} +28 -20
  3. package/dist/docs/product/components/actions.md +2058 -0
  4. package/dist/docs/product/components/blockchain.md +3825 -0
  5. package/dist/docs/product/components/data-display.md +5901 -0
  6. package/dist/docs/product/components/feedback-and-status.md +4008 -0
  7. package/dist/docs/product/components/forms-and-inputs.md +10543 -0
  8. package/dist/docs/product/components/layout.md +3339 -0
  9. package/dist/docs/product/components/navigation.md +2914 -0
  10. package/dist/docs/product/components/overlays.md +4917 -0
  11. package/dist/docs/product/components.md +125 -125
  12. package/dist/docs/product/foundations.md +4596 -0
  13. package/dist/docs/product/patterns.md +10129 -0
  14. package/package.json +1 -1
  15. package/dist/docs/index.md +0 -145
  16. package/dist/docs/product/components/accordion.md +0 -489
  17. package/dist/docs/product/components/address-card.md +0 -147
  18. package/dist/docs/product/components/agent-logo.md +0 -194
  19. package/dist/docs/product/components/alert-dialog.md +0 -631
  20. package/dist/docs/product/components/alert.md +0 -448
  21. package/dist/docs/product/components/amount-input.md +0 -305
  22. package/dist/docs/product/components/amount.md +0 -794
  23. package/dist/docs/product/components/app-shell.md +0 -559
  24. package/dist/docs/product/components/asset-chip.md +0 -294
  25. package/dist/docs/product/components/autocomplete.md +0 -620
  26. package/dist/docs/product/components/avatar.md +0 -321
  27. package/dist/docs/product/components/badge.md +0 -339
  28. package/dist/docs/product/components/badged-logo.md +0 -116
  29. package/dist/docs/product/components/banner.md +0 -379
  30. package/dist/docs/product/components/bar-chart.md +0 -208
  31. package/dist/docs/product/components/breadcrumbs.md +0 -380
  32. package/dist/docs/product/components/button-group.md +0 -286
  33. package/dist/docs/product/components/button.md +0 -650
  34. package/dist/docs/product/components/calendar.md +0 -375
  35. package/dist/docs/product/components/callout.md +0 -96
  36. package/dist/docs/product/components/checkbox-group.md +0 -521
  37. package/dist/docs/product/components/checkbox.md +0 -467
  38. package/dist/docs/product/components/choice-group.md +0 -516
  39. package/dist/docs/product/components/choicebox.md +0 -641
  40. package/dist/docs/product/components/code.md +0 -100
  41. package/dist/docs/product/components/combobox.md +0 -939
  42. package/dist/docs/product/components/container.md +0 -257
  43. package/dist/docs/product/components/copy-button.md +0 -642
  44. package/dist/docs/product/components/date-picker.md +0 -514
  45. package/dist/docs/product/components/dialog.md +0 -1332
  46. package/dist/docs/product/components/drawer.md +0 -966
  47. package/dist/docs/product/components/empty.md +0 -340
  48. package/dist/docs/product/components/field.md +0 -570
  49. package/dist/docs/product/components/fieldset.md +0 -398
  50. package/dist/docs/product/components/frame.md +0 -434
  51. package/dist/docs/product/components/gauge.md +0 -299
  52. package/dist/docs/product/components/get-started-visual.md +0 -117
  53. package/dist/docs/product/components/grid.md +0 -288
  54. package/dist/docs/product/components/hero-visual.md +0 -155
  55. package/dist/docs/product/components/hex.md +0 -487
  56. package/dist/docs/product/components/icon-tile.md +0 -292
  57. package/dist/docs/product/components/identicon.md +0 -371
  58. package/dist/docs/product/components/inline.md +0 -233
  59. package/dist/docs/product/components/inset.md +0 -225
  60. package/dist/docs/product/components/kbd.md +0 -423
  61. package/dist/docs/product/components/list-group.md +0 -981
  62. package/dist/docs/product/components/loading-dots.md +0 -237
  63. package/dist/docs/product/components/menu.md +0 -934
  64. package/dist/docs/product/components/native-select.md +0 -204
  65. package/dist/docs/product/components/network-logo.md +0 -248
  66. package/dist/docs/product/components/number-field.md +0 -543
  67. package/dist/docs/product/components/otp-field.md +0 -616
  68. package/dist/docs/product/components/pagination.md +0 -516
  69. package/dist/docs/product/components/popover.md +0 -544
  70. package/dist/docs/product/components/progress.md +0 -388
  71. package/dist/docs/product/components/qr.md +0 -314
  72. package/dist/docs/product/components/radio-group.md +0 -528
  73. package/dist/docs/product/components/secret-value.md +0 -406
  74. package/dist/docs/product/components/select.md +0 -751
  75. package/dist/docs/product/components/separator.md +0 -379
  76. package/dist/docs/product/components/sidebar-menu.md +0 -922
  77. package/dist/docs/product/components/skeleton.md +0 -517
  78. package/dist/docs/product/components/slider.md +0 -539
  79. package/dist/docs/product/components/snippet.md +0 -424
  80. package/dist/docs/product/components/spinner.md +0 -216
  81. package/dist/docs/product/components/split-bar.md +0 -139
  82. package/dist/docs/product/components/split-button.md +0 -464
  83. package/dist/docs/product/components/stack.md +0 -299
  84. package/dist/docs/product/components/status-chip.md +0 -226
  85. package/dist/docs/product/components/status-indicator.md +0 -119
  86. package/dist/docs/product/components/status-row.md +0 -174
  87. package/dist/docs/product/components/stepper.md +0 -451
  88. package/dist/docs/product/components/success-hero.md +0 -157
  89. package/dist/docs/product/components/surface.md +0 -639
  90. package/dist/docs/product/components/switch.md +0 -472
  91. package/dist/docs/product/components/table.md +0 -968
  92. package/dist/docs/product/components/tabs.md +0 -627
  93. package/dist/docs/product/components/tempo-logo.md +0 -185
  94. package/dist/docs/product/components/text-input.md +0 -624
  95. package/dist/docs/product/components/textarea.md +0 -352
  96. package/dist/docs/product/components/toast.md +0 -535
  97. package/dist/docs/product/components/token-logo.md +0 -371
  98. package/dist/docs/product/components/token.md +0 -247
  99. package/dist/docs/product/components/tooltip.md +0 -490
  100. package/dist/docs/product/components/verification-code.md +0 -116
  101. package/dist/docs/product/components/visual.md +0 -249
  102. package/dist/docs/product/foundations/accessibility.md +0 -377
  103. package/dist/docs/product/foundations/agents.md +0 -159
  104. package/dist/docs/product/foundations/color.md +0 -522
  105. package/dist/docs/product/foundations/content/tone.md +0 -194
  106. package/dist/docs/product/foundations/content/voice.md +0 -194
  107. package/dist/docs/product/foundations/content/writing-style.md +0 -406
  108. package/dist/docs/product/foundations/iconography.md +0 -282
  109. package/dist/docs/product/foundations/intent.md +0 -360
  110. package/dist/docs/product/foundations/layout.md +0 -508
  111. package/dist/docs/product/foundations/linter.md +0 -523
  112. package/dist/docs/product/foundations/motion.md +0 -151
  113. package/dist/docs/product/foundations/radius-and-padding.md +0 -86
  114. package/dist/docs/product/foundations/typography.md +0 -331
  115. package/dist/docs/product/introduction/faq.md +0 -133
  116. package/dist/docs/product/introduction/getting-started.md +0 -377
  117. package/dist/docs/product/patterns/blockchain-values.md +0 -709
  118. package/dist/docs/product/patterns/dashboards.md +0 -638
  119. package/dist/docs/product/patterns/destructive-actions.md +0 -626
  120. package/dist/docs/product/patterns/empty-states.md +0 -612
  121. package/dist/docs/product/patterns/errors-and-validation.md +0 -808
  122. package/dist/docs/product/patterns/feedback-and-status.md +0 -518
  123. package/dist/docs/product/patterns/forms.md +0 -679
  124. package/dist/docs/product/patterns/loading.md +0 -630
  125. package/dist/docs/product/patterns/navigation.md +0 -397
  126. package/dist/docs/product/patterns/payments.md +0 -765
  127. package/dist/docs/product/patterns/responsive-layout.md +0 -997
  128. package/dist/docs/product/patterns/tables-and-lists.md +0 -1170
  129. package/dist/docs/product/products/tempo-console.md +0 -671
  130. package/dist/docs/product/products/tempo-performance.md +0 -435
  131. package/dist/docs/product/products/tempo-wallet.md +0 -438
@@ -1,968 +0,0 @@
1
- # Table
2
-
3
- Displays tabular data in rows and columns.
4
-
5
- [View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Table.tsx)
6
-
7
- Figma: [Data/Table Card](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-3500) (`Table.Root`), [Data/Table Cell](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-3635) (`Table.Cell`), [Data/Table Empty](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-3723) (`Table.Cell`), [Data/Table Footer](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-3719) (`Table.Caption`), [Data/Table Header Cell](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-3681) (`Table.HeaderCell`), [Data/Table Lead Tile](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-3661) (`Table.LeadTile`), [Data/Table Row](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-3589) (`Table.Row`), [Dense Table](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=3506-2536) (`Table.Root`), [Simple Table](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=3506-2513) (`Table.Root`)
8
-
9
- ## Overview
10
-
11
- A table is a native `<table>` with styled parts. Use it for tabular data only, never for layout.
12
-
13
- ## Examples
14
-
15
- ### Basic
16
-
17
- ```tsx
18
- import { style, Surface, Table } from '@tempoxyz/ds'
19
-
20
- export const fill = true
21
- function Transactions(props: Table.Root.Props) {
22
- return (
23
- <Surface>
24
- <Table.Root {...props}>
25
- <Table.Head>
26
- <Table.Row>
27
- <Table.HeaderCell>ID</Table.HeaderCell>
28
- <Table.HeaderCell>Amount</Table.HeaderCell>
29
- <Table.HeaderCell>Status</Table.HeaderCell>
30
- </Table.Row>
31
- </Table.Head>
32
- <Table.Body>
33
- {(
34
- [
35
- ['0x4f2a…91c3', '$1,200.00', 'Confirmed', 'positive'],
36
- ['0x91bd…07e1', '$48.50', 'Confirmed', 'positive'],
37
- ['0xc3e0…5a22', '$310.00', 'Pending', 'warning'],
38
- ['0x77a1…c0d9', '$9.99', 'Failed', 'negative'],
39
- ] as const
40
- ).map(([id, amount, status, tone]) => (
41
- <Table.Row key={id}>
42
- <Table.Cell mono>{id}</Table.Cell>
43
- <Table.Cell numeric>{amount}</Table.Cell>
44
- <Table.Cell status={tone}>{status}</Table.Cell>
45
- </Table.Row>
46
- ))}
47
- </Table.Body>
48
- </Table.Root>
49
- </Surface>
50
- )
51
- }
52
-
53
- export function Demo() {
54
- return (
55
- <div {...styles.grid()}>
56
- <Transactions />
57
- </div>
58
- )
59
- }
60
-
61
- namespace styles {
62
- export const grid = style({
63
- backgroundColor: 'background.primary',
64
- display: 'grid',
65
- gap: '24',
66
- gridTemplateColumns: 'repeat(auto-fill, minmax(24rem, 1fr)) !custom',
67
- padding: '16',
68
- })
69
- }
70
- ```
71
-
72
- [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Table/Basic.tsx)
73
-
74
- ### Two Lines
75
-
76
- Set a second line in `Table.Subtitle`, lead the first cell with a `Table.LeadTile` or a [TokenLogo](token-logo.md), and set `muted` on a value that matters less, such as a zero amount.
77
-
78
- ```tsx
79
- import { Inline, StatusChip, style, Surface, Table } from '@tempoxyz/ds'
80
- import { ArrowDownLeft, ArrowUpRight, CreditCard } from '@tempoxyz/ds/icons'
81
-
82
- export const fill = true
83
- const activity = [
84
- {
85
- amount: '+$48.50',
86
- detail: '48.50 USDC',
87
- icon: <ArrowDownLeft />,
88
- status: ['Settled', 'positive'],
89
- time: 'Today, 09:41',
90
- title: 'Received from Bob',
91
- },
92
- {
93
- amount: '$120.00',
94
- detail: '120.00 USDC',
95
- icon: <ArrowUpRight />,
96
- status: ['Pending', 'warning'],
97
- time: 'Today, 08:12',
98
- title: 'Sent to Ada',
99
- },
100
- {
101
- amount: '$0.00',
102
- detail: 'Declined',
103
- icon: <CreditCard />,
104
- status: ['Failed', 'negative'],
105
- time: 'Yesterday, 18:30',
106
- title: 'Card payment',
107
- },
108
- ] as const
109
-
110
- export function Demo() {
111
- return (
112
- <div {...styles.grid()}>
113
- <Surface>
114
- <Table.Root size="large">
115
- <Table.Body>
116
- {activity.map((entry) => (
117
- <Table.Row key={entry.title}>
118
- <Table.Cell>
119
- <Inline gap="12">
120
- <Table.LeadTile>{entry.icon}</Table.LeadTile>
121
- <div>
122
- {entry.title}
123
- <Table.Subtitle>{entry.time}</Table.Subtitle>
124
- </div>
125
- </Inline>
126
- </Table.Cell>
127
- <Table.Cell>
128
- <StatusChip intent={entry.status[1]} size="small">
129
- {entry.status[0]}
130
- </StatusChip>
131
- </Table.Cell>
132
- <Table.Cell
133
- muted={entry.amount === '$0.00'}
134
- status={entry.amount.startsWith('+') ? 'positive' : undefined}
135
- >
136
- {entry.amount}
137
- <Table.Subtitle>{entry.detail}</Table.Subtitle>
138
- </Table.Cell>
139
- </Table.Row>
140
- ))}
141
- </Table.Body>
142
- </Table.Root>
143
- </Surface>
144
- </div>
145
- )
146
- }
147
-
148
- namespace styles {
149
- export const grid = style({
150
- backgroundColor: 'background.primary',
151
- display: 'grid',
152
- gap: '24',
153
- gridTemplateColumns: 'repeat(auto-fill, minmax(24rem, 1fr)) !custom',
154
- padding: '16',
155
- })
156
- }
157
- ```
158
-
159
- [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Table/TwoLines.tsx)
160
-
161
- ### Sortable Columns
162
-
163
- Put a `Table.SortButton` in a `Table.HeaderCell` and set `aria-sort` on the header cell. The chevron shows on hover and once the column is sorted.
164
-
165
- ```tsx
166
- import { style, Surface, Table } from '@tempoxyz/ds'
167
- import { useState } from 'react'
168
-
169
- export const fill = true
170
- const assets = [
171
- ['USDC', 3420.18],
172
- ['USDT0', 3150],
173
- ['pathUSD', 2424.24],
174
- ] as const
175
-
176
- const format = new Intl.NumberFormat('en-US', { currency: 'USD', style: 'currency' })
177
-
178
- type Sort = { column: 'asset' | 'balance'; order: 'ascending' | 'descending' }
179
-
180
- export function Demo() {
181
- const [sort, setSort] = useState<Sort>({ column: 'balance', order: 'descending' })
182
-
183
- const rows = [...assets].sort((a, b) => {
184
- const order = sort.order === 'ascending' ? 1 : -1
185
- if (sort.column === 'asset') return a[0].localeCompare(b[0]) * order
186
- return (a[1] - b[1]) * order
187
- })
188
- const toggle = (column: Sort['column']) =>
189
- setSort({
190
- column,
191
- order: sort.column === column && sort.order === 'descending' ? 'ascending' : 'descending',
192
- })
193
-
194
- return (
195
- <div {...styles.grid()}>
196
- <Surface>
197
- <Table.Root interactive>
198
- <Table.Head>
199
- <Table.Row>
200
- <Table.HeaderCell aria-sort={sort.column === 'asset' ? sort.order : 'none'}>
201
- <Table.SortButton onClick={() => toggle('asset')}>Asset</Table.SortButton>
202
- </Table.HeaderCell>
203
- <Table.HeaderCell aria-sort={sort.column === 'balance' ? sort.order : 'none'}>
204
- <Table.SortButton onClick={() => toggle('balance')}>Balance</Table.SortButton>
205
- </Table.HeaderCell>
206
- </Table.Row>
207
- </Table.Head>
208
- <Table.Body>
209
- {rows.map(([symbol, balance]) => (
210
- <Table.Row key={symbol}>
211
- <Table.Cell>{symbol}</Table.Cell>
212
- <Table.Cell>{format.format(balance)}</Table.Cell>
213
- </Table.Row>
214
- ))}
215
- </Table.Body>
216
- </Table.Root>
217
- </Surface>
218
- </div>
219
- )
220
- }
221
-
222
- namespace styles {
223
- export const grid = style({
224
- backgroundColor: 'background.primary',
225
- display: 'grid',
226
- gap: '24',
227
- gridTemplateColumns: 'repeat(auto-fill, minmax(24rem, 1fr)) !custom',
228
- padding: '16',
229
- })
230
- }
231
- ```
232
-
233
- [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Table/Sortable.tsx)
234
-
235
- ### Interactive
236
-
237
- Set `interactive` to fill a hovered row and outline a focus-visible one.
238
-
239
- ```tsx
240
- import { style, Surface, Table } from '@tempoxyz/ds'
241
-
242
- export const fill = true
243
- function Transactions(props: Table.Root.Props) {
244
- return (
245
- <Surface>
246
- <Table.Root {...props}>
247
- <Table.Head>
248
- <Table.Row>
249
- <Table.HeaderCell>ID</Table.HeaderCell>
250
- <Table.HeaderCell>Amount</Table.HeaderCell>
251
- <Table.HeaderCell>Status</Table.HeaderCell>
252
- </Table.Row>
253
- </Table.Head>
254
- <Table.Body>
255
- {(
256
- [
257
- ['0x4f2a…91c3', '$1,200.00', 'Confirmed', 'positive'],
258
- ['0x91bd…07e1', '$48.50', 'Confirmed', 'positive'],
259
- ['0xc3e0…5a22', '$310.00', 'Pending', 'warning'],
260
- ['0x77a1…c0d9', '$9.99', 'Failed', 'negative'],
261
- ] as const
262
- ).map(([id, amount, status, tone]) => (
263
- <Table.Row key={id} tabIndex={0}>
264
- <Table.Cell mono>{id}</Table.Cell>
265
- <Table.Cell numeric>{amount}</Table.Cell>
266
- <Table.Cell status={tone}>{status}</Table.Cell>
267
- </Table.Row>
268
- ))}
269
- </Table.Body>
270
- </Table.Root>
271
- </Surface>
272
- )
273
- }
274
-
275
- export function Demo() {
276
- return (
277
- <div {...styles.grid()}>
278
- <Transactions interactive />
279
- </div>
280
- )
281
- }
282
-
283
- namespace styles {
284
- export const grid = style({
285
- backgroundColor: 'background.primary',
286
- display: 'grid',
287
- gap: '24',
288
- gridTemplateColumns: 'repeat(auto-fill, minmax(24rem, 1fr)) !custom',
289
- padding: '16',
290
- })
291
- }
292
- ```
293
-
294
- [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Table/Interactive.tsx)
295
-
296
- ### Dividers
297
-
298
- Rows draw a divider inset by their padding, except the last row. Set `dividers={false}` to remove them.
299
-
300
- ```tsx
301
- import { style, Surface, Table } from '@tempoxyz/ds'
302
-
303
- export const fill = true
304
- function Transactions(props: Table.Root.Props) {
305
- return (
306
- <Surface>
307
- <Table.Root {...props}>
308
- <Table.Head>
309
- <Table.Row>
310
- <Table.HeaderCell>ID</Table.HeaderCell>
311
- <Table.HeaderCell>Amount</Table.HeaderCell>
312
- <Table.HeaderCell>Status</Table.HeaderCell>
313
- </Table.Row>
314
- </Table.Head>
315
- <Table.Body>
316
- {(
317
- [
318
- ['0x4f2a…91c3', '$1,200.00', 'Confirmed', 'positive'],
319
- ['0x91bd…07e1', '$48.50', 'Confirmed', 'positive'],
320
- ['0xc3e0…5a22', '$310.00', 'Pending', 'warning'],
321
- ['0x77a1…c0d9', '$9.99', 'Failed', 'negative'],
322
- ] as const
323
- ).map(([id, amount, status, tone]) => (
324
- <Table.Row key={id}>
325
- <Table.Cell mono>{id}</Table.Cell>
326
- <Table.Cell numeric>{amount}</Table.Cell>
327
- <Table.Cell status={tone}>{status}</Table.Cell>
328
- </Table.Row>
329
- ))}
330
- </Table.Body>
331
- </Table.Root>
332
- </Surface>
333
- )
334
- }
335
-
336
- export function Demo() {
337
- return (
338
- <div {...styles.grid()}>
339
- <Transactions dividers={false} />
340
- </div>
341
- )
342
- }
343
-
344
- namespace styles {
345
- export const grid = style({
346
- backgroundColor: 'background.primary',
347
- display: 'grid',
348
- gap: '24',
349
- gridTemplateColumns: 'repeat(auto-fill, minmax(24rem, 1fr)) !custom',
350
- padding: '16',
351
- })
352
- }
353
- ```
354
-
355
- [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Table/Dividers.tsx)
356
-
357
- ### Size
358
-
359
- Set `size` to `small`, `medium` (default), or `large`.
360
-
361
- ```tsx
362
- import { style, Surface, Table } from '@tempoxyz/ds'
363
-
364
- export const fill = true
365
- function Transactions(props: Table.Root.Props) {
366
- return (
367
- <Surface>
368
- <Table.Root {...props}>
369
- <Table.Head>
370
- <Table.Row>
371
- <Table.HeaderCell>ID</Table.HeaderCell>
372
- <Table.HeaderCell>Amount</Table.HeaderCell>
373
- <Table.HeaderCell>Status</Table.HeaderCell>
374
- </Table.Row>
375
- </Table.Head>
376
- <Table.Body>
377
- {(
378
- [
379
- ['0x4f2a…91c3', '$1,200.00', 'Confirmed', 'positive'],
380
- ['0x91bd…07e1', '$48.50', 'Confirmed', 'positive'],
381
- ['0xc3e0…5a22', '$310.00', 'Pending', 'warning'],
382
- ['0x77a1…c0d9', '$9.99', 'Failed', 'negative'],
383
- ] as const
384
- ).map(([id, amount, status, tone]) => (
385
- <Table.Row key={id}>
386
- <Table.Cell mono>{id}</Table.Cell>
387
- <Table.Cell numeric>{amount}</Table.Cell>
388
- <Table.Cell status={tone}>{status}</Table.Cell>
389
- </Table.Row>
390
- ))}
391
- </Table.Body>
392
- </Table.Root>
393
- </Surface>
394
- )
395
- }
396
-
397
- export function Demo() {
398
- return (
399
- <div {...styles.grid()}>
400
- <Transactions interactive size="small" />
401
- <Transactions size="large" />
402
- </div>
403
- )
404
- }
405
-
406
- namespace styles {
407
- export const grid = style({
408
- backgroundColor: 'background.primary',
409
- display: 'grid',
410
- gap: '24',
411
- gridTemplateColumns: 'repeat(auto-fill, minmax(24rem, 1fr)) !custom',
412
- padding: '16',
413
- })
414
- }
415
- ```
416
-
417
- [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Table/Size.tsx)
418
-
419
- ### Dense
420
-
421
- Set `variant="dense"` for a row of labels over rows of details, such as a comparison of plans. Columns share the width equally.
422
-
423
- ```tsx
424
- import { Table } from '@tempoxyz/ds'
425
-
426
- export const fill = true
427
- const plans = [
428
- ['Starter', '0.10%', 'T+1', 'Email', 'USDC'],
429
- ['Growth', '0.08%', 'Same day', 'Chat', 'USDC, USDT0'],
430
- ['Scale', 'Custom', 'Instant', 'Dedicated', 'Any stablecoin'],
431
- ] as const
432
-
433
- export function Demo() {
434
- return (
435
- <Table variant="dense">
436
- <Table.Head>
437
- <Table.Row>
438
- <Table.HeaderCell>Plan</Table.HeaderCell>
439
- <Table.HeaderCell>Fee</Table.HeaderCell>
440
- <Table.HeaderCell>Settlement</Table.HeaderCell>
441
- <Table.HeaderCell>Support</Table.HeaderCell>
442
- <Table.HeaderCell>Assets</Table.HeaderCell>
443
- </Table.Row>
444
- </Table.Head>
445
- <Table.Body>
446
- {plans.map((plan) => (
447
- <Table.Row key={plan[0]}>
448
- {plan.map((value) => (
449
- <Table.Cell key={value}>{value}</Table.Cell>
450
- ))}
451
- </Table.Row>
452
- ))}
453
- </Table.Body>
454
- </Table>
455
- )
456
- }
457
- ```
458
-
459
- [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Table/Dense.tsx)
460
-
461
- ### Simple
462
-
463
- Set `variant="simple"` for rows that each lead with a row header beside a paragraph. Set `scope="row"` on each `Table.HeaderCell`.
464
-
465
- ```tsx
466
- import { Table } from '@tempoxyz/ds'
467
-
468
- export const fill = true
469
- const uses = [
470
- [
471
- 'Global payouts and payroll',
472
- 'Platforms can pay merchants, contractors, or employees in stablecoins or local currency.',
473
- ],
474
- [
475
- 'Treasury management',
476
- 'Companies can hold balances in stablecoins and move them between entities in seconds.',
477
- ],
478
- [
479
- 'Cross-border settlement',
480
- 'Banks can settle with partners abroad without waiting on correspondent accounts.',
481
- ],
482
- ] as const
483
-
484
- export function Demo() {
485
- return (
486
- <Table variant="simple">
487
- <Table.Caption>Use cases</Table.Caption>
488
- <Table.Body>
489
- {uses.map(([title, description]) => (
490
- <Table.Row key={title}>
491
- <Table.HeaderCell scope="row">{title}</Table.HeaderCell>
492
- <Table.Cell>{description}</Table.Cell>
493
- </Table.Row>
494
- ))}
495
- </Table.Body>
496
- </Table>
497
- )
498
- }
499
- ```
500
-
501
- [View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Table/Simple.tsx)
502
-
503
- ## Anatomy
504
-
505
- Import the component and assemble its parts.
506
-
507
- ```tsx
508
- import { Table } from '@tempoxyz/ds'
509
-
510
- <Table>
511
- <Table.Caption />
512
- <Table.Head>
513
- <Table.Row>
514
- <Table.HeaderCell>
515
- <Table.SortButton />
516
- </Table.HeaderCell>
517
- </Table.Row>
518
- </Table.Head>
519
- <Table.Body>
520
- <Table.Row>
521
- <Table.Cell>
522
- <Table.LeadTile />
523
- <Table.Subtitle />
524
- </Table.Cell>
525
- </Table.Row>
526
- </Table.Body>
527
- </Table>
528
- <Table.Root />
529
- ```
530
-
531
- ## Guidelines
532
-
533
- ### When to Use
534
-
535
- * Compare many records with the same fields, such as wallet activity (date, recipient, amount, status) or benchmark runs (commit, TPS, latency).
536
- * Let people scan a column or find one row among many.
537
- * List API keys, webhooks, or team members.
538
- * Edit several records with the same fields in place, as [Edit Rows in Place](../patterns/tables-and-lists.md#edit-rows-in-place) describes.
539
-
540
- ### When Not to Use
541
-
542
- * Use [ListGroup](list-group.md) with `ListGroup.Label` for the fields of one record, such as a transaction's network, fee, and status.
543
- * Use [ListGroup](list-group.md) with `action="navigation"` for a short list of pages or settings to open.
544
- * Use [Grid](grid.md) or [Stack](stack.md) to arrange content.
545
- * Use a [Surface](surface.md) with a large [Amount](amount.md) for one headline number, such as a balance or the current TPS.
546
-
547
- ### Align Numbers to the End
548
-
549
- * **Figures:** Set `numeric` on number cells for tabular figures.
550
- * **Alignment:** Set `justify="end"` on those cells and on their `Table.HeaderCell`. The last column already aligns to the end, unless its cells set `justify="start"`.
551
- * **Decimals:** Keep one decimal count per column, such as `41.2` and `102.5`.
552
-
553
- **Do:** Set `numeric` and `justify="end"` on number columns and their headers.
554
-
555
- ```tsx
556
- /**
557
- * Do example for "Align Numbers to the End" on the Table page.
558
- * Set `numeric` and `justify="end"` on number columns and their headers.
559
- * @module
560
- */
561
- import { Table } from '@tempoxyz/ds'
562
-
563
- const runs = [
564
- ['4f2a91c', '12,480', '41.2'],
565
- ['91bd07e', '9,315', '38.7'],
566
- ['c3e05a2', '10,072', '102.5'],
567
- ] as const
568
-
569
- /** Renders the static preview, which the guideline card shows inert. */
570
- export function Demo() {
571
- return (
572
- <Table size="small">
573
- <Table.Head>
574
- <Table.Row>
575
- <Table.HeaderCell>Commit</Table.HeaderCell>
576
- <Table.HeaderCell justify="end">TPS</Table.HeaderCell>
577
- <Table.HeaderCell>p99 (ms)</Table.HeaderCell>
578
- </Table.Row>
579
- </Table.Head>
580
- <Table.Body>
581
- {runs.map(([commit, tps, latency]) => (
582
- <Table.Row key={commit}>
583
- <Table.Cell mono>{commit}</Table.Cell>
584
- <Table.Cell justify="end" numeric>
585
- {tps}
586
- </Table.Cell>
587
- <Table.Cell numeric>{latency}</Table.Cell>
588
- </Table.Row>
589
- ))}
590
- </Table.Body>
591
- </Table>
592
- )
593
- }
594
- ```
595
-
596
- **Don't:** Start-align numbers or leave them in proportional figures.
597
-
598
- ```tsx
599
- /**
600
- * Don't example for "Align Numbers to the End" on the Table page.
601
- * Don't start-align numbers or leave them in proportional figures.
602
- * @module
603
- */
604
- import { Table } from '@tempoxyz/ds'
605
-
606
- const runs = [
607
- ['4f2a91c', '12,480', '41.2'],
608
- ['91bd07e', '9,315', '38.7'],
609
- ['c3e05a2', '10,072', '102.5'],
610
- ] as const
611
-
612
- /** Renders the static preview, which the guideline card shows inert. */
613
- export function Demo() {
614
- return (
615
- <Table size="small">
616
- <Table.Head>
617
- <Table.Row>
618
- <Table.HeaderCell>Commit</Table.HeaderCell>
619
- <Table.HeaderCell>TPS</Table.HeaderCell>
620
- <Table.HeaderCell>p99 (ms)</Table.HeaderCell>
621
- </Table.Row>
622
- </Table.Head>
623
- <Table.Body>
624
- {runs.map(([commit, tps, latency]) => (
625
- <Table.Row key={commit}>
626
- <Table.Cell>{commit}</Table.Cell>
627
- <Table.Cell>{tps}</Table.Cell>
628
- <Table.Cell>{latency}</Table.Cell>
629
- </Table.Row>
630
- ))}
631
- </Table.Body>
632
- </Table>
633
- )
634
- }
635
- ```
636
-
637
- An [Amount](amount.md) in a cell renders as a block and sets its own alignment. Give it `align="right"` in an end-aligned column.
638
-
639
- ### Truncate Hashes in the Middle
640
-
641
- Set `mono` on cells with hashes, addresses, and commit IDs, and shorten them with `formatHex`. Link the row to a details view that shows the full value in a [Hex](hex.md) with `copy`.
642
-
643
- **Do:** Keep the `0x` prefix and four characters on each side, such as `0x4f2a…91c3`.
644
-
645
- ```tsx
646
- /**
647
- * Do example for "Truncate Hashes in the Middle" on the Table page.
648
- * Keep the `0x` prefix and four characters on each side, such as `0x4f2a…91c3`.
649
- * @module
650
- */
651
- import { formatHex, Table } from '@tempoxyz/ds'
652
-
653
- const transfers = [
654
- ['0x4f2a8c1e9b7d3a6f5e2c0b8d7a1f4e6c9b3d2a5f8e7c6b1d0a9f3e2c4b5091c3', '25.00'],
655
- ['0x91bd07e3a5c8f2d6b4e1a9c7f3d5b2e8a6c4f1d9b7e3a5c2f8d6b4e1a9c70e17', '120.00'],
656
- ] as const
657
-
658
- /** Renders the static preview, which the guideline card shows inert. */
659
- export function Demo() {
660
- return (
661
- <Table size="small">
662
- <Table.Head>
663
- <Table.Row>
664
- <Table.HeaderCell>Transaction</Table.HeaderCell>
665
- <Table.HeaderCell>Amount</Table.HeaderCell>
666
- </Table.Row>
667
- </Table.Head>
668
- <Table.Body>
669
- {transfers.map(([hash, amount]) => (
670
- <Table.Row key={hash}>
671
- <Table.Cell mono>{formatHex(hash)}</Table.Cell>
672
- <Table.Cell numeric>{amount}</Table.Cell>
673
- </Table.Row>
674
- ))}
675
- </Table.Body>
676
- </Table>
677
- )
678
- }
679
- ```
680
-
681
- **Don't:** Show full hashes, which crowd out the other columns.
682
-
683
- ```tsx
684
- /**
685
- * Don't example for "Truncate Hashes in the Middle" on the Table page.
686
- * Don't show full hashes, which crowd out the other columns.
687
- * @module
688
- */
689
- import { Table } from '@tempoxyz/ds'
690
-
691
- const transfers = [
692
- ['0x4f2a8c1e9b7d3a6f5e2c0b8d7a1f4e6c9b3d2a5f8e7c6b1d0a9f3e2c4b5091c3', '25.00'],
693
- ['0x91bd07e3a5c8f2d6b4e1a9c7f3d5b2e8a6c4f1d9b7e3a5c2f8d6b4e1a9c70e17', '120.00'],
694
- ] as const
695
-
696
- /** Renders the static preview, which the guideline card shows inert. */
697
- export function Demo() {
698
- return (
699
- <Table size="small">
700
- <Table.Head>
701
- <Table.Row>
702
- <Table.HeaderCell>Transaction</Table.HeaderCell>
703
- <Table.HeaderCell>Amount</Table.HeaderCell>
704
- </Table.Row>
705
- </Table.Head>
706
- <Table.Body>
707
- {transfers.map(([hash, amount]) => (
708
- <Table.Row key={hash}>
709
- <Table.Cell mono>{hash}</Table.Cell>
710
- <Table.Cell numeric>{amount}</Table.Cell>
711
- </Table.Row>
712
- ))}
713
- </Table.Body>
714
- </Table>
715
- )
716
- }
717
- ```
718
-
719
- ### Pair Status Color With Words
720
-
721
- `status` colors a cell's text `positive`, `negative`, or `warning`. If the status needs more weight, use a [Badge](badge.md) in the cell.
722
-
723
- **Do:** Keep a word with each color, such as Failed.
724
-
725
- ```tsx
726
- /**
727
- * Do example for "Pair Status Color With Words" on the Table page.
728
- * Keep a word with each color, such as Failed.
729
- * @module
730
- */
731
- import { Table } from '@tempoxyz/ds'
732
-
733
- /** Renders the static preview, which the guideline card shows inert. */
734
- export function Demo() {
735
- return (
736
- <Table size="small">
737
- <Table.Head>
738
- <Table.Row>
739
- <Table.HeaderCell>Recipient</Table.HeaderCell>
740
- <Table.HeaderCell>Status</Table.HeaderCell>
741
- </Table.Row>
742
- </Table.Head>
743
- <Table.Body>
744
- <Table.Row>
745
- <Table.Cell>Alice</Table.Cell>
746
- <Table.Cell status="positive">Confirmed</Table.Cell>
747
- </Table.Row>
748
- <Table.Row>
749
- <Table.Cell>Bob</Table.Cell>
750
- <Table.Cell status="warning">Pending</Table.Cell>
751
- </Table.Row>
752
- <Table.Row>
753
- <Table.Cell>Carol</Table.Cell>
754
- <Table.Cell status="negative">Failed</Table.Cell>
755
- </Table.Row>
756
- </Table.Body>
757
- </Table>
758
- )
759
- }
760
- ```
761
-
762
- **Don't:** Show status by color alone.
763
-
764
- ```tsx
765
- /** Don't example for "Pair Status Color With Words" on the Table page. Don't show status by color alone. @module */
766
- import { Table } from '@tempoxyz/ds'
767
-
768
- /** Renders the static preview, which the guideline card shows inert. */
769
- export function Demo() {
770
- return (
771
- <Table size="small">
772
- <Table.Head>
773
- <Table.Row>
774
- <Table.HeaderCell>Recipient</Table.HeaderCell>
775
- <Table.HeaderCell>Status</Table.HeaderCell>
776
- </Table.Row>
777
- </Table.Head>
778
- <Table.Body>
779
- <Table.Row>
780
- <Table.Cell>Alice</Table.Cell>
781
- <Table.Cell status="positive">●</Table.Cell>
782
- </Table.Row>
783
- <Table.Row>
784
- <Table.Cell>Bob</Table.Cell>
785
- <Table.Cell status="warning">●</Table.Cell>
786
- </Table.Row>
787
- <Table.Row>
788
- <Table.Cell>Carol</Table.Cell>
789
- <Table.Cell status="negative">●</Table.Cell>
790
- </Table.Row>
791
- </Table.Body>
792
- </Table>
793
- )
794
- }
795
- ```
796
-
797
- ### Make Clickable Rows Reachable by Keyboard
798
-
799
- `interactive` adds styles only, with no click or key handling. If the whole row also responds to a click, keep other buttons out of it.
800
-
801
- **Do:** Put a link to the record in the first cell.
802
-
803
- ```tsx
804
- /**
805
- * Do example for "Make Clickable Rows Reachable by Keyboard" on the Table page.
806
- * Put a link to the record in the first cell.
807
- * @module
808
- */
809
- import { style, Table } from '@tempoxyz/ds'
810
-
811
- const transfers = [
812
- ['0x4f2a…91c3', '25.00'],
813
- ['0x91bd…07e1', '120.00'],
814
- ['0xc3e0…5a22', '8.50'],
815
- ] as const
816
-
817
- /** Renders the static preview, which the guideline card shows inert. */
818
- export function Demo() {
819
- return (
820
- <Table interactive size="small">
821
- <Table.Head>
822
- <Table.Row>
823
- <Table.HeaderCell>Transaction</Table.HeaderCell>
824
- <Table.HeaderCell>Amount</Table.HeaderCell>
825
- </Table.Row>
826
- </Table.Head>
827
- <Table.Body>
828
- {transfers.map(([hash, amount]) => (
829
- <Table.Row key={hash}>
830
- <Table.Cell mono>
831
- <a href="#" {...styles.link()}>
832
- {hash}
833
- </a>
834
- </Table.Cell>
835
- <Table.Cell numeric>{amount}</Table.Cell>
836
- </Table.Row>
837
- ))}
838
- </Table.Body>
839
- </Table>
840
- )
841
- }
842
-
843
- namespace styles {
844
- export const link = style({
845
- color: 'content.primary',
846
- textDecorationLine: 'underline !custom',
847
- textUnderlineOffset: '4px !custom',
848
- })
849
- }
850
- ```
851
-
852
- **Don't:** Rely on a row click handler that the keyboard can't reach.
853
-
854
- ```tsx
855
- /**
856
- * Don't example for "Make Clickable Rows Reachable by Keyboard" on the Table page.
857
- * Don't rely on a row click handler that the keyboard can't reach.
858
- * @module
859
- */
860
- import { Table } from '@tempoxyz/ds'
861
-
862
- const transfers = [
863
- ['0x4f2a…91c3', '25.00'],
864
- ['0x91bd…07e1', '120.00'],
865
- ['0xc3e0…5a22', '8.50'],
866
- ] as const
867
-
868
- /** Renders the static preview, which the guideline card shows inert. */
869
- export function Demo() {
870
- return (
871
- <Table interactive size="small">
872
- <Table.Head>
873
- <Table.Row>
874
- <Table.HeaderCell>Transaction</Table.HeaderCell>
875
- <Table.HeaderCell>Amount</Table.HeaderCell>
876
- </Table.Row>
877
- </Table.Head>
878
- <Table.Body>
879
- {transfers.map(([hash, amount]) => (
880
- <Table.Row key={hash} onClick={() => {}}>
881
- <Table.Cell mono>{hash}</Table.Cell>
882
- <Table.Cell numeric>{amount}</Table.Cell>
883
- </Table.Row>
884
- ))}
885
- </Table.Body>
886
- </Table>
887
- )
888
- }
889
- ```
890
-
891
- ### Keep Long Tables Readable
892
-
893
- * **Sticky headers:** Set `sticky` on `Table.Head`, and place the table in a scrolling container with a fixed height.
894
- * **Long histories:** Split them with [Pagination](pagination.md).
895
-
896
- ### Match Density to the Data
897
-
898
- * **Small (32px):** Dense dashboards, such as benchmark results.
899
- * **Medium (40px):** The default.
900
- * **Large (56px):** Avatars or token icons beside two lines of text.
901
-
902
- ## Content
903
-
904
- * Write column headers as short nouns, such as Recipient, Amount, and Block time.
905
- * Put the unit of a metric in the header, such as `p99 (ms)`. Keep the currency or token on each amount, since one table can mix assets.
906
- * Use one date format per column. Use relative times, such as 5 min ago, only for recent activity, and show the full date in the details view.
907
- * Fill empty cells with one value, such as None or 0, so a blank cell doesn't read as a loading error.
908
-
909
- ## Accessibility
910
-
911
- A table renders native table elements, so screen readers announce rows, columns, and headers. It follows the [WAI-ARIA table pattern](https://www.w3.org/WAI/ARIA/apg/patterns/table/).
912
-
913
- ### Semantics
914
-
915
- * **Table.Root (table):** Uses native table elements for every part, from the root to each cell.
916
- * **Table.HeaderCell (th):** Column headers. If a body row's first cell names the record, such as a commit ID, make it a row header.
917
- * **Appearance Props (numeric, mono, muted, status):** These and `interactive` change styles only. Status colors aren't announced.
918
- * **Table.SortButton (button):** A native button in the header cell. The header cell announces its `aria-sort` order.
919
-
920
- ### Keyboard
921
-
922
- A table has no keys of its own. Screen reader users move through cells with table commands.
923
-
924
- For a sort button, and for a row you make focusable with `tabIndex={0}` in an `interactive` table:
925
-
926
- * **Sort the Column (Enter or Space):** Runs the `onClick` of the focused sort button.
927
- * **Move Focus to the Row (Tab):** Moves focus to the row.
928
-
929
- ### Focus
930
-
931
- With `interactive`, a focused body row shows an outline inside its edges. A focused sort button shows an outline around the label of its header cell. The table adds no other tab stops.
932
-
933
- ### Your Responsibilities
934
-
935
- * **Name Every Table (Table.Caption):** Caption it, or use `aria-labelledby` for a visible heading. The caption renders below the rows.
936
- * **Update the Sort Order (aria-sort):** Sort the rows in `onClick`, and set `aria-sort` on the sorted header cell and `none` on the rest.
937
- * **Mark Headers (scope):** Mark every column header, and the cell that identifies each row.
938
- * **Reflow Wide Tables (SC 1.4.10):** Put a wide table in a focusable [scrolling container](https://www.w3.org/WAI/WCAG22/Understanding/reflow.html) with an `aria-label`.
939
-
940
- ## Related
941
-
942
- [ListGroup](list-group.md)
943
-
944
- Use for the details of one record.
945
-
946
- [Amount](amount.md)
947
-
948
- Use for money and token amounts in cells.
949
-
950
- [Hex](hex.md)
951
-
952
- Use for addresses and hashes.
953
-
954
- [Badge](badge.md)
955
-
956
- Use for statuses.
957
-
958
- [Pagination](pagination.md)
959
-
960
- Use for long histories.
961
-
962
- [Tables and Lists](../patterns/tables-and-lists.md)
963
-
964
- Covers choosing a layout.
965
-
966
- [Dashboards](../patterns/dashboards.md)
967
-
968
- Covers benchmark and metric views.