Most dashboard tables fail in the first ten seconds, and not because of the styling. Someone scrolls sideways, the order IDs vanish, and now they're staring at a column of numbers with no idea whose they are. Or they sort by revenue and the digits jiggle left and right like a bad slot machine.
This guide covers the table patterns that decide whether a dashboard is usable: alignment, pinned headers, sorting, selection, loading and the accessibility basics most teams skip. It sits next to our dashboard design patterns hub and the piece on data density, which already covers row height and virtualization, so I won't repeat those here.
TL;DR: Order columns by the task, right-align numbers and give them tabular digits, pin the header and the first column inside a scroll container with
border-collapse: separate, putaria-sorton one header at a time, keep row actions to one or two, and pick the loading model by what the reader does with the rows. Skip any of these and the table still renders. It just stops being comparable.
A data table is a grid of records where each row is one thing and each column is one property of it. Its whole job is comparison: the reader needs to hold two rows in view and decide which one matters. Every pattern below either protects that comparison or gets out of its way.
What does a table have to do before it looks good?
Four things, according to Nielsen Norman Group's research on data tables: help people find records that meet some criteria, compare data, view or edit a single row, and take actions on records. That list is the best spec I know for a table, because every feature maps to one of the four. Filters serve finding. Pinned headers serve comparing. A side panel serves editing. Checkboxes serve acting.
The live table above uses most of them at once. It has a pinned header, a pinned first column that doubles as the row header, right-aligned tabular numbers, a sort indicator, checkbox selection and keyboard-reachable scrolling. Scroll it sideways and the order IDs stay put. Tick a row and the whole row tints without a line of JavaScript.
I built it as a single static <table> on purpose. A table that works as plain HTML before any framework touches it is a table you can reason about, and it's the version screen readers handle best.
How should columns be ordered and aligned?
Start with the identifier. NN/g's advice is to make the first column a readable record name, not an auto-generated database ID, because it's the label people use to keep their place. "A-1044 Halden & Sons" beats "7f3a91c2" every time. Then order the rest by importance and keep related columns adjacent: units next to revenue, revenue next to margin.
Alignment follows the data type, and it's the cheapest fix on this list:
- Text aligns left, so the eye has a clean edge to scan down.
- Numbers align right, so the ones, tens and hundreds line up in columns.
- Headers match the alignment of their column. A left-aligned header over right-aligned numbers makes the column look broken even when it isn't.
- Units go in the header ("Revenue (USD)"), not repeated in every cell.
Right alignment alone isn't enough, though. Most fonts give digits different widths, so a column of money still wobbles. I measured two numbers at 14px in Chromium with the default system font: "1,111.11" came out at 44.6px and "9,999.99" at 58.4px. Turn on tabular numerals and both measure 60.0px. That's a 13.8px swing from the digit 1 alone, and it's visible every time a live value updates.
.num {
text-align: right;
font-variant-numeric: tabular-nums;
}
Two declarations. If you only do one thing from this article, do that one. In the preview, delete the font-variant-numeric line and look at the Revenue column. The decimal points stay lined up because the text is right-aligned, but the thousands separators drift, and your eye stops trusting the column.
How do you pin the header and the first column?
With position: sticky, inside a container that scrolls. NN/g recommends freezing the header row and first column when the table is bigger than the screen, and CSS finally makes that a few lines of work.
.wrap { height: 236px; overflow: auto; }
table { border-collapse: separate; border-spacing: 0; }
thead th { position: sticky; top: 0; z-index: 2; }
tbody th { position: sticky; left: 0; z-index: 1; }
thead th:first-child { left: 0; z-index: 3; }
That last rule is the one people forget. The corner cell is pinned on both axes, so it needs the highest z-index. Without it, the first column slides under the header while you scroll down, and the two labels overprint each other.
Then there's the border trap. I switched the preview to border-collapse: collapse and scrolled: the header's bottom border stayed behind with the rows, so the pinned header floated with no line under it and row text showed right up to its edge. Sticky cells don't carry collapsed borders with them. Use separate with border-spacing: 0, put borders on the cells, and the line travels with the header.
One more rule, and it's about backgrounds. Every pinned cell needs an opaque background. A transparent sticky header lets scrolling rows show through it, and no amount of z-index fixes that.
How should sorting and filtering behave?
Predictably, and with the semantics in the markup. The W3C's sortable table example is a good reference. The header text of each sortable column sits inside a real <button>, and the aria-sort attribute goes on the <th> of the one column currently sorted. When the sort changes, you remove it from the old header and set it on the new one. Values are ascending and descending.
<th scope="col" aria-sort="descending">
<button type="button">Revenue (USD) <span aria-hidden="true">↓</span></button>
</th>
Notice the arrow. It lives in a span with aria-hidden="true", so it doesn't pollute the button's accessible name. The W3C example also puts the "click to sort" instruction in the table caption rather than repeating it on every button, which keeps a ten-column header from reading like a hostage negotiation.
For behaviour, three rules cover most dashboards. Sort on the first click, reverse on the second, and never silently reset the sort when new data arrives. Show active filters as removable chips above the table, so a reader never wonders why only 41 rows came back. And let people hide and reorder columns, but show a count of what's hidden. A table that quietly omits a column is lying by omission.
How do selection and row actions fit?
Selection first. A checkbox in the first column, a header checkbox for select-all, and the indeterminate state for "some rows". Tint selected rows so the choice survives a scroll. Since 2023 every major browser supports :has(), so this needs no script:
tr:has(input:checked) > * { background: #e6eeff; }
When something is selected, replace the filter bar with a bulk action bar ("3 selected: Export, Archive, Delete") instead of floating a toolbar over the rows. And tell people what select-all does. If the table has 1,284 rows and 20 are on screen, "Select all 20" and "Select all 1,284" are different promises, and the reader deserves to pick.
Row actions are where tables turn into hieroglyphics. NN/g suggests keeping inline row actions to one or two, because hidden menus are hard to discover. I agree, and I'd go further: if you need five actions per row, the problem isn't the table, it's that rows are doing the job of a detail page. Open a detail view instead.
A table is a promise that every row can be compared with every other row, so every layout choice either protects that comparison or breaks it.
Editing follows the same logic. NN/g's guidance is to edit in place only when the table is narrow, and to avoid modal dialogs for deeper edits because they hide the neighbouring rows. A non-modal side panel lets someone change a value and still see how the row compares with the rows above and below it. That's the comparison task again.
Pagination, load more, infinite scroll or virtual rows?
Pick by task, not by fashion.
| Task | Best fit | Why |
|---|---|---|
| Find one known record | Search and filters, then pagination | Pages give a stable position and a count |
| Scan and compare hundreds of rows | Virtual scroll, fixed row height | Only visible rows are in the DOM |
| Browse a feed with nothing to act on | Infinite scroll | No footer to reach, no place to lose |
| Act on many rows | Pagination or virtual scroll with "select all matching" | Selection needs a defined set |
Infinite scroll is the one I'd keep away from admin tables. It buries the footer, loses the reader's place on a refresh, and makes "select everything" ambiguous. Whatever model you choose, show the position: "41-60 of 1,284" is a small line of text that does more for orientation than any scrollbar. The density guide linked at the top covers how virtualization and row height depend on each other, so a density toggle should feed the same number to both.
What should loading, empty and error states look like?
Loading first, because that's where layout shifts hide. Render skeleton rows at the real row height, with the real column widths, so the table doesn't jump when data lands. A spinner in an empty box tells the reader nothing and collapses the layout underneath it.
.skeleton td { height: 36px; }
.skeleton td::after {
content: "";
display: block;
height: 12px;
border-radius: 6px;
background: #e3e5ee;
}
Empty states have two causes, and they need different messages. "No orders yet" and "No orders match these filters" are not the same sentence, and the second needs a "Clear filters" button right there. Error states should keep the table frame and headers visible, say what failed, and offer a retry, so the reader keeps their context instead of landing on a blank page.
If a number is missing, say so. A dash is fine, a zero is a claim. "0.0%" margin and "no margin recorded" mean different things, and finance teams know it.
How do you keep a table accessible, and usable on a phone?
Start with the scroll container. A region that scrolls sideways has to be reachable by keyboard, and that's a real rule: axe-core's scrollable-region-focusable check fails when nothing inside a scrollable area can take focus. The fix from Deque is tabindex="0" on the container. I added that plus role="region" and an aria-label to the preview wrapper. Run against the preview as a standalone page, axe-core reported only the two page-level rules, no main landmark and no h1, both caused by testing a fragment, nothing from the table itself.
Next, keep the native <table>. Older write-ups from Adrian Roselli and Steve Faulkner reported that setting display: grid or flex on table elements strips their table semantics in the accessibility tree. A 2024 test by Zell Liew found most browser and screen reader pairs coped, though NVDA missed colspan. The sources disagree, which is the point: if you restyle a table into cards on small screens, you're gambling, and you'd have to re-add every ARIA role by hand to be safe. I'd rather keep the table and let it scroll.
Then touch. WCAG 2.2's target size rule asks for at least 24 by 24 CSS pixels on pointer targets, with a spacing exception. The 16px checkboxes in the preview miss that on size and pass through the exception, because neighbouring rows sit 36px apart. Squeeze rows toward 24px and the exception stops applying, so give the checkbox a bigger hit area before you do. Row action buttons need the same treatment.
On a phone, three habits cover almost everything. Keep the first column pinned. Cut the visible columns to the three that answer "which one is this and what's wrong with it". Everything else goes behind a row tap into a detail view. Contrast matters too, since zebra stripes and tinted rows shrink the margin for grey text, so check your tints against the rules in accessible tokens for design systems.
Which mistake costs the most?
Alignment. It's the least glamorous item here, and it's the one I'd fix first in any dashboard, because it affects every row of every table you ship. Pinned headers and clean sorting are the features people notice. Right-aligned tabular numbers are the ones they feel.
Do the cheap things in order: identifiers first, numbers right, header pinned, sort announced, filters visible. Reach for virtualization and column customisation only when a real table, with real data, demands it. If the same chart question keeps coming up while you build, choosing the right chart type is the next decision, and typography for data-dense interfaces covers the type side of everything above.