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

DataGridSelectable

DataGridSelectable extends DataGrid with active-cell management and single, multiple, or range selection.

Root API

PropTypeDefault
selectionS'single'
Selection mode. 'single' — only one cell can be selected at a time; 'multiple' — independent multi-selection (toggle per cell); 'range' — range selection between two points (Shift + arrows or pointer drag)
disabledDataGridDisabled<K>—
Predicate or map of disabled cells. Can be: a function (key) => boolean; an array of disabled keys; a single key. Disabled cells cannot be selected or focused.
excludeDisabledbooleantrue
—
expandablebooleantrue
Enables expanding selection ranges (Shift + Arrow or mouse drag).
defaultActiveK—
Uncontrolled initial active cell.
activeK—
Controlled active cell.
selectedS extends "single" ? K | null : K[]—
Controlled selected cells. In 'single' mode null means controlled with nothing selected.
defaultSelectedS extends "single" ? K : K[]—
Uncontrolled initially selected cells.
fromK—
Range boundaries. If provided, limits selection to cells between from and to based on the compare function.
toK—
—
resolveRange(start: DataGridResolveValue<K>, end: DataGridResolveValue<K>, grid: Grid<HTMLElement, K>) => K[]—
Custom range resolution logic for selection="range". Given start and end values, returns the list of keys forming the range.
equals(start: K | undefined, end: K | undefined) => boolean—
Custom equality comparator for comparing two cell keys. Defaults to strict equality (===).
compare(a: K, b: K) => -1 | 0 | 1—
Custom ordering comparator for comparing two cell keys. Should return -1, 0, or 1.
onSelectCell(value: S extends 'single' ? K : K[]) => void—
Fires when the user selects cell. Receives the list of selected cell keys.
onChangeActive(active: K) => void—
Fires when the active (focused) cell changes.
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
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

DataGridSelectableRowGroup

Groups rows and can provide scope separation for advanced compositions.

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.

DataGridSelectableRow

Represents one row of cells in the matrix.

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

Also accepts all <div> attributes.

DataGridSelectableCell

Represents one selectable cell.

PropTypeDefault
disabledboolean—
Disables click and keyboard selection. Overrides value from root DataGrid
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.

  • the cell key model should stay stable across renders

Hooks

useDataGridSelectableContext

Advanced hook for reading selection and disabled state in custom cell wrappers.

Types

TypeDefinitionNotes
DataGridSelectableProps<K, S>root prop typeExtends DataGridProps<K>.
DataGridSelectableRowGroupPropsrow-group propsGrouping and scope behavior.
DataGridSelectableRowPropsrow propsRow coordinate metadata.
DataGridSelectableCellPropscell propsCell coordinate and render props.
DataGridSelection'single' | 'multiple' | 'range'Selection mode.
DataGridDisabled<K>disabled map typePredicate, list, or key.

State Model

  • Active state and selected state can both be controlled or uncontrolled.
  • Range mode uses expansion logic driven by keyboard and pointer movement.
  • Disabled and excluded cells change both selection and navigation behavior.

Integration Notes

  • Keep key ordering stable when using compare and range logic.
  • Use DataGridPicker when the visual picker layer should be standardized.
  • Test pointer drag, shift-key expansion, and wrapped navigation together in real flows.