Skip to content
v2.5.0
English
Русский
Documentation

DataGrid

DataGrid is a compound component for keyboard-aware grid navigation across rows and cells.

Root API

DataGrid is the root active-cell and keyboard-navigation container.

PropTypeDefault
refRef<HTMLDivElement>—
Ref to the grid’s root element.
apiRefRef<DataGridApiRef<K>>—
Ref to the grid’s imperative API. Exposes low-level structures for advanced scenarios: grid — matrix navigation helper; keyMap — Map<K, [row, col]> for fast lookups
wrapDataGridWrap—
Navigation wrap mode. 'horizontal' — wrap across columns within the same row; 'vertical' — wrap across rows within the same column; 'both' — enable both behaviors; undefined — no wrapping
defaultActiveK''
Uncontrolled initial active (focused) cell key.
activeK—
Controlled active (focused) cell key.
onChangeActive(active: K) => void—
Fires when the active (focused) cell key changes.
excludeDataGridExclude<K>—
Exclude cells from focus traversal. Can be: a single key; an array of keys; a predicate (key) => boolean
rowDeltanumber—
Page navigation row step for PageUp/PageDown. undefined — jump to the first/last row; number — move by N rows relative to the current row
onArrow(e: KeyboardEvent<HTMLDivElement>, node: MatrixNode<HTMLElement, K>, prevNode: MatrixNode<HTMLElement, K>) => void—
Fires on each Arrow navigation step after focus changes

Also accepts all <div> attributes.

Child Parts API

DataGridRowGroup

Groups rows for navigation registration.

PropTypeDefault
scopeDataGridScope—
Optional logical group for grid cells. Allows the DataGrid to treat cells as part of the same page or section.

Also accepts all <div> attributes.

DataGridRow

Row registration unit.

PropTypeDefault
rowrequirednumber—
Zero-based row index for all descendant cells. Provided to descendants via context.

Also accepts all <div> attributes.

DataGridCell

Cell registration unit.

PropTypeDefault
colrequirednumber—
Column index of the cell (0-based). Used together with row index from the row context to form grid coordinates: [row, col].
refRef<HTMLDivElement>—
External ref to the cell root element. Will be merged with the internal itemRef([row, col], key) registration when the cell is not excluded.
cellKeyDataGridCellKey—
Stable key that identifies the cell in the DataGrid matrix. If omitted, a key is derived as ${row}:${col} from row/col.
asChildbooleanfalse
When true, renders children via Slot and forwards props/refs to the child element instead of using a native <div>.
excludedboolean—
Exclude cells from focus traversal. Overrides value from root DataGrid

Also accepts all <div> attributes.

Hooks

useDataGridContext

Advanced hook for root-level grid coordination.

useDataGridRowContext

Advanced hook for row-level custom abstractions.

Types

TypeDefinitionNotes
DataGridCellKeycell key contractUsually row and column based.
DataGridCoordinatesrow/col coordinate shapeUsed by navigation logic.
DataGridWrapwrap mode unionHorizontal, vertical, or both.
DataGridExcludeexclusion contractSparse-grid navigation control.
DataGridApiRefAPI ref contractAdvanced integrations.
DataGridScopescope identifierSeparates logical grid groups when needed.

State Model

  • Active cell can be controlled or uncontrolled.
  • Navigation depends on row and cell registration order.
  • Exclusion and wrap mode affect the keyboard model directly.
  • The root is foundational; selection and picker semantics are layered on by derived components.

Integration Notes

  • Prefer Table for static data display.
  • Use exclusion rules when the visible matrix is sparse.
  • Use rowDelta when PageUp/PageDown should move by a fixed amount instead of jumping to edges.
  • Retest interactive content inside cells carefully.