Data grid
ProSpreadsheet-style editing, virtualized both ways, with typed editors, validation, keyboard ranges, and copy and paste. Not an M3 component (@windmorph/react-pro).
import { DataGrid } from '@windmorph/react-pro/data-grid';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Props
DataGrid 32 props
The columns.
Every row; only those in view are rendered.
A row's unique id.
Reads a cell's value.
Whether cells can be edited, unless a column says otherwise.
A cell's semantic state, with the label that keeps colour from being alone.
Content of a row header column, joined to the grid's movement; Enter reaches its controls.
Rows of totals the app worked out, kept at the bottom.
The selected range (controlled).
The range selected at first (uncontrolled).
A row's height at density 0, px.
The scrolling area's height.
Rows and columns rendered beyond those in view.
The grid's own density.
Shows loading rows.
Shown when there are no rows.
A message to show in place of the rows.
Replaces icons.
Ref to the outermost element.
The outermost element's id.
Events
Called when a cell's value is committed and valid.
Called when the selected range changes.
May reject a paste (
false) or return the changes to apply instead.Adds a retry button to the error.
Text
Words it shows or announces. A
LabelsProvidersets them for the whole app.Names a cell’s editor.
Given for text that isn’t a number, or is outside the limits.
Given when a column's
validatereturnsfalse.Names a cell’s state icon.
Announced after a paste.
Names the column of row headers, for assistive technology.
Announced when
onPasterejects a paste.Names the loading state.
The empty state’s title.
The error state’s button.
One of
aria-labeloraria-labelledbyis required.One of
aria-labeloraria-labelledbyis required.The id of an element that describes it.
The id of an element with more detail about it.
Classes for the outermost element. Wins over the defaults via
cn().Classes for each part.
The grid inside the scrolling area.
What holds the loading rows.
Each placeholder row while loading.
The text in a cell or header cell.
The group of summary rows.
The icon beside a cell with a state.
The outermost element.
The area that scrolls.
The header group.
The header’s row.
Each column header.
Each row header cell.
The rows’ group.
Each row.
Each cell.
A cell’s editor.
The icon on an invalid cell.
Each summary row.
Each summary cell.
The message below the grid for the active cell.
The loading state.
The empty state.
The error state.
Inline styles for the outermost element.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
Types
DataGridColumn 24 fields
A column of a DataGrid: DataTable's column definition, plus editing and pinning.
Width, px. The grid renders only the rows in view, so it has no
'fit': it can't measure the rest.How the column is edited.
Returns a message when a value isn't acceptable, or
falseforlabels.invalidValue.Whether its cells can be edited.
Keeps the column in view at the grid's start or end.
With
type="currency", the ISO 4217 code.Unique within the table.
Shown above the column and in column settings. Never empty: screen readers name it.
The value used to sort, search, filter and display by default.
Custom cell content.
Formats the value when there is no
cell, right-aligning numbers.Replaces the
type's formatting.Alignment of the header and cells.
Least width, px.
Greatest width, px.
Shares the table's spare width in proportion to its
width.Announced with each row.
Whether a press on the header sorts.
Whether people can hide it.
Whether people can pin it.
Whether people can reorder it.
Whether people can resize it.
How people filter it, if they can.
Whether search reads it.
DataGridSelection 2 fields
A selected range of cells.
Where the range started.
Where the range ends.
DataGridCellChange 4 fields
A cell's changed value, as DataGrid's onCellChange reports it.
The row.
The row’s id.
The column’s
id.The new value.
DataGridCellState 2 fields
A cell's state: never colour alone, so it carries a label.
changed,warning,error,info, or an app's own name (data-state).Says what the state means, to people and to assistive technology.
DataGridSummaryRow 3 fields
A row of totals the app worked out; the grid never computes.
Spec status
Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.
Theming & tokens
Set the tokens below on the grid or any ancestor. Its editors are the core's fields, which keep their own tokens. Style each part with classNames: root, scroller, header, headerRow, headerCell, rowHeaderCell, body, row, cell, editor, invalidIcon, summaryRow, summaryCell, status, loading, empty, error.
| Variable | Default | Paints |
|---|---|---|
--wm-data-grid-container-color | var(--md-sys-color-surface) | The grid’s surface, and a cell at rest. |
--wm-data-grid-container-shape | var(--md-sys-shape-corner-medium) | The scrolling area’s corners. |
--wm-data-grid-outline-color | var(--md-sys-color-outline-variant) | The line around the scrolling area. |
--wm-data-grid-header-height | 56px | The header’s height at density 0; each density step takes 4px off. |
--wm-data-grid-header-color | var(--md-sys-color-surface-container) | The header’s surface. |
--wm-data-grid-header-text-color | var(--md-sys-color-on-surface-variant) | The header’s text. |
--wm-data-grid-row-height | 48px | A row’s height at density 0; each density step takes 4px off. |
--wm-data-grid-row-text-color | var(--md-sys-color-on-surface) | A cell’s text. |
--wm-data-grid-row-header-width | 64px | The width of the row header column. |
--wm-data-grid-divider-color | var(--md-sys-color-outline-variant) | The lines between cells. |
--wm-data-grid-cell-padding | 12px | The space at a cell’s sides. |
--wm-data-grid-active-outline-color | var(--md-sys-color-secondary) | The outline of the active cell. |
--wm-data-grid-active-outline-width | 2px | The width of the active cell’s outline. |
--wm-data-grid-selection-color | var(--md-sys-color-secondary-container) | A selected cell’s fill. |
--wm-data-grid-editor-color | var(--md-sys-color-surface-container-highest) | The fill behind a cell’s editor. |
--wm-data-grid-selection-text-color | var(--md-sys-color-on-secondary-container) | A selected cell’s text. |
--wm-data-grid-state-changed-text-color | var(--md-sys-color-on-tertiary-container) | The text of a cell in the `changed` state. |
--wm-data-grid-state-warning-text-color | var(--md-sys-color-on-warning-container) | The text of a cell in the `warning` state. |
--wm-data-grid-state-error-text-color | var(--md-sys-color-on-error-container) | The text of a cell in the `error` state. |
--wm-data-grid-state-info-text-color | var(--md-sys-color-on-surface) | The text of a cell in the `info` state. |
--wm-data-grid-invalid-color | var(--md-sys-color-error) | An invalid cell’s text and icon. |
--wm-data-grid-state-changed-color | var(--md-sys-color-tertiary-container) | The fill of a cell in the `changed` state. |
--wm-data-grid-state-warning-color | var(--md-sys-color-warning-container) | The fill of a cell in the `warning` state. |
--wm-data-grid-state-error-color | var(--md-sys-color-error-container) | The fill of a cell in the `error` state. |
--wm-data-grid-state-info-color | var(--md-sys-color-surface-container-high) | The fill of a cell in the `info` state. |
--wm-data-grid-pin-shadow-color | color-mix(in srgb, var(--md-sys-color-shadow) 25%, transparent) | The shadow a pinned column casts over what scrolls under it. |
--wm-data-grid-pin-shadow-size | 4px | The reach of a pinned column’s shadow. |
--wm-data-grid-summary-color | var(--md-sys-color-surface-container) | A summary row’s surface. |
--wm-data-grid-summary-text-color | var(--md-sys-color-on-surface) | A summary row’s text. |
--wm-data-grid-status-gap | 8px | The space between the grid and its message. |
--wm-data-grid-status-min-height | 20px | The least height of the message below the grid. |
--wm-data-grid-icon-gap | 4px | The space before a cell’s icon. |
--wm-data-grid-icon-size | 16px | A cell’s icon. |
--wm-data-grid-loading-padding | 16px | The space around loading rows. |
--wm-data-grid-skeleton-gap | 8px | The space between loading rows. |
--wm-data-grid-skeleton-height | 32px | A loading row’s height. |
--wm-data-grid-state-padding | 32px | The space above and below the empty and error states. |