Skip to main content

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 responsive value 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​

PropTypeDefaultDescription
captionstring-Accessible caption describing the table purpose.
headersarray-Array of column header label strings.
rowsarray-Array of row arrays; each inner array contains cell value strings.
footer_rowarray-Optional footer row: array of cell value strings.
has_row_headersboolean-When true, renders the first cell of each body row as a <th scope="row">.
classesarray-Additional CSS class words merged into the root element.
attributesobject-Additional HTML attributes spread on the root element.

Classes​

ClassCapabilityDefaultDescription
.xsSize-Extra small.
.smSize-Small.
.mdSizeYesMedium.
.lgSize-Large.
.flushSpacing-No separation; the parts meet directly.
.stripedSurface-Surface pattern. striped applies alternating row backgrounds; striped-columns applies alternating column backgrounds; hover-rows highlights the row under the pointer.
.striped-columnsSurface-Surface pattern. striped applies alternating row backgrounds; striped-columns applies alternating column backgrounds; hover-rows highlights the row under the pointer.
.hover-rowsSurface-Surface pattern. striped applies alternating row backgrounds; striped-columns applies alternating column backgrounds; hover-rows highlights the row under the pointer.
.responsiveLayout-Wraps the table in a horizontally-scrollable container.
.caption-belowPosition-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.

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 responsive table stays keyboard reachable (the template reserves tabindex="0") and keeps its table semantics via an explicit role="table" while display: block makes it scroll
  • Sufficient color contrast between header and body cells
  • content - tables inside editorial content inherit base styles
  • deflist - alternative for key/value pairs