Examples › Column properties and styling
The accessor
The only property you have to specify for a column is its accessor — the name of the record property whose value you want to display in the column cells.
The accessor supports dot-notation for drilling into nested objects (e.g. 'department.company.name').
The component derives a column header title by “humanizing” the accessor (e.g. 'firstName' → 'First name' or 'department.company.name' → 'Department company name').
If you’re not happy with the automatically derived title, you can override it by setting your own column title, which can be any ReactNode.
Basic column properties
Each column can be further customized by specifying the following properties:
width: number | string
Desired column width.ellipsis: boolean
Iftrue, cell content in this column will not wrap to multiple lines and will be truncated with an ellipsis if needed.
You can set either this property ornoWrap, but not both.noWrap: boolean
Iftrue, cell content in this column will not wrap to multiple lines (i.e.white-space: nowrap).
You can set either this property orellipsis, but not both.textAlign: 'left' | 'center' | 'right'
Text alignment of the column title, cells and footer. Defaults to'left'if not specified.hidden: boolean
Iftrue, the column will not be visible.visibleMediaQuery
A media querystring, or a function accepting the currentMantineThemeas its argument and returning a media query string.
If set, the column will only be visible when the media query matches.render
A function that accepts the current record and its index inrecordsas arguments and returns aReactNode(keep in mind that strings and numbers are valid React nodes).filter
An optional property which provides the user with filtering options. It can be either aReactNodeor a function returning aReactNode.
If set, a filter button will be added to the column header. Clicking the button opens a popover showing the provided node.
If you provide a function, it will be called with an object containing aclose()method, which you can call to close the popover.filtering: boolean
Iftrue, the filter button in the column header will be highlighted to indicate that a filter is in effect. Defaults tofalseif not specified.filterPopoverProps
Props passed to the filter Popover, in case you need to override its defaults (position, width, shadow, etc.).filterPopoverDisableClickOutside: boolean
Iftrue, disables the click-outside handler the DataTable attaches to the filter popover dropdown. Combine it withfilterPopoverProps={{ closeOnClickOutside: false }}to keep the popover open until it’s closed explicitly, which is useful when the filter contains components rendering their own dropdowns in a portal, such as date pickers or selects.filterButtonLabel: string
Accessible label (aria-label) of the filter button in the column header. Defaults toFilter <column title>when the column title is a string, or toFilterotherwise; set it to localize the label or to describe the filter more precisely.
You can create a “virtual column” by providing an accessor that doesn’t refer to an existing property (or nested property) of the records. In this case, you must provide a custom render function. Also, keep in mind that each accessor must be unique within the columns collection.
Consider this example:
Here’s the code for the example above:
Column footers
The DataTable component will display a footer row at the bottom of the table if you specify a footer property for at least one column:
Here’s the code for the example above:
The footer is always visible and sticks to the bottom of the table. For example, if the table is scrollable:
Or if the table is taller than its content:
Styling column titles, cells and footers
You can customize the look of each column by specifying the following styling properties:
titleClassName: string
A custom class name for the column title.titleStyle
A custom style object for the column title, or a function accepting the current theme and returning a style object.cellsClassName
A custom class name for the column cells, or a function that accepts the current record and its index as arguments and returns a class name.cellsStyle
A function that accepts the current record and its index as arguments and returns either a style object for the column cells, or a function accepting the current theme and returning a style object.footerClassName: string
A custom class name for the column footer.footerStyle
A custom style object for the column footer, or a function accepting the current theme and returning a style object.
Consider this example:
Here’s the code for the example above:
Other column properties
Column definitions accept a few more properties, each covered in detail by a dedicated example:
sortableandsortKey— see sorting;draggable,toggleableanddefaultToggle— see column dragging and toggling;resizable— see column resizing;pinnedandpinnable— see pinning arbitrary columns;customCellAttributes— see custom row or cell attributes;hiddenContent— iftrue, the column header is rendered, but the column’s body cells are not. This is only useful in advanced scenarios where you render the table rows yourself, as in the row dragging example.
Head over to the next example to discover more features.












