Table
Rows of the same kind of thing, compared column by column.
{/* Generated by scripts/build-component-docs.mjs — do not edit. The source is the component folder: guidance.json, the doc block and the props. Change those. */}
Rows of the same kind of thing, compared column by column.
Import
import { Table, TableColGroup, TableCol, TableHeader, TableBody, TableFooter, TableRow, TableHead, TableCell, TableCaption } from "@ir/ui";Watch out
- Figma models the table as COLUMNS; this models it as rows. In the file a table is built by placing
Table columncomponents side by side, each holding its own header and ten row slots, with a separateTable row highlightlaid over the top to draw hover and selection across them. That is a sound way to author a table in Figma — it keeps a column's type consistent down its length — but it has no equivalent in HTML. - The card, toolbar and pagination bar around the table in Figma are NOT part of this component. That surface is a Card — same radius, same border, same fill — so it composes rather than being rebuilt here. The stories show it.
Props
Table
| Prop | Type | Required | What it does |
|---|---|---|---|
size | Size | Figma's Size: md rows are 60 tall, sm rows 52. Headers are 40 in both. |
TableRow
| Prop | Type | Required | What it does |
|---|---|---|---|
selected | boolean | Draws the selected fill and sets aria-selected. |
Do and don't
Use a table when the reader needs to compare the same field across rows.
Don't — Use a table to lay out a form or a set of cards.
A table earns its density by making columns scannable. Used as a layout grid it inherits all the cost — the semantics, the scrolling, the alignment — and returns none of it.
Use the Title + supporting cell to stack a second line inside one row.
Don't — Split one record across two rows to fit more fields.
Every row is one record, for a reader and for a screen reader. A record that spans two rows breaks selection, sorting and counting at once.
Right-align numbers and set them in mono.
Don't — Left-align numeric columns.
Digits only line up by place value when they are right-aligned in a fixed-width face. Left-aligned figures cannot be compared down a column, which is the only reason they are in one.
Head the column "MOS" and put the rest in a caption or a tooltip.
Don't — Write "MOS (calculated hourly, 0–5)" in the column header.
The header repeats in assistive technology on every cell in the column. A sentence there is read dozens of times.
Set the selected state on the row, so it reads and looks selected.
Don't — Track selection on the checkbox and leave the row unmarked.
The thing being selected is the record, not the tick. A screen reader that hears "checked" without "selected" has to infer the connection.
Say what would be here and how to get it — or that a filter is hiding it.
Don't — Render a header with nothing under it.
An empty table looks identical whether there is no data, no match, or a failed request, and the reader cannot tell which.
Use sm when a table is a supporting panel, and md when it is the page.
Don't — Reach for sm to squeeze in another column.
Shrinking the row height does not create horizontal room. If columns do not fit, the answer is fewer columns or a scroll, not tighter rows.
Accessibility
- aria-selected belongs on the row, not on the checkbox inside it. The checkbox says what it does; the row says what it is.
- Selection is a fill plus aria-selected, never the fill alone.
Where it is drawn
Figma — structure from code, measurements from figma.