Table
Data table with header, rows, striping, and responsive scroll. Used for tabular data where rows and columns carry meaning - mission logs, specification tables, schedules, or any grid of related values. Styled via the <table> element with an opt-in .table mirror class, plus values for striping, hover, borders, smaller cell padding, and caption position.
Usage
When to use
- Presenting structured data with a clear row/column relationship
- Comparing values across multiple attributes
- Long lists of records where scanning by column matters
When not to use
- Pure layout - use grid or flex utilities instead
- A small list of items - use a description list or unordered list
- Key/value pairs - use a description list
Do
- Provide a
<caption>describing the table's purpose - Use
<th scope="col">and<th scope="row">to clarify headers - Add the
responsivevalue to wide tables so they scroll horizontally at any viewport (below 40rem every table scrolls automatically)
Don't
- Use tables for page layout
- Omit the caption on data tables
- Rely on color alone to convey row meaning
API
Props
| Prop | Type | Default | Description |
|---|---|---|---|
caption | string | - | Accessible caption describing the table purpose. |
headers | array | - | Array of column header label strings. |
rows | array | - | Array of row arrays; each inner array contains cell value strings. |
footer_row | array | - | Optional footer row: array of cell value strings. |
has_row_headers | boolean | - | When true, renders the first cell of each body row as a <th scope="row">. |
classes | array | - | Additional CSS class words merged into the root element. |
attributes | object | - | Additional HTML attributes spread on the root element. |
Classes
| Class | Capability | Default | Description |
|---|---|---|---|
.xs | Size | - | Extra small. |
.sm | Size | - | Small. |
.md | Size | Yes | Medium. |
.lg | Size | - | Large. |
.flush | Spacing | - | No separation; the parts meet directly. |
.striped | Surface | - | Surface pattern. striped applies alternating row backgrounds; striped-columns applies alternating column backgrounds; hover-rows highlights the row under the pointer. |
.striped-columns | Surface | - | Surface pattern. striped applies alternating row backgrounds; striped-columns applies alternating column backgrounds; hover-rows highlights the row under the pointer. |
.hover-rows | Surface | - | Surface pattern. striped applies alternating row backgrounds; striped-columns applies alternating column backgrounds; hover-rows highlights the row under the pointer. |
.responsive | Layout | - | Wraps the table in a horizontally-scrollable container. |
.caption-below | Position | - | Renders the caption below the table instead of above. |
Examples
Default table
Plain <table> with header row and data rows.
Striped rows
Alternating row backgrounds for readability on long tables.
Striped columns
Alternating column backgrounds.
Small
Reduced padding for high-density tables.
Row headers
<th scope="row"> for tables where the first column labels rows.
Footer
Summary row or totals in a <tfoot>.
Caption at bottom
Caption positioned below the table.
Responsive
The responsive value turns the table itself into a horizontally scrolling block at all viewports.
Hover rows
The hover-rows surface value, which tints the row under the cursor so the eye can track across a wide table.
Flush
The flush spacing value, which drops the outer border and the edge padding so the table sits level with the text around it.
Accessibility
- WCAG 2.2 AA
<th scope="col">for column headers<th scope="row">for row headers<caption>describes the table purpose- A
responsivetable stays keyboard reachable (the template reservestabindex="0") and keeps its table semantics via an explicitrole="table"whiledisplay: blockmakes it scroll - Sufficient color contrast between header and body cells