Skip to content
nexubDesign System
v12.7.0

Components · Data Display

Data Table

StableAdded v0.0.1 · updated v5.4.0

Feature-rich data table with sorting and row selection powered by TanStack Table.

import { DataTable } from '@nexub/react';
View as Markdown

Playground

Props

NameEmailPlanStatus
Alice Brownalice@example.comProActive
Bob Carterbob@example.comFreePending
Carol Daviscarol@example.comProInactive
Dave Evansdave@example.comEnterpriseActive
TSX
<DataTable columns={columns} data={data} />

Examples

Default

NameEmailPlanStatus
Alice Brownalice@example.comProActive
Bob Carterbob@example.comFreePending
Carol Daviscarol@example.comProInactive
Dave Evansdave@example.comEnterpriseActive

With sorting

Alice Brownalice@example.comProActive
Bob Carterbob@example.comFreePending
Carol Daviscarol@example.comProInactive
Dave Evansdave@example.comEnterpriseActive

Selection, bulk actions and view menu

Select rows with the checkbox column; the bar at the bottom acts on them. The View menu switches density and hides columns.

Invoices
INV-2041AcmeOverdue1200
INV-2042GlobexPaid860
INV-2043InitechDraft430
INV-2044UmbrellaOverdue2150
INV-2045HooliPaid990
2 selected

Resize, reorder and pin

Drag header edges to resize and headers to reorder (or Alt+Arrow). Invoice stays pinned while the rest scroll; the header sticks within `maxHeight`.

Invoices
InvoiceCustomerRegionOwnerStatusAmount
INV-2041AcmeEMEAAnaPaid400
INV-2042GlobexAPACBenOverdue537
INV-2043InitechAmericasChenDraft674
INV-2044UmbrellaEMEADevPaid811
INV-2045HooliAPACAnaOverdue948
INV-2046AcmeAmericasBenDraft1085
INV-2047GlobexEMEAChenPaid1222
INV-2048InitechAPACDevOverdue1359
INV-2049UmbrellaAmericasAnaDraft1496
INV-2050HooliEMEABenPaid1633
INV-2051AcmeAPACChenOverdue1770
INV-2052GlobexAmericasDevDraft1907
INV-2053InitechEMEAAnaPaid2044
INV-2054UmbrellaAPACBenOverdue2181
INV-2055HooliAmericasChenDraft2318
INV-2056AcmeEMEADevPaid455
INV-2057GlobexAPACAnaOverdue592
INV-2058InitechAmericasBenDraft729
INV-2059UmbrellaEMEAChenPaid866
INV-2060HooliAPACDevOverdue1003
INV-2061AcmeAmericasAnaDraft1140
INV-2062GlobexEMEABenPaid1277
INV-2063InitechAPACChenOverdue1414
INV-2064UmbrellaAmericasDevDraft1551
INV-2065HooliEMEAAnaPaid1688
INV-2066AcmeAPACBenOverdue1825
INV-2067GlobexAmericasChenDraft1962
INV-2068InitechEMEADevPaid2099
INV-2069UmbrellaAPACAnaOverdue2236
INV-2070HooliAmericasBenDraft2373

10,000 rows (DataTableVirtual)

`import { DataTableVirtual } from '@nexub/react/DataTableVirtual'` and install `@tanstack/react-virtual`. Only the rows in view are rendered.

Audit log
1sign_inuser0@example.com2026-11-01 00:00
2exportuser940@example.com2026-11-01 00:01
3inviteuser883@example.com2026-11-01 00:02
4upgradeuser826@example.com2026-11-01 00:03
5sign_inuser769@example.com2026-11-01 00:04
6exportuser712@example.com2026-11-01 00:05
7inviteuser655@example.com2026-11-01 00:06
8upgradeuser598@example.com2026-11-01 00:07
9sign_inuser541@example.com2026-11-01 00:08
10exportuser484@example.com2026-11-01 00:09
11inviteuser427@example.com2026-11-01 00:10
12upgradeuser370@example.com2026-11-01 00:11
13sign_inuser313@example.com2026-11-01 00:12
14exportuser256@example.com2026-11-01 00:13
15inviteuser199@example.com2026-11-01 00:14
16upgradeuser142@example.com2026-11-01 00:15

Tree rows

`getSubRows` nests rows: the first column gets an expand toggle and indents each level. With pages, a parent and its children stay on one page.

Accounts by region
AccountOwnerARR
Acme Group
Ada$420,000
Acme EU
Grace$180,000
Acme US
Alan$240,000
Globex
Linus$95,000

Export CSV

`toCSV(rows, columns)` quotes and escapes per RFC 4180 and neutralises cells that start like a spreadsheet formula. Pass what the person sees.

Invoices
InvoiceCustomerAmount
INV-1042Acme, Inc.1200
INV-1043Globex860

`footer` on a column adds a totals row; a render function gets the table, so a sum can follow the filtered rows. `meta.filter` (`text`, `select` or `number-range`) adds a filter button to the header. Control it with `columnFilters` / `onColumnFiltersChange`; `manualFiltering` leaves the rows to the server.

Invoices
Customer
Status
Amount
AcmePaid$1,200
GlobexDue$860
InitechPaid$430
UmbrellaOverdue$2,150
Total$4,640

Streaming rows

Set `streaming` while an agent produces rows and pass `data` as it grows. The table stays usable: sort or select while rows arrive. Screen readers hear "busy", a count every few seconds and "Done" at the end. Announcements come from `rowsSoFar` and `rowsDone` in messages.

Leads
AcmeManufacturing120
GlobexEnergy85

States

  • NameEmailPlanStatus
    Alice Brownalice@example.comProActive
    Bob Carterbob@example.comFreePending
    Carol Daviscarol@example.comProInactive
    Dave Evansdave@example.comEnterpriseActive
    default
  • NameEmailPlanStatus
    loading

Props

Props
PropTypeDefaultDescription
columnsrequiredDataTableColumn<TData>[]—TanStack Table column definitions (DataTableColumn is exported from @nexub/react). Set meta: { align: 'end' } for numeric columns; headers, sort buttons and cells follow it.
datarequiredTData[]—Array of row data objects to render.
getSubRows((row: TData, index: number) => TData[])—Nested rows (a tree table). The first column gets an expand toggle (aria-expanded) and indents each level; sorting sorts within each level.
expandedExpandedState—Expanded rows by row id (see getRowId), or true for all.
defaultExpandedExpandedState—Expanded rows by row id (see getRowId), or true for all.
onExpandedChange((expanded: ExpandedState) => void)—Expanded rows by row id (see getRowId), or true for all.
onRowOrderChange((data: TData[]) => void)—Adds a handle column: drag rows, or Alt+ArrowUp/Down on a handle. Hidden while a column is sorted.
getRowLabel((row: TData) => string)its positionNames a row in "Move ‹label›" and the move announcements.
captionReact.ReactNode—Names the table for assistive tech (and its scroll region). Shown below the table; add captionHidden to keep it screen-reader only.
enableSortingbooleanfalseClick a header to sort; Shift+click adds more columns, numbered 1, 2… (5.3).
enableRowSelectionbooleanfalseTurns on row selection state.
selectionColumnbooleantrueWith enableRowSelection: a checkbox column, select-page in its header, and "Select all N" across pages (on by default from 6.0). false keeps selection without the column.
rowSelectionRowSelectionState—Controlled selection keyed by row id (5.3).
onRowSelectionChange((selection: RowSelectionState) => void)—Controlled selection keyed by row id (5.3).
getRowId((row: TData, index: number) => string)—Stable row ids for selection; defaults to the row index (5.3).
bulkActions((rows: TData[], clear: () => void) => React.ReactNode)—A floating bar while rows are selected, with the count, your actions and a clear button (5.3).
density'comfortable' | 'compact'—Row height (5.3).
defaultDensity'comfortable' | 'compact''comfortable'Row height (5.3).
onDensityChange((density: DataTableDensity) => void)—Row height (5.3).
columnVisibilityVisibilityState—Which columns show, keyed by column id (5.3).
onColumnVisibilityChange((visibility: VisibilityState) => void)—Which columns show, keyed by column id (5.3).
viewOptionsbooleanfalseA "View" menu above the table for density and column visibility (5.3).
toolbarReact.ReactNode—Content at the start of the row above the table, e.g. filters (5.3).
enableColumnResizingbooleanfalseDrag a header edge to resize (5.4). The handle is focusable: Arrow keys resize by 16px, double-click resets.
columnSizingColumnSizingState—Column widths in px, keyed by column id (5.4).
onColumnSizingChange((sizing: ColumnSizingState) => void)—Column widths in px, keyed by column id (5.4).
enableColumnReorderingbooleanfalseDrag headers to reorder, or Alt+Arrow on a focused header; the move is announced (5.4).
columnOrderColumnOrderState—Column ids in display order (5.4).
onColumnOrderChange((order: ColumnOrderState) => void)—Column ids in display order (5.4).
columnPinningColumnPinningState—Columns that stay in view while the rest scroll sideways (5.4). The selection column pins with them.
onColumnPinningChange((pinning: ColumnPinningState) => void)—Columns that stay in view while the rest scroll sideways (5.4). The selection column pins with them.
maxHeightstring | number—Caps the height: rows scroll and the header sticks (5.4).
gridbooleanfalseARIA grid keyboard model for tables whose cells hold actions (5.8): the table is one tab stop; Arrow keys move between cells and the controls in them, Home/End to the row ends, Ctrl+Home/End to the corners.
DataTableVirtualimport from '@nexub/react/DataTableVirtual'—Same props plus maxHeight (required), estimateRowHeight and overscan: renders only the rows in view, for thousands of rows. Needs @tanstack/react-virtual installed (5.4). No pagination.
streamingbooleanfalseRows are still arriving, e.g. from an agent (12.4). A skeleton row trails the last row, aria-busy is set, the row count is announced every few seconds (not per row) and "done" when it turns off. New rows enter with the motion preset; sorting and selection keep working.
pagination.pageSizenumber20Rows per page; pagination is on when pagination is set.
captionHiddenbooleanfalseKeep the caption for screen readers only.
columnFiltersColumnFiltersState—Column filters, for columns that set meta.filter: [{ id: 'status', value: ['Active'] }]. Changing a filter goes back to the first page.
defaultColumnFiltersColumnFiltersState—
emptyStateReact.ReactNodemessages.noResultsShown in a full-width row when there are no rows.
errorStateReact.ReactNode—Shown in a full-width row when a load failed, e.g. <ErrorState title="…" onRetry={…} />. Wins over loading and empty.
loadingbooleanfalseShows skeleton rows (one page's worth) and sets aria-busy on the table.
manualFilteringbooleanfalseRows arrive filtered (server-side): the headers still edit columnFilters, but rows aren't filtered here.
manualPaginationbooleanfalsedata is the current page only (server-side); set rowCount for the page count. Turns pagination on.
manualSortbooleanfalseRows arrive sorted (server-side): headers still toggle sort, but rows aren't reordered.
onColumnFiltersChange((filters: DataTableColumnFilters) => void)—
onPageChange((page: number) => void)—
onSortChange((sort: SortingState) => void)—
pagenumber—Controlled page, zero-based. Turns pagination on.
pageSizenumber20Rows per page; overrides pagination.pageSize. Turns pagination on.
pagination{ pageSize?: number; }—
rowCountnumber—Total rows across all pages, with manualPagination.
rowWindowDataTableRowWindowHook—Rows to render; set by DataTableVirtual.
sortSortingState—Controlled sort (with enableSorting): [{ id: 'name', desc: false }].

Design tokens

Data Table reads these component tokens. Each one is unset by default and falls back to the semantic role it aliases, so nothing changes until you set it. Set one on any element to restyle every Data Table below it, and leave the roles other components share alone. See the three token tiers.

Data Table design tokens
TokenAliasesNotes
--table-head-bgtransparentDefault: transparent
--table-head-fg--color-on-surface-muted—
--table-border--color-outline-variantRow rules.
CSS
/* One area of your app */
.checkout {
  --table-head-bg: var(--color-secondary);
}

Accessibility

ARIA roles

table (default)grid (with `grid`)columnheader with aria-sort when sortable

Keyboard

  • Tab

    Without `grid`: every control in the table is a tab stop. With `grid`: the table is one tab stop and remembers the last cell.

  • Arrow keys

    With `grid`: move between cells, and between the controls inside a cell. Mirrored in RTL.

  • Home / End

    With `grid`: first or last cell in the row. Ctrl+Home / Ctrl+End: first or last cell in the grid.

  • Space

    Toggles a focused row checkbox.

  • Alt+Arrow

    Moves a focused header when `enableColumnReordering` is on.

Focus

  • With `grid`, focus goes to a cell’s first control, or to the cell itself when it has none.

Screen reader

  • Name the table with `caption` (or `aria-label`); `captionHidden` keeps it for screen readers only.

  • Sorting, selection counts and column moves are announced from a polite live region.

  • 12.4 `streaming`: the table is aria-busy, the skeleton tail row is hidden from assistive tech, and the polite region announces the row count at most every 3 seconds, then "Done. N rows".

  • DataTableVirtual sets aria-rowcount and aria-rowindex so readers report the full row count.

Notes

  • Use `grid` when rows hold actions (edit, menus); plain tables of text read better as a table.