Examples › Row styling
You can style individual rows based on their data using the rowColor, rowBackgroundColor, rowClassName and rowStyle properties.
They are the row-level counterparts of the c, backgroundColor, className and style properties of the DataTable component, but they accept functions that receive the current record and its index, so each row can be styled differently (rowClassName also accepts a plain string).
Using rowColor and rowBackgroundColor
The rowColor and rowBackgroundColor properties accept a function that receives the current record and its index as arguments and returns either a MantineColor (a key of theme.colors or any valid CSS color string) to be applied to the row, or an object with light and dark keys and MantineColor values to be applied in light and dark color schemes respectively. Return undefined to leave a row with its default colors.
Here is the code used to produce the result above:
Using rowClassName
The rowClassName property accepts either a string, to apply the same class name to every row, or a function that receives the current record and its index as arguments and returns the class name to be applied to the row (or undefined for no extra class).
Here is the code used to produce the result above:
Using rowStyle
The rowStyle property accepts a function that receives the current record and its index as arguments and returns either a style object to be applied to the row, or a function that accepts the current theme and returns such an object.
Here is the code used to produce the result above:
And here is how you could build the style based on the current theme, by returning a function:
Here is the code used to produce the result above:
Head over to the next example to discover more features.












