Examples › Overriding the default styles
Mantine DataTable closely follows the current Mantine theme, so it should look great out of the box in most cases.
However, if you’re not happy with the default Mantine DataTable styling, there are several ways to override it.
With color properties
The quickest way to customize the default colors is to use the c, backgroundColor, borderColor, rowBorderColor, stripedColor, highlightOnHoverColor and selectionColor properties.
Each of them accepts either a MantineColor (a key of theme.colors or any valid CSS color string), or an object with light and dark keys and MantineColor values, to be used for the light and dark color schemes respectively.
The c property sets the text color and is applied to:
- the table body, header and footer;
- the pagination text and page buttons (if present).
The backgroundColor property is applied to:
- the table body, header and footer;
- the pagination area (if present).
The borderColor property is applied to:
- the table outer border (if enabled by the
withTableBorderproperty); - the header bottom border;
- the footer top border (see column footers);
- the pagination top border and page button borders (if present).
The rowBorderColor property defaults to the borderColor value and is applied to:
- the bottom border of each row;
- the column borders (if enabled by the
withColumnBordersproperty).
The stripedColor property sets the background color of striped rows when the striped property is enabled (odd rows by default, or even rows with striped="even"), while highlightOnHoverColor sets the background color of the row under the mouse cursor when the highlightOnHover property is enabled (see basic table properties). The selectionColor property sets the background color of selected rows, which defaults to the light variant of the theme’s primary color.
If you’re using pagination, you can also customize the colors of the active page button with the paginationActiveTextColor and paginationActiveBackgroundColor properties.
For example, this code:
…will produce the following table (hover over the rows to see the highlight color):
With CSS variables
Under the hood, the color properties above are implemented with CSS variables defined on the component root (the element with the mantine-datatable class). You can override these variables in your own CSS, which also gives you access to colors that don’t have a dedicated property, such as the background color of selected rows:
--mantine-datatable-color--mantine-datatable-background-color--mantine-datatable-border-color--mantine-datatable-row-border-color--mantine-datatable-striped-color--mantine-datatable-highlight-on-hover-color--mantine-datatable-selection-color(background color of selected rows, also settable with theselectionColorproperty; defaults to--mantine-primary-color-light)
In the example below, a className is used to change the colors of the selected and hovered rows:
Here is the code for the above example:
Besides its basic properties and the aforementioned colors, there are several more elaborate ways to change (or completely override) the default styling of Mantine DataTable.
With className
You can pass a className that will be applied to the DataTable component root:
Here is the code for the above example:
With a style object or function
You can style the DataTable component root with a style object:
Here is the code for the above example:
The style property also accepts a function that receives the current theme as its argument and returns a style object:
Here is the code for the above example:
With multiple class names
You can target the component root, table, header, footer and pagination individually by passing an object with root, table, header, footer and pagination keys to the classNames property:
Here is the code for the above example:
With multiple style objects or functions
Similarly, the styles property accepts an object with the same keys and style objects (or functions receiving the current theme and returning style objects) as values:
Here is the code for the above example:
With global class names
Finally, Mantine DataTable elements have static class names you can target in your global stylesheets, such as mantine-datatable (the root), mantine-datatable-table, mantine-datatable-header, mantine-datatable-row, mantine-datatable-footer and mantine-datatable-pagination. Prefer the approaches above when possible, though: they are scoped to a single table and less likely to be affected by changes in the component’s internal structure.
Head over to the next example to discover more features.














