Components · Data Display
Data Table
Feature-rich data table with sorting and row selection powered by TanStack Table.
import { DataTable } from '@nexub/react';Playground
Props
| Name | Plan | Status | |
|---|---|---|---|
| Alice Brown | alice@example.com | Pro | Active |
| Bob Carter | bob@example.com | Free | Pending |
| Carol Davis | carol@example.com | Pro | Inactive |
| Dave Evans | dave@example.com | Enterprise | Active |
<DataTable columns={columns} data={data} />Examples
Default
With sorting
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.
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`.
10,000 rows (DataTableVirtual)
`import { DataTableVirtual } from '@nexub/react/DataTableVirtual'` and install `@tanstack/react-virtual`. Only the rows in view are rendered.
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.
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.
Footer and column filters
`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.
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.
States
Name Email Plan Status Alice Brown alice@example.com Pro Active Bob Carter bob@example.com Free Pending Carol Davis carol@example.com Pro Inactive Dave Evans dave@example.com Enterprise Active defaultName Email Plan Status loading
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| columnsrequired | DataTableColumn<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. |
| datarequired | TData[] | — | 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. |
| expanded | ExpandedState | — | Expanded rows by row id (see getRowId), or true for all. |
| defaultExpanded | ExpandedState | — | 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 position | Names a row in "Move ‹label›" and the move announcements. |
| caption | React.ReactNode | — | Names the table for assistive tech (and its scroll region). Shown below the table; add captionHidden to keep it screen-reader only. |
| enableSorting | boolean | false | Click a header to sort; Shift+click adds more columns, numbered 1, 2… (5.3). |
| enableRowSelection | boolean | false | Turns on row selection state. |
| selectionColumn | boolean | true | With 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. |
| rowSelection | RowSelectionState | — | 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). |
| columnVisibility | VisibilityState | — | Which columns show, keyed by column id (5.3). |
| onColumnVisibilityChange | ((visibility: VisibilityState) => void) | — | Which columns show, keyed by column id (5.3). |
| viewOptions | boolean | false | A "View" menu above the table for density and column visibility (5.3). |
| toolbar | React.ReactNode | — | Content at the start of the row above the table, e.g. filters (5.3). |
| enableColumnResizing | boolean | false | Drag a header edge to resize (5.4). The handle is focusable: Arrow keys resize by 16px, double-click resets. |
| columnSizing | ColumnSizingState | — | Column widths in px, keyed by column id (5.4). |
| onColumnSizingChange | ((sizing: ColumnSizingState) => void) | — | Column widths in px, keyed by column id (5.4). |
| enableColumnReordering | boolean | false | Drag headers to reorder, or Alt+Arrow on a focused header; the move is announced (5.4). |
| columnOrder | ColumnOrderState | — | Column ids in display order (5.4). |
| onColumnOrderChange | ((order: ColumnOrderState) => void) | — | Column ids in display order (5.4). |
| columnPinning | ColumnPinningState | — | 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. |
| maxHeight | string | number | — | Caps the height: rows scroll and the header sticks (5.4). |
| grid | boolean | false | ARIA 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. |
| DataTableVirtual | import 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. |
| streaming | boolean | false | Rows 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.pageSize | number | 20 | Rows per page; pagination is on when pagination is set. |
| captionHidden | boolean | false | Keep the caption for screen readers only. |
| columnFilters | ColumnFiltersState | — | Column filters, for columns that set meta.filter: [{ id: 'status', value: ['Active'] }]. Changing a filter goes back to the first page. |
| defaultColumnFilters | ColumnFiltersState | — | |
| emptyState | React.ReactNode | messages.noResults | Shown in a full-width row when there are no rows. |
| errorState | React.ReactNode | — | Shown in a full-width row when a load failed, e.g. <ErrorState title="…" onRetry={…} />. Wins over loading and empty. |
| loading | boolean | false | Shows skeleton rows (one page's worth) and sets aria-busy on the table. |
| manualFiltering | boolean | false | Rows arrive filtered (server-side): the headers still edit columnFilters, but rows aren't filtered here. |
| manualPagination | boolean | false | data is the current page only (server-side); set rowCount for the page count. Turns pagination on. |
| manualSort | boolean | false | Rows 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) | — | |
| page | number | — | Controlled page, zero-based. Turns pagination on. |
| pageSize | number | 20 | Rows per page; overrides pagination.pageSize. Turns pagination on. |
| pagination | { pageSize?: number; } | — | |
| rowCount | number | — | Total rows across all pages, with manualPagination. |
| rowWindow | DataTableRowWindowHook | — | Rows to render; set by DataTableVirtual. |
| sort | SortingState | — | 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.
| Token | Aliases | Notes |
|---|---|---|
| --table-head-bg | transparent | Default: transparent |
| --table-head-fg | --color-on-surface-muted | — |
| --table-border | --color-outline-variant | Row rules. |
/* One area of your app */
.checkout {
--table-head-bg: var(--color-secondary);
}Accessibility
ARIA roles
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.
On iOS & Android: DataList
import { DataList } from '@nexub/react-native';
<DataList data={invoices} keyExtractor={(i) => i.id} title={(i) => i.customer} value={(i) => i.total} sorts={sorts} selectable />
<DataList data={rows} keyExtractor={(r) => r.id} title={(r) => r.name} streaming={agentRunning} />Web vs mobile
Same tokens and prop names. Where the platforms differ:
| Web | iOS & Android | |
|---|---|---|
| Layout | Columns: resize, reorder, pin, virtualize. | One row per record with its key fields: no horizontal scrolling. |
| Sort | Click headers; Shift+click for more. | A Sort button opens a sheet: one sort and a direction. |
| Selection | Checkbox column and a floating bulk bar. | Checkbox rows; the bar above the list shows the count and your actions. |
| Streaming | A skeleton row, aria-busy and a polite live region. | The same streaming prop (12.5): a skeleton row, a busy list, and the count announced at most every 3 seconds, then "Done. N rows". |
Interactive preview of @nexub/react-native rendered for the web. Native chrome (switches, pickers, Liquid Glass) looks like the platform on a device.
On device

iPhone (iOS simulator)

Pixel (Android emulator)
Screenshots from the latest CI run of the showcase app; the live frame renders the same code for the web.
DataList props
| Prop | Type | Default | Description |
|---|---|---|---|
| datarequired | readonly T[] | — | — |
| keyExtractorrequired | (item: T) => string | — | — |
| titlerequired | (item: T) => string | — | — |
| subtitle | (item: T) => string | undefined | — | — |
| value | (item: T) => string | undefined | — | Trailing key value, e.g. an amount or status. |
| leading | (item: T) => React.ReactNode | — | — |
| onPressItem | (item: T) => void | — | — |
| sorts | DataListSort<T>[] | — | Sort choices; a Sort button opens them in a sheet. |
| sort | { id: string; desc: boolean } | — | — |
| defaultSort | { id: string; desc: boolean } | — | — |
| onSortChange | (sort: { id: string; desc: boolean }) => void | — | — |
| selectable | boolean | — | Checkbox rows; the selection bar shows bulkActions while rows are selected. |
| selected | string[] | — | — |
| onSelectedChange | (keys: string[]) => void | — | — |
| bulkActions | (keys: string[], clear: () => void) => React.ReactNode | — | — |
| empty | React.ReactNode | — | Shown when data is empty. |
| streaming | boolean | false | 12.5: rows can keep arriving (an agent is producing the data). A skeleton row trails the last
row (hidden from screen readers), the list is busy, the row count is announced at most every
3 seconds and "Done. N rows" when streaming turns off. Rows that arrive meanwhile fade in
(instant under Reduce Motion). Before the first row, the skeleton row shows instead of empty. |
| style | StyleProp<ViewStyle> | — | — |