Skip to content

DataTable

The grid of a data console: thousands of rows that scroll smoothly, columns you can sort, filter, resize and hide, rows to select and act on together, values edited in place, and CSV export. On a phone every row becomes a card, and long lists always paginate.

import { DataTable, DataTableSkeleton } from '@sypnia/ui/react'

On this page
  1. 10,000 rows
  2. Edit in place
  3. Select and act on many
  4. As cards
  5. Pages from a server
  6. Loading, error and empty
  7. Skeleton
  8. When to use it
  9. For everyone
  10. Props

10,000 rows

Scroll, sort by a column, open «Filters», hide columns or export what you see as CSV. The bar under the rows pages them: 100 at a time, or as many as you choose.

ord_110000
Sofía Herrera
Paid
Nov 17, 2026
$364.69
ord_109999
Marco Silva
Paid
Nov 16, 2026
$271.43
ord_109998
Élan Bikes
Paid
Nov 16, 2026
$187.12
ord_109997
Acme Studio
Pending
Nov 16, 2026
$233.95
ord_109996
Kenji Watanabe
Refunded
Nov 16, 2026
$461.58
ord_109995
Élan Bikes
Paid
Nov 16, 2026
$454.17
ord_109994
Julia Prieto
Paid
Nov 16, 2026
$76.29
ord_109993
Northwind Traders
Paid
Nov 16, 2026
$278.69
ord_109992
Amara Okafor
Pending
Nov 16, 2026
$280.32
ord_109991
Northwind Traders
Paid
Nov 16, 2026
$27.44
ord_109990
Julia Prieto
Paid
Nov 16, 2026
$257.43
ord_109989
Julia Prieto
Paid
Nov 16, 2026
$211.98
ord_109988
Blue Harbor
Paid
Nov 16, 2026
$453.25
ord_109987
Amara Okafor
Paid
Nov 16, 2026
$258.12
ord_109986
Acme Studio
Paid
Nov 16, 2026
$354.12
ord_109985
Élan Bikes
Paid
Nov 16, 2026
$195.72
ord_109984
Amara Okafor
Pending
Nov 16, 2026
$38.86
ord_109983
Diego Ruiz
Paid
Nov 16, 2026
$110.00
ord_109982
Diego Ruiz
Paid
Nov 16, 2026
$68.90
ord_109981
Amara Okafor
Refunded
Nov 16, 2026
$453.88
ord_109980
Marco Silva
Pending
Nov 16, 2026
$38.02
ord_109979
Élan Bikes
Paid
Nov 16, 2026
$244.68
ord_109978
Ana Castaño
Paid
Nov 16, 2026
$186.97
10,000 rows
1–100 of 10,000
Code
import { useMemo } from 'react';
import { Badge, DataTable, useSypnia, type DataColumn } from '@sypnia/ui/react';
import { orders, statuses, type Order } from './data';

const tone = { Paid: 'ok', Pending: 'warn', Refunded: 'neutral', Failed: 'fail' } as const;

// 10,000 orders in the browser. Only the rows on screen are drawn, so it scrolls smoothly; the bar under the rows pages them.
// Sort by any column, filter by customer, status or country, show the hidden «Country» and «Items» columns, and export what you see as CSV.
export default function TenThousand() {
  const { format } = useSypnia();
  const rows = useMemo(() => orders(10000), []);
  const columns: DataColumn<Order>[] = [
    { id: 'id', header: 'Order', machine: true, width: 120, value: (o) => o.id, sortable: true },
    { id: 'customer', header: 'Customer', width: 180, value: (o) => o.customer, sortable: true, filter: 'text' },
    { id: 'status', header: 'Status', width: 120, value: (o) => o.status, sortable: true, filter: 'select', options: statuses,
      render: (o) => <Badge tone={tone[o.status as keyof typeof tone]} dot>{o.status}</Badge> },
    { id: 'country', header: 'Country', width: 150, value: (o) => o.country, sortable: true, filter: 'select',
      options: ['Argentina', 'Chile', 'Colombia', 'Japan', 'Mexico', 'Peru', 'Spain', 'United States'] },
    { id: 'items', header: 'Items', numeric: true, width: 80, value: (o) => o.items, sortable: true },
    { id: 'placed', header: 'Placed', width: 120, value: (o) => o.placed, render: (o) => format.date(o.placed), sortable: true },
    { id: 'total', header: 'Total', numeric: true, width: 120, value: (o) => o.total, render: (o) => (o.total === null ? null : format.currency(o.total, 'USD')), sortable: true },
  ];
  return <DataTable label="Orders" columns={columns} rows={rows} rowKey={(o) => o.id} columnPicker defaultHidden={['country', 'items']} exportName="orders" height="28rem" />;
}

Edit in place

Double-click a value, or move to it and press Enter. Saving takes a moment. Try a negative price: it is refused, and the cell says why.

ID
Name
Price (USD)
Seats
Status
starter
Starter
9
3
Active
team
Team
29
10
Active
business
Business
99
50
Draft
legacy
Legacy 2024
19
5
Archived
4 rows
Code
import { useState } from 'react';
import { DataTable, type DataColumn } from '@sypnia/ui/react';

interface Plan { id: string; name: string; price: number; seats: number; status: string }
const start: Plan[] = [
  { id: 'starter', name: 'Starter', price: 9, seats: 3, status: 'Active' },
  { id: 'team', name: 'Team', price: 29, seats: 10, status: 'Active' },
  { id: 'business', name: 'Business', price: 99, seats: 50, status: 'Draft' },
  { id: 'legacy', name: 'Legacy 2024', price: 19, seats: 5, status: 'Archived' },
];

// Double-click a cell, or move to it and press Enter. Enter saves, Escape cancels, Tab saves and opens the next one.
// Saving takes a moment (the cell shows it is busy). A negative price is refused: the cell keeps what you typed and says why.
export default function Editable() {
  const [plans, setPlans] = useState(start);
  const save = (plan: Plan, column: string, value: unknown) => new Promise<void>((resolve, reject) => {
    setTimeout(() => {
      if (column === 'price' && Number(value) < 0) return reject(new Error('A price cannot be below zero.'));
      setPlans((all) => all.map((p) => (p.id === plan.id ? { ...p, [column]: column === 'name' || column === 'status' ? value : Number(value) } : p)));
      resolve();
    }, 700);
  });
  const columns: DataColumn<Plan>[] = [
    { id: 'id', header: 'ID', machine: true, width: 120, value: (p) => p.id },
    { id: 'name', header: 'Name', width: 180, value: (p) => p.name, editable: true },
    { id: 'price', header: 'Price (USD)', numeric: true, width: 130, value: (p) => p.price, editable: true, editor: 'number' },
    { id: 'seats', header: 'Seats', numeric: true, width: 100, value: (p) => p.seats, editable: (p) => p.status !== 'Archived', editor: 'number' },
    { id: 'status', header: 'Status', width: 140, value: (p) => p.status, editable: true, editor: 'select', options: ['Active', 'Draft', 'Archived'] },
  ];
  return <DataTable label="Plans" columns={columns} rows={plans} rowKey={(p) => p.id} onEdit={save} />;
}

Select and act on many

Tick rows, or the header box to tick every row that matches the filters. The bar above the rows says how many and what can be done to all of them.

Order
Customer
Status
Total
ord_100240
Sofía Herrera
Paid
364.69
ord_100239
Marco Silva
Paid
271.43
ord_100238
Élan Bikes
Paid
187.12
ord_100237
Acme Studio
Pending
233.95
ord_100236
Kenji Watanabe
Refunded
461.58
ord_100235
Élan Bikes
Paid
454.17
ord_100234
Julia Prieto
Paid
76.29
ord_100233
Northwind Traders
Paid
278.69
ord_100232
Amara Okafor
Pending
280.32
ord_100231
Northwind Traders
Paid
27.44
ord_100230
Julia Prieto
Paid
257.43
ord_100229
Julia Prieto
Paid
211.98
ord_100228
Blue Harbor
Paid
453.25
ord_100227
Amara Okafor
Paid
258.12
ord_100226
Acme Studio
Paid
354.12
ord_100225
Élan Bikes
Paid
195.72
ord_100224
Amara Okafor
Pending
38.86
ord_100223
Diego Ruiz
Paid
110
ord_100222
Diego Ruiz
Paid
68.9
ord_100221
Amara Okafor
Refunded
453.88
ord_100220
Marco Silva
Pending
38.02
ord_100219
Élan Bikes
Paid
244.68
ord_100218
Ana Castaño
Paid
186.97
240 rows · 0 selected
1–50 of 240
Code
import { useMemo, useState } from 'react';
import { Button, DataTable, type DataColumn, type RowKey } from '@sypnia/ui/react';
import { orders, type Order } from './data';

// Tick rows, or the box in the header to tick every row that matches the filters. A bar appears with what can be done to all of them.
export default function Selectable() {
  const [rows, setRows] = useState(() => orders(240));
  const [selected, setSelected] = useState<Set<RowKey>>(new Set());
  const columns: DataColumn<Order>[] = useMemo(() => [
    { id: 'id', header: 'Order', machine: true, width: 130, value: (o) => o.id },
    { id: 'customer', header: 'Customer', width: 200, value: (o) => o.customer, filter: 'text' },
    { id: 'status', header: 'Status', width: 120, value: (o) => o.status, filter: 'select', options: ['Paid', 'Pending', 'Refunded', 'Failed'] },
    { id: 'total', header: 'Total', numeric: true, width: 120, value: (o) => o.total },
  ], []);
  return (
    <DataTable label="Orders to review" columns={columns} rows={rows} rowKey={(o) => o.id} pageSize={50} height="24rem"
      selectable selected={selected} onSelect={setSelected}
      bulkActions={(keys) => (
        <>
          <Button size="sm" icon="check" onClick={() => { setRows((all) => all.map((o) => (keys.includes(o.id) ? { ...o, status: 'Paid' } : o))); setSelected(new Set()); }}>Mark as paid</Button>
          <Button size="sm" variant="danger" icon="trash" onClick={() => { setRows((all) => all.filter((o) => !keys.includes(o.id))); setSelected(new Set()); }}>Delete</Button>
        </>
      )} />
  );
}

As cards

What a phone shows, forced here with layout='cards': 25 cards a page, each value with its column name.

  • ord_100080
    Customer
    Status
    Paid
    Total
    $364.69
  • ord_100079
    Customer
    Status
    Paid
    Total
    $271.43
  • ord_100078
    Customer
    Status
    Paid
    Total
    $187.12
  • ord_100077
    Customer
    Status
    Pending
    Total
    $233.95
  • ord_100076
    Customer
    Status
    Refunded
    Total
    $461.58
  • ord_100075
    Customer
    Status
    Paid
    Total
    $454.17
  • ord_100074
    Customer
    Status
    Paid
    Total
    $76.29
  • ord_100073
    Customer
    Status
    Paid
    Total
    $278.69
  • ord_100072
    Customer
    Status
    Pending
    Total
    $280.32
  • ord_100071
    Customer
    Status
    Paid
    Total
    $27.44
  • ord_100070
    Customer
    Status
    Paid
    Total
    $257.43
  • ord_100069
    Customer
    Status
    Paid
    Total
    $211.98
  • ord_100068
    Customer
    Status
    Paid
    Total
    $453.25
  • ord_100067
    Customer
    Status
    Paid
    Total
    $258.12
  • ord_100066
    Customer
    Status
    Paid
    Total
    $354.12
  • ord_100065
    Customer
    Status
    Paid
    Total
    $195.72
  • ord_100064
    Customer
    Status
    Pending
    Total
    $38.86
  • ord_100063
    Customer
    Status
    Paid
    Total
    $110.00
  • ord_100062
    Customer
    Status
    Paid
    Total
    $68.90
  • ord_100061
    Customer
    Status
    Refunded
    Total
    $453.88
  • ord_100060
    Customer
    Status
    Pending
    Total
    $38.02
  • ord_100059
    Customer
    Status
    Paid
    Total
    $244.68
  • ord_100058
    Customer
    Status
    Paid
    Total
    $186.97
  • ord_100057
    Customer
    Status
    Refunded
    Total
    $456.50
  • ord_100056
    Customer
    Status
    Paid
    Total
    $94.07
80 rows · 0 selected
1–25 of 80
Code
import { useMemo } from 'react';
import { DataTable, useSypnia, type DataColumn } from '@sypnia/ui/react';
import { orders, type Order } from './data';

// On a phone (40rem and below) every row is a card, with no setting: the first column is the title and each value
// carries its column name. 25 cards a page. Here it is forced with layout="cards", so you can see it on any screen.
export default function Cards() {
  const { format } = useSypnia();
  const rows = useMemo(() => orders(80), []);
  const columns: DataColumn<Order>[] = [
    { id: 'id', header: 'Order', machine: true, value: (o) => o.id },
    { id: 'customer', header: 'Customer', value: (o) => o.customer, editable: true },
    { id: 'status', header: 'Status', value: (o) => o.status },
    { id: 'total', header: 'Total', numeric: true, value: (o) => o.total, render: (o) => (o.total === null ? null : format.currency(o.total, 'USD')) },
  ];
  return <DataTable layout="cards" label="Orders" columns={columns} rows={rows} rowKey={(o) => o.id} selectable onEdit={() => {}} />;
}

Pages from a server

The table shows the page it was given, with skeleton rows while the next one comes, and reports the sort and the page.

1–25 of 1,342
Code
import { useEffect, useState } from 'react';
import { DataTable, type DataColumn, type DataSort } from '@sypnia/ui/react';
import { orders, type Order } from './data';

const all = orders(1342);
// A pretend server: it sorts and cuts the page, and answers after a moment.
function fetchPage(page: number, size: number, sort: DataSort | null) {
  return new Promise<Order[]>((resolve) => setTimeout(() => {
    const list = sort ? [...all].sort((a, b) => String(a[sort.id as keyof Order]).localeCompare(String(b[sort.id as keyof Order]), undefined, { numeric: true }) * (sort.dir === 'ascending' ? 1 : -1)) : all;
    resolve(list.slice((page - 1) * size, page * size));
  }, 600));
}

// When the rows live on a server, pass server and pagination: the table shows what it is given and reports the sort and the page.
export default function ServerPages() {
  const [page, setPage] = useState(1);
  const [size, setSize] = useState(25);
  const [sort, setSort] = useState<DataSort | null>(null);
  const [rows, setRows] = useState<Order[] | undefined>();
  useEffect(() => { let live = true; setRows(undefined); fetchPage(page, size, sort).then((r) => live && setRows(r)); return () => { live = false; }; }, [page, size, sort]);
  const columns: DataColumn<Order>[] = [
    { id: 'id', header: 'Order', machine: true, width: 130, value: (o) => o.id, sortable: true },
    { id: 'customer', header: 'Customer', width: 200, value: (o) => o.customer, sortable: true },
    { id: 'placed', header: 'Placed', width: 130, value: (o) => o.placed, sortable: true },
    { id: 'total', header: 'Total', numeric: true, width: 120, value: (o) => o.total, sortable: true },
  ];
  return (
    <DataTable server label="Orders" columns={columns} rows={rows} loading={!rows} rowKey={(o) => o.id} height="22rem"
      sort={sort} onSort={(s) => { setSort(s); setPage(1); }}
      pagination={{ page, pageSize: size, total: all.length, onPage: setPage, onPageSize: (n) => { setSize(n); setPage(1); } }} />
  );
}

Loading, error and empty

Choose a state. «Try again» and «Create a key» take you to the rows.

Code
import { useState } from 'react';
import { Button, DataTable, EmptyState, SegmentedControl, type DataColumn } from '@sypnia/ui/react';

interface Key { id: string; name: string; created: string }
const columns: DataColumn<Key>[] = [
  { id: 'name', header: 'Name', value: (k) => k.name },
  { id: 'id', header: 'Key', machine: true, value: (k) => k.id },
  { id: 'created', header: 'Created', value: (k) => k.created },
];
const keys: Key[] = [{ id: 'sk_live_4f1a…9c2e', name: 'Back office', created: '2026-11-02' }];

// Loading draws skeleton rows with the real columns, never a spinner. An error says what happened and offers to try again.
// An empty table says what goes in it and the first step.
export default function States() {
  const [state, setState] = useState('loading');
  return (
    <div className="sy-stack">
      <SegmentedControl label="State" value={state} onChange={setState}
        options={[{ value: 'loading', label: 'Loading' }, { value: 'error', label: 'Error' }, { value: 'empty', label: 'Empty' }, { value: 'ready', label: 'Ready' }]} />
      <DataTable label="API keys" columns={columns} rowKey={(k) => k.id}
        rows={state === 'ready' ? keys : state === 'empty' ? [] : undefined} loading={state === 'loading'}
        error={state === 'error' ? 'The keys could not be loaded. The server did not answer in time.' : undefined} onRetry={() => setState('ready')}
        empty={<EmptyState icon="key" title="No keys yet" actions={<Button variant="primary" icon="plus" onClick={() => setState('ready')}>Create a key</Button>}>A key lets your server talk to Sypnia without a password.</EmptyState>} />
    </div>
  );
}

Skeleton

Before even the columns are known: the same boxes as the real one, so nothing moves when the data arrives. On a phone, cards.

Code
import { DataTableSkeleton } from '@sypnia/ui/react';

// Before even the columns are known: toolbar, header, rows and the pagination bar on wide screens, and cards on phones,
// in the same boxes as a real DataTable. When the columns are known, use <DataTable loading> instead.
export default function Skeleton() {
  return <DataTableSkeleton columns={5} rows={6} selectable />;
}

When to use it

Use it when

  • People work with the rows, not just read them: they look for some, change values, act on many at once.
  • There are hundreds or thousands of rows: only the ones on screen are drawn.
  • Rows live on a server: pass server and pagination, and the table reports the sort, the filters and the page.
  • Give every column a value: it is what sorts, filters, edits and goes to the CSV. render only changes how it looks.

Do not use it when

  • People only read a few rows: Table is lighter and enough.
  • It is facts about a single thing: KeyValue.
  • Each item has a different shape or a picture: Cards.

For everyone

  • It is a grid with a name (label) and a single tab stop. Arrow keys move between cells, Home and End go to the ends of a row, Page Up and Page Down move a screen at a time.
  • Enter edits the cell, Enter or Tab saves it, Escape cancels. While it saves the cell is marked busy; if the save fails it keeps what was typed and says why.
  • A sortable header is a button named «Sort by Total», and the column says how it is sorted. A column edge can be resized with the arrow keys.
  • Empty values are written NULL, so «nothing» never looks like an empty string.
  • Loading draws skeleton rows with the real columns, never a spinner. The count of rows and selected rows is announced.
  • On phones (40rem and below) each row is a card: every value carries its column name, and the checkbox and the edit buttons are at least 44 px.

Props

DataTableTypeDefault
columnsrequired DataColumn<Row>[]
labelrequired

A name for screen readers.

string
rowKeyrequired (row: Row) => RowKey
rowsrequired

The rows in memory: all of them (the table scrolls through thousands), or one page when `pagination` is set.

Row[] | undefined
bulkActions

Buttons for the bar that appears while rows are selected. Receives the selected keys and the selected rows that are in memory.

((keys: RowKey[], rows: Row[]) => ReactNode)
columnPicker

Adds the «Columns» menu to the toolbar.

boolean
defaultHidden

Ids of columns hidden at first. With `columnPicker` the person can change them.

string[]
defaultSort DataSort | null null
empty

What to show when there are no rows at all: an EmptyState with the next step.

ReactNode
error

Something failed: say what happened in plain words.

ReactNode
exportName

Adds «Export CSV» to the toolbar. This is the name of the file. It exports the selected rows, or all the rows shown.

string
filters

Controlled filters, by column id. Leave it out and the table keeps its own.

DataFilters
height

The tallest the grid gets before it scrolls: any CSS length.

string min(32rem, 70dvh)
layout

`auto`: a grid on wide screens, cards on phones. Force one of them for a narrow panel or a preview.

"grid" | "cards" | "auto" auto
loading

Data is on its way: rows are drawn as skeletons of the right shape.

boolean
loadingRows

How many skeleton rows (cards on phones) to draw while loading: as many as will come. Default 8 rows, 3 cards. Or the rows of the last visit: as many, and on phones each card's values that can be edited wait in their edit box (an `editable` function is asked about each of them).

number | Row[]
onColumnWidths

Called with every width, by column id, after the person resizes one.

((widths: Record<string, number>) => void)
onEdit

Saves one value. Return a promise and the cell shows it is busy; reject it (or throw) and the cell keeps what was typed and shows the reason.

((row: Row, columnId: string, value: unknown) => void | Promise<unknown>)
onFilter ((filters: DataFilters) => void)
onRetry

With `error`: shows «Try again».

(() => void)
onSelect ((selected: Set<RowKey>) => void)
onSort ((sort: DataSort | null) => void)
pageSize

Rows in memory are shown a page at a time (every table paginates). The person can change it. On phones a page holds at most 25 cards.

number 100
pageSizes

The page sizes the person can choose from.

number[] [50, 100, 250, 500]
pagination

Server pages: the table shows `rows` as one page and this bar under them. Without it the table pages the rows in memory itself (`pageSize`).

{ page: number; pageSize: number; total: number; onPage: (page: number) => void; onPageSize?: ((size: number) => void); }
selectable

Adds a checkbox to every row.

boolean
selected

Controlled selection: the keys of the selected rows.

ReadonlySet<RowKey>
server

The rows already arrive sorted and filtered (by a server): the table only reports what the person asked through `onSort` and `onFilter`.

boolean
sort

Controlled sort. Leave it out and the table keeps its own.

DataSort | null
toolbar

Extra content at the start of the toolbar: a search field, a title.

ReactNode
DataTableSkeletonTypeDefault
columns number 5
layout "grid" | "cards" | "auto" auto
pagination boolean true
rows number 8
selectable boolean
toolbar boolean true
  1. 10,000 rows
  2. Edit in place
  3. Select and act on many
  4. As cards
  5. Pages from a server
  6. Loading, error and empty
  7. Skeleton
  8. When to use it
  9. For everyone
  10. Props

    Search pages, sections and terms