# DataTable: the table of every list

DataTable is the table behind every list in an app built on Meadowstack: each column says what it holds, and that kind sets its width, its alignment and its figures, so money lines up on the right on every screen. On a phone the table keeps its main columns and folds the rest under them, so it never scrolls sideways.

Checked 2 December 2026. By Bohuslav Poláček. https://meadowstack.com/components/data-table/

*Kestrel's invoices in the To be paid view, rendered from the kit with the demo's data. Narrow the window: the table keeps the client and the amount and folds the number, the days overdue and the status under them.*

A live screen, rendered from the kit's components on the page: https://meadowstack.com/components/data-table/

## What it is for, and what the preview shows

DataTable is the table of a list of records: orders, invoices, dies, members. It sorts, groups, sums a column in a footer, selects rows for a [BulkBar](https://meadowstack.com/components/bulk-bar/), marks the row whose record is open beside the list in a [RecordPeek](https://meadowstack.com/components/record-peek/), and draws an empty list and a filter with no results as two different states.

The preview is the invoice list of [Kestrel](https://meadowstack.com/examples/accounting-office-documents/), an accounting practice in the demo, in its **To be paid** view: twelve invoices, the client as the title column, the number, two dates, the amount and the status. Four are overdue, and the row says by how many days in the danger colour, beside the word, never as colour alone.

## The rules, and where each one lives

- **Every column says what it holds.** `meta: { kind }` takes one of twelve kinds, and the kind sets the width, the alignment and the figures: `money` is 8rem wide from 768px, right-aligned, with tabular figures; `date` is 7rem; `id` is 8rem with plain figures, because tabular figures widen the hyphens of INV-2026-0049. The widths are the kit's `columnKinds`; `npm run check:columns` fails a column without a kind, and the runtime audit's `column-kinds` rule checks alignment by kind and one width per kind on a screen (`docs/audit.md`).
- **A table never scrolls sideways on a phone.** A column with `hideOnMobile` hides, and `CellStack` folds its value into a cell that stays. The root `AGENTS.md` sets it under Responsive; the audit's `table-scroll` and `horizontal-overflow` rules fail a screen that breaks it at 390px.
- **The table folds by its own width.** `hideOnMobile` is a container query on the table, so the same list folds beside a side panel at 1440px as it does on a phone.
- **One look, one height.** A subtle header band, hairlines between rows, the hovered row a rounded chip, no outer box; rows are one height, and ticking a row never changes it (`AGENTS.md`, Tables; the audit's `row-heights`).
- **Selection keeps its slot.** Every row keeps its checkbox slot, each box is 24 by 24px with its label (the audit's `target-size`), and bulk actions say how many rows they apply to.
- **Apps import the kit, not the engine.** ESLint stops an app from importing `@tanstack/react-table`, and `npm run check:markup` stops an own `<table>` (`bare-table`).

## What AI coding tools write instead

Asked for an invoice list, a coding assistant writes what the manifest's `replaces` names: a hand-written `<table>`, a grid of divs, or TanStack Table imported straight into the page, wrapped in an `overflow-x-auto` box.

Each of these works on its own screen and drifts across the app: every list picks its own widths, so amounts stop lining up between screens; dates and IDs get whichever figures the font gives them; the phone gets a table to swipe sideways with the client's name scrolled out of view. Selection, the empty list and the filter with no results are rebuilt each time, and usually only one of the two empty states exists. With DataTable the assistant writes columns and kinds, and the checks above catch a column that forgets its kind.

## How to use it

The props that matter, from its exported `DataTableProps`:

- `columns`, `data`, `getRowId`, and `label`: the table's accessible name ("Invoices").
- `meta` on each column: `kind`, then `hideOnMobile` (hidden under 42rem of table width) or `hideBelow` (`"sm"`, `"lg"`, `"xl"`: 32, 64 or 72rem) for what hides first, `total` for a sum in the footer, `group` for grouping, `clip` and `fill` for a long name that ends in an ellipsis.
- `CellStack` in a cell: `primary`, `secondary`, `secondaryOnMobile` to show the folded value only when the column beside it hides, and `align="end"` under money.
- `enableSelection` with `canSelectRow` and `getRowSelectBlockedReason` (the reason shows on the disabled box), `getRowLabel` so a screen reader hears which row a box selects.
- `onRowClick` and `activeRowId` for a list that opens records beside it.
- `pageSize` (10 unless set), `initialSorting`, `emptyState`, `isFiltered` with `onClearFilters`, and `variant` (`"plain"` or `"card"`).

Load the rows with `useResource` and render the table inside [AsyncState](https://meadowstack.com/components/async-state/), which draws the loading and error states around it.

## Its entry in the manifest

*The component's rules as the kit's manifest states them, the same entry an AI coding tool reads.*

| Manifest field | DataTable |
| --- | --- |
| What it is | The table of a list: column kinds set widths, sorting, grouping, selection with BulkBar, empty and no-results states, folding on a phone. |
| Use it for | Every list of records. |
| Not for | For two or three facts (PropertyList); For a board (Board, SortableBoard) |
| It replaces | A hand-written <table>; A div grid of rows; TanStack Table imported in the app; A table that scrolls sideways on a phone |
| Screen types | Index; Worklist; Record; Overview |
| Import | `import { DataTable, CellStack, tableRowClass, tableRowHoverClass, columnKinds } from "@meadowstack-studio/kit";` |

Read from the kit's component manifest when the site was built (126 components, packages/kit/src/components.json); the same entry answers an AI coding tool through the kit's MCP server.

## Where it runs in the example apps

*The example apps whose code renders DataTable, and in which modules, read from the demo's source.*

| Example app | Modules that render it |
| --- | --- |
| [An app for a packaging and print company](https://meadowstack.com/examples/packaging-print-production/) | Jobs, Print file editor, Quotes, Cutting dies, Colour |
| [An app for a studio or agency](https://meadowstack.com/examples/agency-capacity-planning/) | Capacity, Finance |
| [An app for a haulage company](https://meadowstack.com/examples/haulage-dispatch-planning/) | Freight, Drivers, Costs |
| [An app for a roastery with an online shop](https://meadowstack.com/examples/coffee-roastery-production/) | Roasting, Green coffee, Shop, Wholesale |
| [An app for a sports club](https://meadowstack.com/examples/sports-club-court-bookings/) | Club, Coaching, Rentals |
| [An app for a construction company](https://meadowstack.com/examples/construction-site-management/) | Sites, Crews, Machines, Site diary, Drawings, Budget |
| [An app for an accounting office](https://meadowstack.com/examples/accounting-office-documents/) | Documents, Bookkeeping, Official mail, Invoicing |
| [An app for restaurants and venues](https://meadowstack.com/examples/restaurant-staff-rota/) | Kitchen, Food safety |
| [An app for one person](https://meadowstack.com/examples/personal-app-for-a-creator/) | Brand deals, Money, Training |

Read from the demo's source when the site was built: 9 of 9 example apps render <DataTable>, in the modules named here as each app's sidebar names them.

## How the starter declares its columns

*The last three columns of the starter's purchase requests: each names its kind, the date and the status hide on a phone, and the status folds under the amount there.*

From `templates/starter/src/modules/requests/pages/requests-list.tsx` in the Meadowstack repository:

```tsx
    id: "neededBy",
    accessorKey: "neededBy",
    header: "Needed by",
    meta: { kind: "date", hideOnMobile: true },
    cell: ({ getValue }) => (
      <span className="whitespace-nowrap text-fg-muted tabular">{formatDate(getValue<string>())}</span>
    ),
  },
  {
    id: "status",
    accessorKey: "status",
    header: "Status",
    meta: { kind: "status", hideOnMobile: true },
    cell: ({ row }) => <RequestStatusLabel status={row.original.status} />,
    sortingFn: (a, b) => statusOrder.indexOf(a.original.status) - statusOrder.indexOf(b.original.status),
  },
  {
    id: "amount",
    accessorKey: "amount",
    header: "Amount",
    meta: { kind: "money" },
    // On a phone the status sits under the amount.
    cell: ({ row }) => (
      <CellStack
        align="end"
        primary={<span className="font-medium whitespace-nowrap">{formatMoney(row.original.amount)}</span>}
        secondary={<RequestStatusLabel status={row.original.status} short />}
        secondaryOnMobile
      />
    ),
  },
],
```

## Questions

### Does the table scroll sideways on a phone?

No. Columns marked to hide on a phone disappear below 672px of table width, and CellStack shows their values under the cells that stay, so the client, the number and the days overdue still read in one column.

### How do I show money in a column?

Give the column the money kind. It takes a fixed width, aligns right and uses tabular figures, so amounts line up in every row and on every screen; on a phone the status can sit under the amount in the same cell.

### Why does the table fold by its own width and not by the window?

Because a list is not always the whole window. When a record opens in a side panel beside it, the list gets narrower and hides its less important columns, the same way a phone does.

### Can I import TanStack Table directly?

Not in an app built on the kit: ESLint stops the import. DataTable takes TanStack Table's column definitions, so the API is familiar, and adds the kinds, the fold, selection and the two empty states.

### What happens when a filter hides every row?

The table says there are no results for this filter and offers to clear it. A list that is empty because nothing exists yet shows its own empty state with the action that creates the first record.

## Related

- [BulkBar: what to do with the selection](https://meadowstack.com/components/bulk-bar/) (Components)
- [FilterBar: the one row above a list](https://meadowstack.com/components/filter-bar/) (Components)
- [Data tables in business apps: kinds, figures, headers, cut text](https://meadowstack.com/blog/data-tables-in-business-apps/) (Blog)
- [A packaging quote that works out its price as you type](https://meadowstack.com/screens/quote-form/) (Screens)
- [A weekly timesheet for an agency](https://meadowstack.com/screens/timesheet/) (Screens)
- [An invoice form that shows its totals as you type](https://meadowstack.com/screens/invoice-form/) (Screens)
