Design System
Data display

Data grid

Table plus search, sorting, column visibility, paging and loading and empty states. This is what operational lists need.

Purpose

If the user ever has to find a row, you want DataGrid. It wraps Table with everything an operational list needs — a search box, sortable headers, a column-visibility menu, a pagination footer, and proper loading and empty states — so a claims queue or member roster never gets rebuilt from primitives.

ComponentUse
DataGridOperational lists: claims queues, member rosters, anything searched or paged.
TableStatic, short lists: plan summaries, breakdowns inside a detail page.
DescriptionListOne record's fields — a detail view is not a one-row table.

Example

Columns are TanStack Table ColumnDefs (the type is re-exported from the subpath); cell renderers compose freely with other components — badges, menus, avatars.

CLM-48213Aisyah RahmanKlinik Mediviron, KL Sentral85.00Approved
CLM-48214Lim Wei JiePoliklinik Bangsar120.00Pending
CLM-48215Priya NairKlinik Kita, Petaling Jaya45.00Approved
CLM-48216Tan Mei LingKlinik Idzham, Shah Alam310.00Denied
CLM-48217Ahmad FaizGleneagles Medical Centre780.00Open

10 rows

Page 1 of 2
Claims queue
import { DataGrid, type ColumnDef } from "@healthmetrics/ui/data-grid";
import { Badge } from "@healthmetrics/ui/badge";

const columns: ColumnDef<Claim, unknown>[] = [
  { accessorKey: "id", header: "Claim", enableHiding: false },
  { accessorKey: "member", header: "Member" },
  {
    accessorKey: "amount",
    header: "Amount (MYR)",
    cell: ({ getValue }) => (
      <span className="tabular-nums">{(getValue() as number).toFixed(2)}</span>
    ),
  },
  {
    accessorKey: "status",
    header: "Status",
    cell: ({ getValue }) => <Badge variant="success">{getValue() as string}</Badge>,
  },
];

<DataGrid columns={columns} data={claims} searchPlaceholder="Search claims…" pageSize={10} />;

Per-column behaviour comes straight from the ColumnDef: enableHiding: false pins a column out of the visibility menu (do this for identifiers), and enableSorting: false removes the sort affordance from a header. hideToolbar drops the search box and column menu when the grid is embedded somewhere those duplicate the page's own controls.

Everything is client-side and in-memory: the global filter, sorting and paging all operate on the data you pass. There is no server-side pagination mode, no row selection, and no controlled sort/filter state — if you need those, compose TanStack Table over the raw Table parts instead.

States

loading swaps the body for five skeleton rows and the footer count for "Loading…" — the layout holds its shape while data arrives.

Loading…

Page 1 of 1

With no rows — an empty result or an over-eager search — a single centred cell shows emptyText. Make it say what to do next, not just "No results."

No claims match your filters.

0 rows

Page 1 of 1

Structure

The tokens behind the grid — the table itself inherits everything from Table.

PropertyValue
Toolbarsearch Input (max 320px, leading search glyph) + Columns menu
Container1px --border, --radius-xl, horizontal scroll
HeaderSortableHead buttons, 44px rows, 12px uppercase
Loading5 Skeleton rows, one per visible column
Emptysingle 112px centred cell, --muted-foreground
Footer12px row count + "Page X of Y", small outline previous/next buttons

Best practices

Do

  • Pin identifier columns with enableHiding: false — a claims queue with the claim number hidden is unusable.
  • Render amounts with tabular-nums in a cell, right-aligned when compared.
  • Write specific searchPlaceholder and emptyText — "Search claims…", "No claims match your filters.", not the defaults.
  • Keep row actions in a trailing DropdownMenu cell, not a strip of icon buttons.

Don't

  • Reach for DataGrid on a short static list — that is Table, without the toolbar chrome.
  • Feed it one page of server data — filtering, sorting and paging are client-side and in-memory, so partial data silently searches and sorts only what it was given.
  • Hide the toolbar on a list long enough to page — search is how users cope with volume.
  • Truncate identifiers users copy (claim numbers) — wrap or widen instead.

Accessibility & keyboard

  • Semantic <table> markup throughout — real row and column navigation for screen readers.
  • Sortable headers are real <button>s inside a <th> carrying aria-sort (ascending / descending / none), so sort state never relies on the arrow glyph alone.
  • The search input has aria-label="Search table"; the pager buttons are labelled "Previous page" / "Next page" and disable at the bounds.
  • All glyphs (search, column, chevrons, sort arrows) are decorative and hidden from assistive tech — every control also has a text or ARIA name.
  • The loading state is visual only — skeleton rows make no announcement. If load times are long, announce progress at page level.
  • Keyboard: Tab reaches search → Columns menu → each sortable header → the pager; Enter/Space toggles sort, opens the menu and activates paging. The column menu is a DropdownMenu — arrow keys move between checkboxes, Escape closes.

Props

PropTypeDefaultDescription
columnsrequiredColumnDef<TData, unknown>[]——
datarequiredTData[]——
loadingboolean | undefined—Render skeleton rows instead of data (Figma "Loading" state).
emptyTextstring | undefined"No results."Message for the empty state.
searchPlaceholderstring | undefined"Search…"Placeholder for the global search box.
hideToolbarboolean | undefined—Hide the toolbar (search + column visibility).
pageSizenumber | undefined10Rows per page.
classNamestring | undefined——
Data grid in Storybook

On this page