Row Selection
Preview

Select DataGrid rows through row clicks, keyboard interaction, or an optional checkbox column.

Overview

Use interaction="row-selection" with enableRowSelection to select eligible rows by clicking the row or pressing Space. Add the checkbox column when users also need explicit row and select-all controls.

Buttons, links, inputs, editable content, and [data-grid-interactive] descendants retain their own behavior without selecting the row. Call event.preventDefault() from a custom cell handler when it should own the gesture.

Row-click selection

Set enableMultiRowSelection to false for single selection. The preview switches between single and multiple selection.

The row-selection preset uses the same row-first keyboard model as Row Navigation. Up, Down, Home, and End move row focus; Space toggles the focused row; Escape clears the selection and returns focus to the viewport. Hierarchical models use treegrid semantics and retain their expansion navigation.

Per-row activation

Pair getRowCanActivate with onRowActivate when specific rows should perform an action instead of using the selection preset. Matching rows activate on click or Enter; other eligible rows continue to select on click or Space.

const table = useDataGridTable({
  columns,
  data,
  enableRowSelection: (row) => !row.getIsGrouped(),
});

<DataGrid
  getRowCanActivate={(row) => row.getIsGrouped()}
  interaction="row-selection"
  onRowActivate={({ row }) => row.toggleExpanded()}
  table={table}
>
  <DataGrid.Viewport aria-label="Grouped matters" />
</DataGrid>

Activation overrides only the matching row gesture. Selection remains native, and an optional checkbox can still select any row allowed by enableRowSelection. Both activation props are required together.

Selection checkbox column

Set rowSelectionColumn: true when users should have explicit row and select-all checkboxes. This convenience option enables row selection when enableRowSelection is omitted. Supply enableRowSelection as a predicate when eligibility differs per row. An explicit enableRowSelection: false keeps both selection and the convenience column off.

The checkbox column is independent of the root interaction preset. It can accompany passive tables, row navigation, row selection, or spreadsheets. Checkbox interaction never activates a row or applies row-click selection twice.

The column is always leading. It cannot be hidden, resized, grouped, sorted, pinned, edited, or reordered. When a consumer column is pinned left, the selection column becomes the first sticky column; otherwise it remains leading and scrolls normally. It never appears in consumer columnOrder or columnPinning state.

API Reference

DataGrid props

PropTypeDefaultDescription
interaction"row-selection"-Enables row focus, keyboard navigation, and row-click selection. Required.
getRowCanActivate(row) => boolean-Selects rows that activate instead of applying the row-selection gesture. Requires onRowActivate.
onRowActivateDataGridRowActivationHandler<TData>-Handles activation for matching rows. Requires getRowCanActivate.

Selection options

DataGrid defaults enableRowSelection to false. Row-click selection and the optional checkbox column share the same selection behavior, including configured eligibility and Shift-range selection.

OptionTypeDefaultDescription
enableRowSelectionboolean | ((row) => boolean)falseEnables selection for every row or rows that match a predicate.
rowSelectionColumnbooleanfalseAdds the fixed leading checkbox column and enables row selection when enableRowSelection is omitted.
enableMultiRowSelectionboolean | ((row) => boolean)trueAllows rows to remain selected together. Strict false removes the select-all header.
enableSubRowSelectionboolean | ((row) => boolean)trueControls whether selecting a parent also selects eligible descendants.
enableRowRangeSelectionbooleantrueEnables inclusive Shift-range selection.
isRowRangeSelectionEvent(event: unknown) => booleanShift-key eventDetermines whether a selection gesture extends from the previous row.
onRowSelectionChangeOnChangeFn<RowSelectionState>State updaterReceives row-selection updates when the consumer controls the slice.
getRowId(row, index, parent?) => stringIndex-derivedSupplies stable application IDs for selection state.

Selection methods

APISignatureDescription
table.getSelectedRowIds() => string[]Returns all selected row IDs.
table.getSelectedRowModel() => RowModel<DataGridFeatures, TData>Returns selected rows from the core row model.
table.setRowSelection(updater) => voidUpdates row-selection state.
table.resetRowSelection(defaultState?) => voidRestores initial selection, or clears it when passed true.
row.getCanSelect() => booleanReturns whether the row is eligible for selection.
row.getIsSelected() => booleanReturns whether the row ID is selected.
row.getIsSomeSelected() => booleanReturns whether some selectable descendants are selected.
row.toggleSelected(selected?, options?) => voidToggles or sets the row and optionally its descendants.

On this page