Tables and Data Specialist reference: Responsive Tables
In the kit: .github/skills/tables-data-specialist/references/responsive-tables.md.
-
This file as plain text, at
https://letitglow.app/ahg/kit/raw/.github/skills/tables-data-specialist/references/responsive-tables.md - Everything in the kit
Copy it into ChatGPT or another assistant
Read the plain text first
Tables and Data Specialist reference: Responsive Tables
Part of the tables-data-specialist skill. Read this only when the task reaches these sections.
Responsive Tables
Approach 1: Horizontal Scroll
<div role="region" aria-label="User accounts" tabindex="0">
<table>
<!-- full table -->
</table>
</div>- Wrap in a
<div>withrole="region"andaria-label - Add
tabindex="0"so keyboard users can scroll - Add
overflow-x: autoon the wrapper - Visual scroll indicator so users know there's more content
Approach 2: Stacked Cards on Mobile
@media (max-width: 768px) {
table, thead, tbody, th, td, tr {
display: block;
}
thead { display: none; } /* Hide visual headers */
td::before {
content: attr(data-label); /* Show header as label */
font-weight: bold;
}
}<td data-label="Name">Jane Smith</td>
<td data-label="Email">jane@example.com</td>Requirements for stacked pattern:
- Each cell must have its header visible (via
data-labelor other technique) thead { display: none; }hides the headers from screen readers too. Hide them visually with a visually-hidden class instead if screen readers should keep them- Changing
displayon table elements can drop their table semantics in some browsers; restore them with explicit roles (role="table",rowgroup,row,columnheader,cell) and test with a screen reader - Row boundaries must be clear (borders, spacing, or visual grouping)
Approach 3: Priority Columns
Show only essential columns on mobile, with a "View details" button per row:
<tr>
<td>Jane Smith</td>
<td class="hide-mobile">jane@example.com</td>
<td class="hide-mobile">Admin</td>
<td>
<button aria-label="View details for Jane Smith">Details</button>
</td>
</tr>Hide columns with display: none, which also removes them for assistive technology. Never use aria-hidden alone: the content stays visible and focusable.