Data grid
A React component in Beamline's Data & tables category.
Virtualised local or server-driven grid: stable row IDs, manual sort and filters, pages or infinite loading, retry without losing rows, inline editing and keyboard navigation.
Use it for
- Any list a person works through: CRM records, orders, users, logs.
- More than ~50 rows, or when people sort, filter, select or edit.
Not for
- A handful of static rows in a card → table.
- Trading positions with live PnL → positions-table.
- Records summed up by fields chosen in rows and columns (pivot-table).
Anatomy
- toolbar (a size container: search on its own line when narrow, beside the filter chips from 28rem; filter chips, selection count, actions)
- header (select-all, #, column headers with sort, pin, resize)
- virtualised rows (select, #, cells); a numeric height is fitted to whole rows so the last row in view ends at the footer
- footer aggregates
- loading skeleton
- empty state (kept in view at the viewport's width however wide the columns run)
- quiet pending status above retained rows; retry action beside errors
- pagination below the grid, or an end-of-list loading row
- explicit select-all-matching action, separate from loaded-row selection
Variants
- density: compact 28, default 36, comfortable 44
- toolbar: on, off
- rowNumbers: on, off
- dataMode: local (default), manual (server owns sort, filters, search and pagination)
States
- loading (8 skeleton rows of the real row height, one bar per column; toolbar stays usable; the pulse stops with reduced motion)
- empty (emptyLabel centred in the body, header kept)
- error (red-tinted status band under the toolbar with a glyph, the caller's words and retry; last rows kept)
- filtered (search and value filters; controlled or not; Reset clears both and calls onFiltersChange({}) and onQueryChange(""))
- sorted (multi, with order index)
- selected (checkbox + accent tint + ink text)
- editing (editor on the field role in its focus state)
- pinned (filled pin at rest; outline pin previews on header hover or focus)
- scrolled (the last pinned column casts a logical edge shadow, also in RTL)
- unmeasured (null cells show — and read "Not measured")
- narrow (the grid under 30rem: row numbers fold away and a pinned column takes at most 40 % of the width, so the columns that scroll keep a readable share)
- pending: loading with previous rows retains them; skeletons only before the first result
- loadingMore: appending rows never hides existing rows; hasMore=false stops requests
- page: one-based page, pageSize and known rowCount (null is unknown) with controlled and uncontrolled forms
Keyboard
- role=grid, one tab stop among cells; child checkboxes and buttons keep their own Space / Enter actions
- Arrows move between cells, Home/End row edges, Ctrl+Home/End grid edges, PageUp/Down
- Enter or F2 edits an editable cell; typing starts an edit with that character
- Enter commits, Esc cancels, Tab commits and moves
- Space toggles the row, Shift+Space extends the range, Ctrl/⌘+A selects all visible
- Focus header with ArrowUp from the first row; Shift+F10 opens sort/pin/reset actions; resize separator arrows change 16px (Shift 64px), Home/Enter reset.
- ArrowDown on the last row requests the next page; focus lands on the first row in the same column after success. PageUp across the first row requests the previous page and focuses its last row. Pending requests never move focus to unrelated content.
Motion
On a sort or filter, rows that stay on screen slide to their new places (320 ms, no overshoot; instant with reduced motion). The sort arrow turns over between ascending and descending (--pui-duration-morph) instead of being swapped. Resize and pin are immediate; hover and selection change only the row's tint.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
data (required) | T[] | — | |
columns (required) | DataGridColumn<T>[] | — | id, header, value?, type (text|number|currency|percent|date|tags|status), width, pinned, sortable, filterable, editable, aggregate, format, aggregateFormat (the footer aggregate in the column's own words, e.g. 13.0 min; format needs a row), cell, tones |
getRowId (required) | (row) => string | — | |
onCellEdit | (rowId, columnId, value) => void | — | Called with the edited value (already parsed for number columns). Update your data to commit it. |
actions | (selectedIds, {hidden: string[], rowIds: string[]}) => ReactNode | — | Content at the end of the toolbar: bulk actions, export, add. |
density | 'compact'|'default'|'comfortable' | — | |
height | number | 'fill' | 480 | The most the grid grows to before its rows scroll (a few rows take only their own height; a loading or empty grid keeps all of it, so the box does not jump when the data lands), or "fill" for its container's height. |
loading / emptyLabel / rowNumbers / toolbar / footer / onRowClick | … | — | |
columns[].nullLabel | string | — | columns[].nullLabel: Label for missing cells and numeric aggregate coverage. |
columns[].currency | string | — | columns[].currency: ISO 4217 code for a currency column, used by its cells and footer. Default USD. |
columns[].grow | boolean | — | columns[].grow: Takes the room left over when the columns are narrower than the grid, so a wide grid has no empty band at its end. Default: the widest text column, else the last column; `false` keeps this column at its width. |
selectionLabel | (selected: string[], hidden: string[]) => ReactNode | — | Replaces the toolbar's “N selected · M not shown” line (hidden selected IDs included). |
located | string | — | Row to mark as located (aria-current) and bring into view inside the grid, e.g. on return from its detail. |
onViewChange | (rowIds: string[]) => void | — | IDs in view after search, filters and sort, whenever they change. |
manual | boolean | false | Server owns sort, search, filters and page slicing. Default false. |
pagination | boolean | — | Enable page controls explicitly. Page-related props also enable them, unless onEndReached is supplied. |
rowCount | number | null | — | Total matching rows on the server. null means unknown. Local grids calculate it before slicing. |
onEndReached / hasMore / loadingMore | (() => void | Promise<unknown>) / boolean / boolean | — | onEndReached: Append mode: fetch another batch. The app appends it to the supplied rows. hasMore: Whether another batch exists; defaults to true with onEndReached. False stops requests. loadingMore: An append request is pending; retain every loaded row. |
onRetry | (() => void | Promise<unknown>) | — | Retry the caller-owned failed request. |
columns[].filterValues | string[] | — | columns[].filterValues: Distinct server values, including options absent from the loaded page. |
allowSelectAllMatching / onSelectAllMatching | boolean / (scope: {rowCount: number; query: string; filters: Record<string,string[]>}) => void | — | Explicit opt-in action asks the app to select the entire matching result on the server. Does not manufacture row IDs or change selected. The app owns the query-scoped bulk operation and its confirmation; checkboxes and Ctrl+A select only loaded/visible IDs. |
allowSelectAllMatching | boolean | — | Explicit server-wide selection request; loaded-row checkboxes still use IDs only. |
onSelectAllMatching | ((scope: { rowCount: number; query: string; filters: Record<string, string[]>; }) => void) | — | |
selected | string[] | — | Row selection (controlled or not). |
defaultSelected | string[] | — | |
onSelectedChange | ((ids: string[]) => void) | — | |
selectable | boolean | — | |
sort | ListSort | — | |
defaultSort | ListSort | — | |
onSortChange | ((sort: ListSort) => void) | — | |
filters | Record<string, string[]> | — | Value filters by column id (controlled or not): the chosen values of that column; an empty array or no key means no filter. A key for a column without `filterable` still filters but shows no chip; an unknown column id is ignored. |
defaultFilters | Record<string, string[]> | — | |
onFiltersChange | ((filters: Record<string, string[]>) => void) | — | |
query | string | — | Toolbar search text (controlled or not). Reset clears it together with the filters. |
defaultQuery | string | — | |
onQueryChange | ((query: string) => void) | — | |
toolbar | boolean | — | Toolbar with search and filter chips. |
rowNumbers | boolean | — | |
rowHeight | number | — | Explicit fixed row geometry beats density and scoped CSS metrics. |
headerHeight | number | — | |
footerHeight | number | — | |
footer | boolean | — | |
loading | boolean | — | |
error | ReactNode | Error | — | Caller-owned load error; existing rows and drafts remain available. |
emptyLabel | string | — | |
onRowClick | ((row: T) => void) | — | |
label | string | — | |
className | string | — | Classes on the documented visual root; no override by default. |
style | CSSProperties | — | Inline styles on the documented visual root; no overrides by default. |
classNames | Partial<Record<"root" | "header" | "empty" | "filter" | "footer" | "search" | "cell" | … | — | Classes for the named visual parts; no overrides by default. |
ref | Ref<HTMLDivElement> | — | Receives the documented native target or imperative handle; omitted by default. |
page | number | — | One-based requested page. Default 1. |
defaultPage | number | — | |
onPageChange | ((page: number) => void) | — | |
pageSize | number | — | Positive rows per page. Default 25. |
defaultPageSize | number | — | |
onPageSizeChange | ((pageSize: number) => void) | — | |
onEndReached | (() => void | Promise<unknown>) | — | Append mode: fetch another batch. The app appends it to the supplied rows. |
hasMore | boolean | — | Whether another batch exists; defaults to true with onEndReached. False stops requests. |
loadingMore | boolean | — | An append request is pending; retain every loaded row. |
total | number | null | — | Deprecated: Use rowCount. Canonical rowCount wins, including null. |
columns[].hint | string | — | columns[].hint: Explains this column in its header tooltip, alongside the sorting instructions. |
aggregateChoice | boolean | — | Let the person choose each column's footer calculation from its footer cell: sum, average, min and max for number columns, filled, empty and unique counts for any column. The footer says which rows the totals cover (all, the matching ones, or only the loaded ones when rows come from a server). Off by default: only `aggregate` columns total, as before. |
aggregates | Record<string, Aggregate | null> | — | The chosen calculation per column id (null: none); controlled, or `defaultAggregates`. Starts from each column's `aggregate`. |
defaultAggregates | Record<string, Aggregate | null> | — | |
onAggregatesChange | ((aggregates: Record<string, Aggregate | null>) => void) | — | |
serverTotals | Record<string, string> | — | With `aggregateChoice`: totals the app has for every row (from its server), said in the footer's first cell apart from the loaded rows' own: column id → text ("5,471,339"). |
columnChooser | boolean | — | A Columns button in the toolbar: each column shown or hidden, and moved earlier or later, so an app can keep a person's own view. Off by default (the grid shows `columns` as given). |
columnOrder | string[] | — | Column ids in the order shown; ids left out keep their place after the listed ones. |
defaultColumnOrder | string[] | — | |
onColumnOrderChange | ((order: string[]) => void) | — | |
hiddenColumns | string[] | — | Column ids not shown (their filters still apply). |
defaultHiddenColumns | string[] | — | |
onHiddenColumnsChange | ((hidden: string[]) => void) | — |
Built from
- Bottom sheet
- Button
- Checkbox
- Context menu
- Dropdown menu
- Glow
- Kbd
- Label
- Pagination
- Popover
- Search field
- Select
- Spinner
- Tooltip
Used in
- Action center
- Admin users
- Agent runs monitor
- Bulk item edit
- Change orders
- Collection batch edit
- CRM pipeline
- Hiring pipeline
- Invoices
- Market screener
- Order history and fills
- Orders admin
- Portfolio overview
- Return queue
- Submittal register
- Workflow builder
Dependencies
@tanstack/react-virtual, lucide-react
Import
import { DataGrid } from "@beamline/data-grid";
Get it
Data grid is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Get Beamline · Connect your agent
More in Data & tables
- Living table: A table that shows as much as fits on both axes: width decides which columns show (the rest ride in the name line, moving there rather than vanishing)…
- Availability layers: A week of bookable start times whose closed times explain themselves: every availability rule (hours, time off, bookings, buffers, rooms, lead time…
- Capacity terrain: A schedule that stands on a terrain of capacity: under each station's lane of jobs, every day's load rises to its capacity line and an overload is a…
- Domino move: A room board where one move shows its chain: drag a booking (or pick it and aim it with the keys) onto a taken room and the bookings it would push appear…
- Match board: Month-end matching as one picture: bank lines and books entries side by side with threads between them — solid for matched, dashed with the host's reason…
- Split anything: One splitter for money, quantities and time: a bar of the whole shows every target's part and what is not split yet; items are dragged onto targets…
- Approval route: A policy you can read by trying it: an amount on a log scale with the thresholds as marks (the arrows stop just under, at and just over each), the…
- Proposal twin: A proposal edited beside the client's exact page, the two linked both ways: a field in focus lights its twin on the page, scrolls it into view and joins…
- Quantity river: The life of one order line's quantity: at rest a bar of its real split ("5 delivered · 1 back in stock · 1 damaged · 5 cancelled"), unfolding into a…
- Stock horizon: Projected stock per item over the coming weeks: a strip of weeks with the safety line, weeks under safety in warn and short in danger, every dip said in…
- Ageing queue: Tickets that visibly age: each ticket's ring fills toward its own service target and steps from on time to late to very late, the words say when it is…
- Import lens: A messy import made fixable by kind: rows stream through the checks once with live counts; problems gather into groups that say what is wrong in words…
- Duplicate guard: A new record that watches for the one that already exists: as you type, the likely duplicates slide in beside the form with the fields that match lit and…
- Scan flow: A pick list that takes scans: each scan flies from the scan field into its row and fills that row's quantity ring, and the prompt moves to the next bin…
- Pack planner: The packing bench: the order's items sit in box outlines drawn to scale, each box filling to its padding line, weighing against its limit and naming the…
- Provenance lens: Hold Alt (or press Lens) over any number on the page and see what makes it: hairline threads draw from the number to the rows, cards and documents on…
- Record time machine: The record itself, rewound in place: a slim track of every change (a tick per change in its person's colour, hollow for automation, named moments as…
- Tension timeline: A plan where slack is something you see: every dependency is a string from one task's end to the next one's start, sagging with the days it has to spare…
- Replay bar: Rewind for anything live: pause a stream, scrub back to the moment you missed (markers for the ones that matter), step one update at a time, replay at a…
- Event calendar: A schedule of events by day, week or month: events that overlap sit side by side, drag one to another time or day or pull its bottom edge to change its…
- Kanban board: Work as cards in columns by stage: drag a card (or lift it with Space and walk it with the arrows) to another column or place, the cards around it make…
- Pivot table: Records summed up by the fields people choose: rows grouped by one or more fields that fold open level by level, columns split by another, one or more…
- Query builder: Conditions people build by hand to pick out records: each rule is a field, an operator that fits the field (contains, between, in the last N days, is any…
- Sort order: Several sort keys in order. Each key says its rank in words ("Sort by Plan, A to Z", "then by Size, largest first") with its order named for the field's…
- Metric rules: Ordered rules that colour a dashboard number. Each rule has a name for what its colour means ("At risk", not just red) and a tone (good, watch, act…
- Log viewer: Log lines as they stream: it follows the newest line until you scroll up, then counts what arrived and brings you back in one click; filter by level with…
- JSON viewer: A JSON value as a tree you can read and walk: branches open and close (one level, or all at once), closed ones preview what they hold, every value reads…
- JSON diff viewer: Two versions of a JSON value compared as one tree: added keys marked +, removed ones struck through with −, changed values read old → new, unchanged keys…
- Import mapping: Map the columns of a file to the fields of one record type, see what every value becomes, then run the import and get an outcome for each row…
- Diff table: Proposed edits to a table before they happen: new rows green, removals struck through, changed cells old → new; each change can be left out and Apply…
- Filter toolbar: The filters on a list kept in view: chips that remove themselves, Add filter with fields and their values, Clear all, and room for search or view controls.
- Table: A native HTML table for small datasets, composed with children or driven by records; shared server paging, sorting, filters, search, stable-ID selection…