---
title: "Data Table"
description: "Shows a list of records that people can search, filter, sort, select, and page through. It has a loading, empty, and error state of its own."
url: https://gelatinui.com/components/data-table
markdown_url: https://gelatinui.com/components/data-table.md
access: free
install: "npx shadcn@latest add @gelatin-ui/data-table"
registry_item: https://gelatinui.com/r/data-table.json
version: "2026-11-11"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Data Table

> Shows a list of records that people can search, filter, sort, select, and page through. It has a loading, empty, and error state of its own.

Page: https://gelatinui.com/components/data-table

## When to use it

Best for: A list of records that people sort, pick, and page, with loading and empty states.

- Use it when the rows need sort, selection, or pages.
- Use `manual` options of TanStack Table for server data.
- Use `DataTableEmpty` and `DataTableError` for your own words.

## When not to use it

- For a plain list with no state, use a [Table](https://gelatinui.com/components/table.md).

## Notes for agents

- Make the table with `useTable` and `dataTableFeatures`, and pass it as `table`.
- Each column needs `meta.label`: the column menu and the screen reader name read it.
- The root is a Frame. Put `FrameHeader` in the tray, `DataTableContent` for the rows, and `DataTablePagination` in the footer.
- It has three installs: `data-table` (the root, the rows, and the states), `data-table-toolbar` (search, Filters, Reset, and View), and `data-table-pagination` (the footer). Add only the parts you use: the toolbar installs Filters.
- Put `DataTableToolbar` first inside `DataTable`, with `DataTableSearch`, `DataTableFilters`, `DataTableReset`, and `DataTableViewOptions` in it. A column with `meta.filter` gets a field in Filters.
- `getRowId` keeps the selection when the rows change.
- Add the select column with `dataTableSelectColumn`. Read the scope with `useDataTableSelection`.
- It renders on TanStack Table 9, which installs with it.

## Anatomy

```text
DataTable
├─ DataTableSelectAll (0..n)
├─ DataTableSelectRow (0..n)
├─ DataTableColumnHeader (0..n)
├─ DataTableSelectAllBar (0..n)
├─ DataTableContent (0..n)
├─ DataTableState (0..n)
├─ DataTableStateHeader (0..n)
├─ DataTableStateIcon (0..n)
├─ DataTableStateTitle (0..n)
├─ DataTableStateDescription (0..n)
├─ DataTableStateActions (0..n)
├─ DataTableEmpty (0..n)
├─ DataTableNoResults (0..n)
├─ DataTableError (0..n)
└─ DataTableRow (0..n)
```

## API reference

### DataTable

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `"default" \| "sm"` |  |  |
| `table` | `ReactTable<TFeatures, TData, TSelected>` |  | The table from `useTable`, with `dataTableFeatures` (or a preset that adds to it). |
| `children` | `ReactNode` |  |  |
| `status` | `DataStatus` | "ready" | The load state of the rows. Default `ready`. `loading`: the first load, skeleton rows at the real row height, and `aria-busy`. `empty`: the body shows its no rows state. `error`: the rows did not load. With no rows the body shows the error state; with rows on screen (a refresh failed) the rows stay and one line above them says so. |
| `refreshing` | `boolean` | false | New data loads while the old rows stay: a 2px line under the head, and `aria-busy`. |
| `onRetry` | `function` |  | Load the rows again: the Retry button of the error states. Without it, no button. Keep it stable. |
| `density` | `DataTableDensity` |  | The row height (controlled). |
| `defaultDensity` | `DataTableDensity` | "default" | The row height on the first render (uncontrolled). Default `default` (36px). |
| `onDensityChange` | `function` |  |  |
| `labels` | `Partial<DataTableLabels>` |  | The words of the table, over the English defaults (`DATA_TABLE_LABELS`). Keep it stable. |
| `locale` | `string` |  | The locale of the counts. Default: the page locale. |

Also takes every prop of Base UI `UseRender`: https://base-ui.com/react/components/use-render

### DataTableSelectAll

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `size` | `"default" \| "lg"` |  | `default` 16px, or `lg` 20px. Default: the `CheckboxGroup` size, else `default`. |

Also takes every prop of Base UI `Checkbox.Root`: https://base-ui.com/react/components/checkbox

### DataTableSelectRow

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `aria-label` | `string` |  | Defines a string value that labels the current element. The text people hear: "Select Acme Robotics". Default: `labels.selectRow`. |
| `className` | `string` |  |  |
| `size` | `"default" \| "lg"` |  | `default` 16px, or `lg` 20px. Default: the `CheckboxGroup` size, else `default`. |
| `rowId` | `string` |  | The row id (`row.id`). |

Also takes every prop of Base UI `Checkbox.Root`: https://base-ui.com/react/components/checkbox

### DataTableColumnHeader

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `column` | `string` |  | The column id. |
| `children` | `ReactNode` |  | The text of the head. Default: the column `meta.label`, else the id. |
| `className` | `string` |  |  |
| `menuItems` | `ReactNode` |  | More items at the end of the column menu, after a line: the Pro Data Grid adds Pin and Move here. Render `MenuItem`s (or a `MenuGroup`). |

### DataTableSelectAllBar

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### DataTableContent

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `ReactNode` |  | The body states: `DataTableEmpty`, `DataTableNoResults`, and `DataTableError`. Each one shows only in its own state. A state you leave out shows its default content (each part registers with the content, CONTRACT C11), so pass only the states you change. |
| `label` | `string` |  | The name of the table for screen readers ("Customers"). |
| `skeletonRows` | `number` | 5 | Skeleton rows on the first load. Default 5. |

Also takes every prop of Base UI `UseRender`: https://base-ui.com/react/components/use-render

### DataTableState

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### DataTableStateHeader

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### DataTableStateIcon

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `"default" \| "icon"` |  |  |
| `tone` | `"destructive" \| "neutral"` | "neutral" | `destructive`: the soft red tile of a failed load. Default `neutral`: the plain tile. |

### DataTableStateTitle

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### DataTableStateDescription

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### DataTableStateActions

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### DataTableEmpty

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### DataTableNoResults

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### DataTableError

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### DataTableRow

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `rowId` | `string` |  | The row id, for its selected fill. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| DataTable | `data-table` |  |  |  |
| DataTableSelectAll | `data-table-select-all` |  |  | `hit-area` |
| DataTableSelectRow | `data-table-select-row` |  |  | `hit-area` |
| DataTableColumnHeader | `data-table-column-header` | `data-popup-open` |  | `hit-area` |
| DataTableSelectAllBar | `data-table-select-all-bar` |  |  |  |
| DataTableContent | `data-table-content` | `data-state` | `--card`, `--foreground` |  |
| DataTableState | `data-table-state` |  |  |  |
| DataTableStateHeader | `data-table-state-header` |  |  |  |
| DataTableStateIcon | `data-table-state-icon` |  |  |  |
| DataTableStateTitle | `data-table-state-title` |  |  |  |
| DataTableStateDescription | `data-table-state-description` |  |  |  |
| DataTableStateActions | `data-table-state-actions` |  |  |  |
| DataTableEmpty | `data-table-empty` |  |  |  |
| DataTableNoResults | `data-table-no-results` |  |  |  |
| DataTableError | `data-table-error` |  |  |  |
| DataTableRow | `data-table-row` |  |  |  |

## Usage

Make the table with `useTable`, and pass it to the root. Add `data-table-toolbar` for search and filters, and `data-table-pagination` for the footer.

The sample also uses `data-table-pagination`, `data-table-toolbar`, which this add does not write. One command adds them with this item:

```bash
npx shadcn@latest add @gelatin-ui/data-table @gelatin-ui/data-table-pagination @gelatin-ui/data-table-toolbar
```

```tsx title="customers-table.tsx"
import { createColumnHelper, useTable } from "@tanstack/react-table";

import { DataTable, DataTableContent } from "@/components/data/data-table";
import { DataTablePagination } from "@/components/data/data-table-pagination";
import {
  DataTableFilters,
  DataTableReset,
  DataTableSearch,
  DataTableToolbar,
  DataTableViewOptions,
} from "@/components/data/data-table-toolbar";
import { dataTableFeatures } from "@/lib/data-table-features-model";
import type { DataTableFeatures } from "@/lib/data-table-features-model";

type Customer = { id: string; name: string; plan: string };

const customers: Customer[] = [{ id: "c1", name: "Northwind Traders", plan: "Team" }];
const column = createColumnHelper<DataTableFeatures, Customer>();
const columns = column.columns([
  column.accessor("name", { header: "Customer", meta: { label: "Customer" } }),
  column.accessor("plan", {
    header: "Plan",
    filterFn: "filter",
    meta: { label: "Plan", filter: { kind: "options" } },
  }),
]);

export function CustomersTable() {
  const table = useTable({ features: dataTableFeatures, columns, data: customers });
  return (
    <DataTable table={table}>
      <DataTableToolbar>
        <DataTableSearch placeholder="Search customers" />
        <DataTableFilters />
        <DataTableReset />
        <DataTableViewOptions />
      </DataTableToolbar>
      <DataTableContent label="Customers" />
      <DataTablePagination pageSizes={[10, 25, 50]} />
    </DataTable>
  );
}
```

## Compose

Build it with:

- [Filters](https://gelatinui.com/components/filters.md): Narrows the records.
- [Badge](https://gelatinui.com/components/badge.md): Shows the status of each record.
- [Menu](https://gelatinui.com/components/menu.md): Holds the actions of one row.
- [Pagination](https://gelatinui.com/components/pagination.md): Moves between pages.
- [Empty](https://gelatinui.com/components/empty.md): Shows when no record matches, with a next action.
- [Skeleton](https://gelatinui.com/components/skeleton.md): Holds the layout while the rows load.

Rules:

- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.
- Color has a job (`color-has-a-job`): Use color only for a status, the brand action, or data; keep the rest neutral, and show a level with a small mark (a dot, a tinted badge) before a big fill.
- Real content (`real-content`): Fill the UI with content of the real product (real names, amounts, dates, and states), never lorem text or "Item 1".
- Steady text weight (`steady-weight`): Never change the font weight on hover, focus, selected, active, or open; change the color or the fill, so the text does not jump.

Patterns: `gelatin://patterns/data-list`

## Add it

```bash
npx shadcn@latest add @gelatin-ui/data-table
```

It adds 59 registry items: 56 files, 9474 lines, and the npm packages `@base-ui/react`, `@phosphor-icons/react`, `@tanstack/react-table`, `@xstate/react`, `clsx`, `tailwind-merge`, `tailwind-variants`, `xstate`.

## Built on

- [Alert](https://gelatinui.com/components/alert.md)
- [Badge](https://gelatinui.com/components/badge.md)
- [Button](https://gelatinui.com/components/button.md)
- [Checkbox](https://gelatinui.com/components/checkbox.md)
- [Empty](https://gelatinui.com/components/empty.md)
- [Frame](https://gelatinui.com/components/frame.md)
- [Icon Tile](https://gelatinui.com/components/icon-tile.md)
- [Menu](https://gelatinui.com/components/menu.md)
- [Skeleton](https://gelatinui.com/components/skeleton.md)
- [Table](https://gelatinui.com/components/table.md)
- [Tooltip](https://gelatinui.com/components/tooltip.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Table](https://gelatinui.com/components/table.md): Pick Table for plain rows and columns with no sort, filter, selection, or pages.
- [Filters](https://gelatinui.com/components/filters.md)
- [Frame](https://gelatinui.com/components/frame.md)
- [Data Grid](https://gelatinui.com/components/data-grid.md): Pick Data Grid (Pro) for records that people edit in cells all day, with 10,000 rows and more, paste, and undo.

## Keyboard

| Keys | Action |
| --- | --- |
| Tab | Moves focus through the toolbar, the head menus, the boxes, and the page buttons. |
| F | Opens the field list of the Filter button, when focus is not in a field. |
| Escape | Clears the search while it has focus. |
| Enter, Space | Opens a column menu, or ticks a box. |
| Left Arrow, Right Arrow | Scrolls a table that is wider than its box. |

## Accessibility

`DataTableContent` takes a `label` that names the table.

While new data loads, the table sets `aria-busy`.

A wide table scrolls in its own box, and that box takes focus so the arrow keys work.
