Overview
TheDataGrid component is the main entry point for rendering high-performance data grids. It supports virtualization, row/column selection, sorting, editing, custom renderers, and extensive keyboard accessibility.
Props
Grid and Data
An array of column definitions and/or column groups. See the
Column type for all available options.An array of rows, the rows data can be of any type.
Performance: The grid is optimized for efficient rendering:
- Virtualization: Only visible rows are rendered in the DOM
- Individual row updates: Row components are memoized, so updating a single row object will only re-render that specific row
- Array reference matters: Changing the array reference itself triggers viewport and layout recalculations
- Best practice: When updating rows, create a new array but reuse unchanged row objects
Optional ref for imperative APIs like scrolling/selecting a cell.
Rows pinned at the top of the grid for summary purposes.
Rows pinned at the bottom of the grid for summary purposes.
Function to return a unique key/identifier for each row.
rowKeyGetter is required for row selection to work.While optional, setting this prop is recommended for optimal performance as the returned value is used to set the
key prop on the row elements.Callback triggered when rows are changed.The first parameter is a new rows array with both the updated rows and the other untouched rows. The second parameter contains
indexes (array of changed row indices) and column (where the change happened).Dimensions
Height of each row in pixels. A function can be used to set different row heights.
Height of the header row in pixels.Default:
rowHeight when it is a number, otherwise 35 pixelsHeight of each summary row in pixels.Default:
rowHeight when it is a number, otherwise 35 pixelsA map of column widths containing both measured and resized widths. If not provided then an internal state is used.
Callback triggered when column widths change. If not provided then an internal state is used.
Selection
A set of selected row keys.
rowKeyGetter is required for row selection to work.Function to determine if row selection is disabled for a specific row.
Callback triggered when the selection changes.
Sorting
An array of sorted columns.
Sorting is controlled: the grid does not reorder
rows for you. Apply the sorting to your rows state (or derived rows) based on sortColumns.Callback triggered when sorting changes.More than one column can be sorted via
ctrl (command) + click. To disable multiple column sorting:Default options applied to all columns.
Events
Callback triggered when a pointer becomes active in a cell. The default behavior is to select the cell. Call
preventGridDefault to prevent the default behavior.Callback triggered when a cell is clicked.This event can be used to open cell editor on single click:
Callback triggered when a cell is double-clicked. The default behavior is to open the editor if the cell is editable. Call
preventGridDefault to prevent the default behavior.Callback triggered when a cell is right-clicked.
A function called when keydown event is triggered on a cell. This event can be used to customize cell navigation and editing behavior.Examples:Prevent editing on Prevent navigation on
Enter:Tab:Callback triggered when a cell’s content is copied.
Callback triggered when content is pasted into a cell.Return the updated row; the grid will call
onRowsChange with it.Triggered when the selected cell is changed.Arguments:
args.rowIdx:number- row indexargs.row:R | undefined- row object of the currently selected cellargs.column:CalculatedColumn<TRow, TSummaryRow>- column object of the currently selected cell
Callback triggered when the grid is scrolled.
Callback triggered when column is resized.
Callback triggered when columns are reordered.
Callback triggered during drag-fill operations. Return the updated row.
Customization
This prop can be used to disable virtualization.
Custom renderers for cells, rows, and other components.The default
<Row /> component can be wrapped via the renderRow prop:Function to apply custom class names to rows.
Custom class name for the header row.
This property sets the text direction of the grid. Setting
direction to 'rtl' has the following effects:- Columns flow from right to left
- Frozen columns are pinned on the right
- Column resize cursor is shown on the left edge of the column
- Scrollbar is moved to the left
Styling
Custom class name for the grid.
Custom styles for the grid.
Accessibility
ARIA role for the grid container.
The label of the grid. We recommend providing a label using
aria-label or aria-labelledby.The id of the element containing a label for the grid. We recommend providing a label using
aria-label or aria-labelledby.Total number of rows for assistive technologies.
Description of the grid.
If the grid has a caption or description,
aria-describedby can be set on the grid element with a value referring to the element containing the description.Testing
This prop can be used to add a testid for testing. We recommend querying the grid by its
role and name.Optional attribute to help with Cypress (or similar) selectors.
Generics
R- Row typeSR- Summary row type (default:unknown)K- Row key type (default:Key)