In Mantine React Table, every column has an associated column instance object. This object provides access to various static methods and properties that describe the state and definition of that specific column.
Important Distinction: These are not column options (configuration settings). They are methods and properties available on the instance itself to inspect or react to the column's current state.
Common Access Points
You can access the column instance in several callback props and component overrides:
- Column Definition Callbacks: Inside properties like
mantineTableHeadCellProps, Header, or Cell within your column array. - Table Instance Callbacks: Inside global table callback props like
mantineTableBodyCellProps provided to useMantineReactTable.
const columns = [
{
accessorKey: 'username',
header: 'Username',
// Accessing column instance in a column definition callback
mantineTableHeadCellProps: ({ column }) => ({
style: {
color: column.getIsSorted() ? 'red' : 'black',
},
}),
// Accessing column instance in the Header component override
Header: ({ column }) => <div>{column.columnDef.header}</div>,
// Accessing column instance in the Cell component override
Cell: ({ cell, column }) => (
<Box
style={{
backgroundColor: column.getIsGrouped() ? 'green' : 'white',
}}
>
{cell.getValue()}
</Box>
),
},
];
const table = useMantineReactTable({
columns,
data,
// Accessing column instance in table-level callback props
mantineTableBodyCellProps: ({ column }) => ({
style: {
boxShadow: column.getIsPinned() ? '0 0 0 2px red' : 'none',
},
}),
});