A responsive data table that changes layout on small screens: each row becomes a card, and every value gets its column name as a label. It is pure CSS with no JavaScript, and it suits invoices, orders, user lists and other admin tables that need to stay readable on phones without horizontal scrolling.
How it works
The .st-card wrapper is a size container (container-type: inline-size, named st), so the table reacts to the width of its card instead of the viewport. That means it also stacks inside a narrow sidebar or dashboard column on a large screen.
The default styles are the mobile layout. The .st-table, its tbody, rows and cells are set to block or flex display. The thead is hidden visually but kept for screen readers. Each td has a data-label attribute, and td::before prints it with content: attr(data-label), so a cell reads as "AMOUNT ... $4,250.00". Rows get a rounded border and a colored left edge, and cells are separated by dashed lines.
When the card is at least 44rem wide, the @container st (min-width: 44rem) block switches everything back to table, table-row-group, table-row and table-cell, shows the header row and removes the generated labels. Numeric columns use .st-num for right alignment and tabular figures.
Customization
data-labelon eachtd: the label shown on mobile. Keep it in sync with the matchingthtext.44remin the@containerrule: the width at which the table layout returns. Raise it for tables with more columns.--st-accenton.st-wrap: the color of the row edge on mobile, the links and the focus outline.--st-label-width: the width of the label column in the stacked cards..st-pill--paid,.st-pill--pending,.st-pill--overdueand.st-pill--draft: status badge colors. Add a new modifier for other states..st-avatar--1to.st-avatar--4: background and text colors of the client initials.
Use cases
- Billing pages: invoice rows become labeled cards on narrow screens
- Admin dashboards: data stays readable on phones without horizontal scrolling
- Customer portals: data-label attributes name every value in the stacked layout
- Reports: a container query switches layouts based on the available width
Accessibility
Changing display on table elements can remove table semantics in some browsers, so the markup sets them explicitly with role="table", rowgroup, row, columnheader and cell. The table is labelled by its heading through aria-labelledby. Each View link includes hidden text such as "invoice 2041" so it is unique out of context, and links get a visible focus outline. Status colors also carry a text label, so color is never the only signal.
Usage notes
Container queries are supported in all current browsers. In very old browsers the table stays in its stacked card layout, which still works at any width.