Frame
By default, the grid has a border around the toolbar, the table and the footer.
Use radius to change its border radius and withTableBorder={false} to remove the border.
borderColor accepts a key of theme.colors or any valid CSS color:
Separators
Use these DataGrid props to style rows and separators:
To display stripes without row borders, set striped and withRowBorders={false}:
Default rules
Subtle rules
Stripes without rules
Column borders between data columns
Every separator
Example with custom stripe and hover colors:
Size
size is a useDataGrid option, sm by default. It controls the font size, row height,
cell padding and the size of controls and icons. It does not accept numbers,
use CSS variables to change individual values:
size="xs"
size="sm"
size="md"
size="lg"
size="xl"
Pass store.getControlSize() to your own buttons and inputs inside the grid so they match the grid size.
To let users change the density, call store.setSize:
CSS variables
The following CSS variables are set on the root element. Override them with vars,
the Styles API or in a stylesheet.
Styles API
DataGrid supports classNames and styles props. Selectors are listed in the Styles API table
on the DataGrid page. Row and cell states are available as data attributes,
for example data-selected, data-striped and data-pinned:
Compound components
Use compound components to add a toolbar, a selection bar and a footer to the grid. The toolbar and the selection bar are displayed above the table, other children below it:
DataGrid.Toolbar-- bar above the tableDataGrid.GlobalFilter-- global search inputDataGrid.ColumnVisibilityToggle-- column visibility menu buttonDataGrid.ExportButton-- export menuDataGrid.RowCount-- total / filtered row count textDataGrid.SelectionBar-- bulk actions bar displayed while rows are selectedDataGrid.Footer-- bar below the table with status text, page size select and paginationDataGrid.ColumnMenu-- column menu button for custom header cells
Toolbar
DataGrid.Toolbar without children renders the global filter, the column visibility toggle
and the export button, each when its feature is enabled. Pass children to replace the default content,
use a div with flex: 1 as a spacer. DataGrid.RowCount displays the number of rows,
for example 5 of 18 rows when the data is filtered:
Export button
DataGrid.ExportButton opens a menu with CSV, Excel, print and copy to clipboard items:
formats– formats to display and their order, a single format renders a button without a menufileName– name of the downloaded file,databy defaultrows– rows to export:all(default),filtered,selectedorpagecolumns– columns to export:visible(default),allor an array of column idsonExport– called with the format after an export
Utility columns, actions columns and columns with meta.disableExport are never exported:
Selection bar
DataGrid.SelectionBar replaces the toolbar while rows are selected. It displays the number
of selected rows, bulk actions passed as children and a button that clears the selection.
Set withCloseButton={false} to remove the close button:
Set floating to display the bar over the grid content near the bottom of the grid,
the toolbar stays visible:
Footer
DataGrid.Footer renders the status text, the page size select and pagination controls in one bar
at the bottom of the frame, see Pagination.
Column menu
Set withColumnMenu on DataGrid to add a menu button to every data column header.
Menu items depend on the features enabled for the column: sorting, reordering, pinning, hiding,
grouping and resizing. Use columnMenuItems to add your own items and meta.disableColumnMenu
to hide the menu of one column:
To render the column menu inside your own header cell, use DataGrid.ColumnMenu and pass
the column instance to it. children are added after the built-in items:
Column meta
meta of a column definition contains settings specific to the grid:
See Editing for examples of action columns, custom editors and validation.
Labels
Use the labels prop of DataGrid to change or translate text labels. All keys are optional,
{token} placeholders are replaced with values:
The full list of keys is the DataGridLabels type, exported from the package together with
DEFAULT_LABELS.
State persistence
To save and restore grid state, use controlled state options of useDataGrid.
The example below saves the sorting state to localStorage:
useDataGridState
useDataGridState saves the state keys listed in persistedState to localStorage
and restores them on mount:
Theme integration
Use DataGrid.extend to set default props and class names for all grids in your application:
Dark mode
DataGrid colors are based on Mantine CSS variables and follow the current color scheme, no additional configuration is required.
ScrollArea configuration
The table is wrapped in ScrollArea. Use scrollAreaProps to pass props to it, or set
withScrollArea={false} to use native scrollbars. For virtualized grids, set withScrollArea
to enable ScrollArea. This option does not apply to list view.
TanStack passthrough
Use tableOptions in useDataGrid to pass options that the hook does not cover to TanStack Table: