Examples › Records selection
To enable records selection, add the following properties to the DataTable:
selectedRecords→ an array of currently selected records (of the same type as the items in therecordsarray);onSelectedRecordsChange→ a callback invoked with the new array of selected records when the user changes the selection.
With these two properties set, the component renders a selection checkbox column and handles user input as follows:
- Clicking a row selection checkbox selects or deselects the underlying record;
- Clicking the column header checkbox selects or deselects all visible records (selected records that are not currently visible, e.g. on other pages, are left untouched);
- Shift-clicking a row selection checkbox selects or deselects all records between the last clicked record and the current one.
Disable selection of certain records
You can disable the selection of certain records by providing an isRecordSelectable function. It receives a record and its index and should return false for records that can’t be selected:
The selection checkboxes of non-selectable records are disabled, and both the column header checkbox and shift-click range selection skip them:
Customizing the selection column className and style
By default, the selection column is 44px wide — the space needed for the checkbox plus the default xs horizontal spacing on each side. Its width and padding follow the table’s horizontalSpacing and verticalSpacing. If you need a different width, or you need to customize the column for other reasons, you can do so by providing the selectionColumnClassName and/or selectionColumnStyle properties:
Selection column spacing
The selection column uses the same horizontalSpacing and verticalSpacing values as the other columns. Change them below to see how the checkbox cell padding, width and sticky divider follow along:
Horizontal spacing
Vertical spacing
Additional selection checkbox props
You can pass additional Mantine Checkbox props to the selection checkboxes with the following properties:
selectionCheckboxProps→ an object of props applied to all selection checkboxes (both the column header checkbox and the row selection checkboxes);allRecordsSelectionCheckboxProps→ an object of props applied to the column header checkbox;getRecordSelectionCheckboxProps→ a function receiving a record and its index and returning an object of props applied to that record’s selection checkbox.
In this example, the checkboxes are rendered with a smaller size and have custom aria-label attributes, which are read by screen readers (inspect the DOM to check them):
Selecting all records on all pages
When using pagination, the best practice is to only load the current page’s records from the server.
This also means that Mantine DataTable can’t — and shouldn’t — know about your entire dataset, so the “select all” checkbox only selects or deselects the records on the current page.
However, in certain cases you might want to give users the ability to “select all records on all pages” (like in Gmail’s user interface). In this case, you can use allRecordsSelectionCheckboxProps to implement your own selection mechanism. The example below also makes use of the uniqBy and differenceBy utility functions exported by Mantine DataTable:
You have selected 0 records of a total of 500.
Here is the code for the above example:
Horizontal scrolling behavior
Notice how, when the table is horizontally scrollable, the selection column stays pinned to the left side of the table, so that the selection checkboxes are always visible:
Code:
Maximizing the selection trigger area to the entire cell
By default, selection is triggered when the user clicks a selection checkbox.
However, you can extend the trigger area to the entire cell holding the checkbox by setting the selectionTrigger property to 'cell' (the default value is 'checkbox'):
In this case, clicking anywhere in the cell selects or deselects the underlying record:
Head over to the next example to discover more features.












