# Table

Supply UI 1.1.0. Showing things.

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

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).

## Options

| Option | Type | Default | 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 renders (`className`, `aria-label`, events…).

## Without React

Classes: `ui-table-wrap` > `ui-table`

## CSS parts

With the CSS in parts (`/ui/css/`), it needs: `components/card.css`, `components/table.css`, `components/input-group.css`, `components/table-sorting-chosen-rows.css`, besides the ones every page loads.

## In the examples

- Which ones sell: A line for each product, the change beside it (https://www.supply.family/ui/#scene-sellers)
- Who still owes: Nudge a client and the row remembers (https://www.supply.family/ui/#scene-owing)
- An invoice that adds up: Change a quantity or a price; the lines and VAT follow (https://www.supply.family/ui/#scene-invoice-lines)
- In, out, and what is left: Three numbers on top, the rows under two tabs (https://www.supply.family/ui/#scene-books)
- Who is on today: A name opens a card about the person (https://www.supply.family/ui/#scene-shifts)

## Showing things: notes

**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 `Table` turn into blocks on a phone; give it `scroll` only 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`, `Calendar` or `Empty`: 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.
