📄 tanstack/table/v8/docs/api/features/row-selection

File: row-selection.md | Updated: 11/15/2025

Source: https://tanstack.com/table/v8/docs/api/features/row-selection



TanStack

Table v8v8

Search...

+ K

Auto

Log In

TanStack StartRC

Docs Examples GitHub Contributors

TanStack Router

Docs Examples GitHub Contributors

TanStack Query

Docs Examples GitHub Contributors

TanStack Table

Docs Examples Github Contributors

TanStack Formnew

Docs Examples Github Contributors

TanStack DBbeta

Docs Github Contributors

TanStack Virtual

Docs Examples Github Contributors

TanStack Paceralpha

Docs Examples Github Contributors

TanStack Storealpha

Docs Examples Github Contributors

TanStack Devtoolsalpha

Docs Github Contributors

More Libraries

Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide

Documentation

Framework

React logo

React

Version

v8

Search...

+ K

Menu

Getting Started

Core Guides

Feature Guides

Core APIs

Feature APIs

Enterprise

Examples

Framework

React logo

React

Version

v8

Menu

Getting Started

Core Guides

Feature Guides

Core APIs

Feature APIs

Enterprise

Examples

On this page

Row Selection APIs

Copy Markdown

State
-----

Row selection state is stored on the table using the following shape:

tsx

export type RowSelectionState = Record<string, boolean>

export type RowSelectionTableState = {
  rowSelection: RowSelectionState
}


export type RowSelectionState = Record<string, boolean>

export type RowSelectionTableState = {
  rowSelection: RowSelectionState
}

By default, the row selection state uses the index of each row as the row identifiers. Row selection state can instead be tracked with a custom unique row id by passing in a custom getRowId function to the the table.

Table Options
-------------
### enableRowSelection

tsx

enableRowSelection?: boolean | ((row: Row<TData>) => boolean)


enableRowSelection?: boolean | ((row: Row<TData>) => boolean)
  • Enables/disables row selection for all rows in the table OR
  • A function that given a row, returns whether to enable/disable row selection for that row

### enableMultiRowSelection

tsx

enableMultiRowSelection?: boolean | ((row: Row<TData>) => boolean)


enableMultiRowSelection?: boolean | ((row: Row<TData>) => boolean)
  • Enables/disables multiple row selection for all rows in the table OR
  • A function that given a row, returns whether to enable/disable multiple row selection for that row's children/grandchildren

### enableSubRowSelection

tsx

enableSubRowSelection?: boolean | ((row: Row<TData>) => boolean)


enableSubRowSelection?: boolean | ((row: Row<TData>) => boolean)

Enables/disables automatic sub-row selection when a parent row is selected, or a function that enables/disables automatic sub-row selection for each row.

(Use in combination with expanding or grouping features)

### onRowSelectionChange

tsx

onRowSelectionChange?: OnChangeFn<RowSelectionState>


onRowSelectionChange?: OnChangeFn<RowSelectionState>

If provided, this function will be called with an updaterFn when state.rowSelection changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.

Table API
---------
### getToggleAllRowsSelectedHandler

tsx

getToggleAllRowsSelectedHandler: () => (event: unknown) => void


getToggleAllRowsSelectedHandler: () => (event: unknown) => void

Returns a handler that can be used to toggle all rows in the table.

### getToggleAllPageRowsSelectedHandler

tsx

getToggleAllPageRowsSelectedHandler: () => (event: unknown) => void


getToggleAllPageRowsSelectedHandler: () => (event: unknown) => void

Returns a handler that can be used to toggle all rows on the current page.

### setRowSelection

tsx

setRowSelection: (updater: Updater<RowSelectionState>) => void


setRowSelection: (updater: Updater<RowSelectionState>) => void

Sets or updates the state.rowSelection state.

### resetRowSelection

tsx

resetRowSelection: (defaultState?: boolean) => void


resetRowSelection: (defaultState?: boolean) => void

Resets the rowSelection state to the initialState.rowSelection, or true can be passed to force a default blank state reset to {}.

### getIsAllRowsSelected

tsx

getIsAllRowsSelected: () => boolean


getIsAllRowsSelected: () => boolean

Returns whether or not all rows in the table are selected.

### getIsAllPageRowsSelected

tsx

getIsAllPageRowsSelected: () => boolean


getIsAllPageRowsSelected: () => boolean

Returns whether or not all rows on the current page are selected.

### getIsSomeRowsSelected

tsx

getIsSomeRowsSelected: () => boolean


getIsSomeRowsSelected: () => boolean

Returns whether or not any rows in the table are selected.

### getIsSomePageRowsSelected

tsx

getIsSomePageRowsSelected: () => boolean


getIsSomePageRowsSelected: () => boolean

Returns whether or not any rows on the current page are selected.

### toggleAllRowsSelected

tsx

toggleAllRowsSelected: (value: boolean) => void


toggleAllRowsSelected: (value: boolean) => void

Selects/deselects all rows in the table.

### toggleAllPageRowsSelected

tsx

toggleAllPageRowsSelected: (value: boolean) => void


toggleAllPageRowsSelected: (value: boolean) => void

Selects/deselects all rows on the current page.

### getPreSelectedRowModel

tsx

getPreSelectedRowModel: () => RowModel<TData>


getPreSelectedRowModel: () => RowModel<TData>

### getSelectedRowModel

tsx

getSelectedRowModel: () => RowModel<TData>


getSelectedRowModel: () => RowModel<TData>

### getFilteredSelectedRowModel

tsx

getFilteredSelectedRowModel: () => RowModel<TData>


getFilteredSelectedRowModel: () => RowModel<TData>

### getGroupedSelectedRowModel

tsx

getGroupedSelectedRowModel: () => RowModel<TData>


getGroupedSelectedRowModel: () => RowModel<TData>

Row API
-------
### getIsSelected

tsx

getIsSelected: () => boolean


getIsSelected: () => boolean

Returns whether or not the row is selected.

### getIsSomeSelected

tsx

getIsSomeSelected: () => boolean


getIsSomeSelected: () => boolean

Returns whether or not some of the row's sub rows are selected.

### getIsAllSubRowsSelected

tsx

getIsAllSubRowsSelected: () => boolean


getIsAllSubRowsSelected: () => boolean

Returns whether or not all of the row's sub rows are selected.

### getCanSelect

tsx

getCanSelect: () => boolean


getCanSelect: () => boolean

Returns whether or not the row can be selected.

### getCanMultiSelect

tsx

getCanMultiSelect: () => boolean


getCanMultiSelect: () => boolean

Returns whether or not the row can multi-select.

### getCanSelectSubRows

tsx

getCanSelectSubRows: () => boolean


getCanSelectSubRows: () => boolean

Returns whether or not the row can select sub rows automatically when the parent row is selected.

### toggleSelected

tsx

toggleSelected: (value?: boolean) => void


toggleSelected: (value?: boolean) => void

Selects/deselects the row.

### getToggleSelectedHandler

tsx

getToggleSelectedHandler: () => (event: unknown) => void


getToggleSelectedHandler: () => (event: unknown) => void

Returns a handler that can be used to toggle the row.

Edit on GitHub

Row Pinning

AG Grid

Partners Become a Partner

Code RabbitCode Rabbit CloudflareCloudflare AG GridAG Grid NetlifyNetlify NeonNeon WorkOSWorkOS ClerkClerk ConvexConvex ElectricElectric SentrySentry PrismaPrisma StrapiStrapi UnkeyUnkey

scarf analytics