Table
Semantic HTML table. Wrap it in TableRoot so wide grids scroll instead of breaking the page.
Basic
TableRoot is the overflow wrapper. Table is the table element. Header cells are TableHead, body cells are TableCell.
| Host | Region | Requests |
|---|---|---|
| iad.proxy | IAD | 12.4k |
| fra.proxy | FRA | 8.1k |
| sin.proxy | SIN | 3.6k |
1
<TableRoot>
2
<Table>
3
<TableHeader>
4
<TableRow>
5
<TableHead>Host</TableHead>
6
<TableHead>Region</TableHead>
7
<TableHead>Requests</TableHead>
8
</TableRow>
9
</TableHeader>
10
<TableBody>
11
<TableRow>
12
<TableCell>iad.proxy</TableCell>
13
<TableCell>IAD</TableCell>
14
<TableCell>12.4k</TableCell>
15
</TableRow>
16
</TableBody>
17
</Table>
18
</TableRoot>
Striped
striped on TableBody tints even rows with --ds-gray-100.
Bordered
bordered draws a hairline on every cell. Use it when columns must line up for comparison.
Interactive
interactive adds a hover wash and a pointer. You still own click and the selected row.
Full featured
TableColgroup sets column widths. TableFooter sits under the body for a subtotal.
| Product | Usage | Price | Charge |
|---|---|---|---|
| Residential 1 GB | 840 MB | $4.20 / GB | $35 |
| Datacenter 5 GB | 5.0 GB | $1.10 / GB | $55 |
| Mobile 500 MB | 120 MB | $8.00 / GB | $10 |
| ISP 2 GB | 1.4 GB | $3.40 / GB | $48 |
| Sticky session | 48 h | $0.12 / h | $6 |
| Subtotal | $153 | ||
1
<Table>
2
<TableColgroup>
3
<TableCol class="w-[44%]" />
4
<TableCol class="w-[22%]" />
5
<TableCol class="w-[22%]" />
6
<TableCol class="w-[12%]" />
7
</TableColgroup>
8
<TableHeader>…</TableHeader>
9
<TableBody interactive striped>…</TableBody>
10
<TableFooter>
11
<TableRow>
12
<TableCell :col-span="3">Subtotal</TableCell>
13
<TableCell>$15,326</TableCell>
14
</TableRow>
15
</TableFooter>
16
</Table>
Virtualized
virtualize on TableBody pins the header and caps the root at 420px. This port scrolls the body; it does not window individual rows.
| Product | Usage | Price |
|---|---|---|
| Residential 1 GB | 840 MB | $4.20 / GB |
| Datacenter 5 GB | 5.0 GB | $1.10 / GB |
| Mobile 500 MB | 120 MB | $8.00 / GB |
| Residential 1 GB | 840 MB | $4.20 / GB |
| Datacenter 5 GB | 5.0 GB | $1.10 / GB |
| Mobile 500 MB | 120 MB | $8.00 / GB |
| Residential 1 GB | 840 MB | $4.20 / GB |
| Datacenter 5 GB | 5.0 GB | $1.10 / GB |
| Mobile 500 MB | 120 MB | $8.00 / GB |
| Residential 1 GB | 840 MB | $4.20 / GB |
| Datacenter 5 GB | 5.0 GB | $1.10 / GB |
| Mobile 500 MB | 120 MB | $8.00 / GB |
| Residential 1 GB | 840 MB | $4.20 / GB |
| Datacenter 5 GB | 5.0 GB | $1.10 / GB |
| Mobile 500 MB | 120 MB | $8.00 / GB |
| Residential 1 GB | 840 MB | $4.20 / GB |
| Datacenter 5 GB | 5.0 GB | $1.10 / GB |
| Mobile 500 MB | 120 MB | $8.00 / GB |
| Residential 1 GB | 840 MB | $4.20 / GB |
| Datacenter 5 GB | 5.0 GB | $1.10 / GB |
| Mobile 500 MB | 120 MB | $8.00 / GB |
| Residential 1 GB | 840 MB | $4.20 / GB |
| Datacenter 5 GB | 5.0 GB | $1.10 / GB |
| Mobile 500 MB | 120 MB | $8.00 / GB |
Best practices
- Use a table when every row shares a shape and at least one column is comparable. A membership row with one action is an entity list, not a table. Key/value metadata is a description list.
- Wrap the grid in
TableRoot. The table element itself should stayTable. - Empty lists render an Empty State outside the table, not a blank
TableBody. - Unknown cells are an em dash. Do not write
N/A,null, or leave the cell empty. - Headers are Title Case nouns:
Last Used,Requests (7d). Never a sentence. - Numeric columns get
tabular-numsso digits line up. interactiveis a hover affordance. Wire selection and keyboard yourself.