Table
A table. Use plain <thead>, <tr>, <th>, <td> inside. Where its columns do not fit (a phone), each row becomes a block: the first cell is its title, the others sit under it with their column's name. With scroll it keeps its columns and scrolls sideways instead: for a table read down its columns (sorting, many figures).
Preview
| Customer | Status | Date | Amount |
|---|---|---|---|
| Noor Haddad | Paid | 12 Nov | £120.00 |
| Mira Kovac | Pending | 13 Nov | £80.00 |
| Otis Brandt | Failed | 14 Nov | £45.50 |
Use
import { Badge, Table } from '@/components/ui';
<div className="ui-grow">
<Table>
<thead>
<tr>
<th>Customer</th>
<th>Status</th>
<th>Date</th>
<th className="ui-num">Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>Noor Haddad</td>
<td><Badge tone="success" dot>Paid</Badge></td>
<td className="ui-mono">12 Nov</td>
<td className="ui-num">£120.00</td>
</tr>
<tr>
<td>Mira Kovac</td>
<td><Badge tone="warning">Pending</Badge></td>
<td className="ui-mono">13 Nov</td>
<td className="ui-num">£80.00</td>
</tr>
<tr>
<td>Otis Brandt</td>
<td><Badge tone="danger">Failed</Badge></td>
<td className="ui-mono">14 Nov</td>
<td className="ui-num">£45.50</td>
</tr>
</tbody>
</Table>
</div>Options
| Option | Type | What it does |
|---|---|---|
scroll | boolean | Keeps its columns where they do not fit and scrolls sideways, in place of turning rows into blocks. |
It also takes the 289 attributes of the element or UI SDK part it draws: className, aria-label, events and the rest.
Without React
The same look on any HTML, with the classes ui-table-wrap > ui-table.
With the CSS in parts (/ui/css/), it needs these, besides the ones every page loads:
components/card.csscomponents/table.csscomponents/input-group.csscomponents/table-sorting-chosen-rows.cssIn the examples
Small screens made with it and the rest of the kit. They work: click, type and choose in them.
This week, by product
| Linen tote | 18% | |
| Enamel mug | 9% | |
| Wall calendar | 44% | |
| Sticker sheet | 2% |
| Client | Due | Amount | Reminder |
|---|---|---|---|
| Northwind Joinery#0398 | 31 days late | €2,780.00 | |
| Kestrel Studio#0412 | 12 days late | €1,200.00 | |
| Lumen Bakery#0420 | In 3 days | €340.00 |
| Work | Qty | Price | Line |
|---|---|---|---|
| €900.00 | |||
| €240.00 |
- Subtotal
- €1,140.00
- VAT 21%
- €239.40
- Total
- €1,379.40
| Kestrel Studio | Website | €1,200.00 |
| Lumen Bakery | Menu design | €340.00 |
| Northwind Joinery | Signage | €2,780.00 |
Showing things: states, do and don’t
Data in rows. Plain <thead>, <tr>, <th>, <td> inside; className="ui-num" on number cells. Where its columns do not fit, each row becomes a block: the first cell is its title, every other cell a line with its column's name (a heading in ui-sr-only names none: such cells share one line). With scroll it keeps its columns and scrolls sideways instead.
States. Lists, tables and boards have three more states besides their content: empty (Empty, with the first action inside), loading (Skeleton) and failed (Alert tone="danger"). A chosen row shows in ink, never in the brand colour.
Do
- Put numbers, dates and codes in
ui-mono(in a table cell,ui-num, which also aligns them). - Let a
Tableturn into blocks on a phone; give itscrollonly when it is read down its columns. - Show a status in words and colour together (
Badge tone="success"with "Paid"), never colour alone.
Don't
- Don't put a card round a
Table,List,Cells,CalendarorEmpty: they draw their own box. - Don't truncate a name or a price to fit; let it wrap. Truncate only file names and addresses.
- Don't use the status colours (success, warning, danger, info) for anything but those meanings.