Installation
Install @mantine/data-grid and its peer dependencies:
Import the package styles after @mantine/core styles:
Quick start
Store hook
Use useDataGrid to create a store that manages grid state and pass it to DataGrid
with the store prop:
createDataGridColumnHelper
createDataGridColumnHelper is a wrapper around TanStack Table createColumnHelper.
Pass your row data type as a generic to get autocompletion on accessor keys and cell values:
Column definition types
TanStack Table supports three kinds of column definitions:
- Accessor columns – defined with
accessorKeyoraccessorFn. Read data from the row and support sorting, filtering and grouping. - Display columns – defined with an
idand no accessor. Used for action buttons, checkboxes or any content not tied to row data. - Group columns – defined with a
columnsarray. Create a multi-level header by nesting other columns inside a group.
defaultColumn
Pass defaultColumn in tableOptions to set default values of column properties:
Features overview
Features are configured with useDataGrid options. Most of them are enabled automatically
when you pass controlled state or column-level flags:
Set the matching with* option (for example, withSorting) to force a feature on or off.
Appearance props such as striped or withColumnBorders are set on the DataGrid component,
see Customization.
Peer dependencies
@mantine/data-grid has the following peer dependencies: