Column Options
Many of the column options you can pass here are the same as the ones that you can pass to the useReactTable ColumnDefs
Here is a list of all the column options you can specify in a
column
definition.const columns = useMemo(() => [{accessorKey: 'name',header: 'Name',// All of the options you can specify here},],[],);const table = useMantineReactTable({columns,data,});return <MantineReactTable table={table} />;
# | Column Option | Type | Default Value | More Info Links | |
---|---|---|---|---|---|
1 |
| MRT Data Columns Docs | |||
Alternative to an accessorKey, define an accessor function instead of a string key. | |||||
2 |
| MRT Data Columns Docs | |||
If provided, the accessorKey will be used to point to which key in the data object should be used to access the data in this column. | |||||
3 |
| ||||
Define a custom cell render for an aggregated cell. | |||||
4 |
| TanStack Table Grouping Docs | |||
Specify which aggregate function should be used for grouped columns. | |||||
5 |
| MRT Data Columns Docs | |||
Define a custom cell render to add markup, styles, or conditional logic. | |||||
6 |
| ||||
No Description Provided... Yet... | |||||
7 |
| ||||
If using header groups, define an array of sub columns here. | |||||
8 |
| MRT Editing Docs | |||
Define a custom edit component for cells in a column. | |||||
9 |
|
| MRT Editing Docs | ||
Define which component should be used for editing. | |||||
10 |
| MRT Click to Copy Docs | |||
Enable the click to copy feature for this column. | |||||
11 |
| MRT Column Actions Docs | |||
Enable or disable column actions for this column. | |||||
12 |
| ||||
Enable or disable column dragging for this column. | |||||
13 |
| MRT Column Filtering Docs | |||
Enable or disable column filtering for this column. Filter will not be shown if disabled. | |||||
14 |
| MRT Column Filtering Docs | |||
Enable column filtering modes for this column. | |||||
15 |
| ||||
No Description Provided... Yet... | |||||
16 |
| ||||
No Description Provided... Yet... | |||||
17 |
| ||||
No Description Provided... Yet... | |||||
18 |
| ||||
No Description Provided... Yet... | |||||
19 |
| ||||
No Description Provided... Yet... | |||||
20 |
| ||||
No Description Provided... Yet... | |||||
21 |
|
| |||
No Description Provided... Yet... | |||||
22 |
| ||||
No Description Provided... Yet... | |||||
23 |
| ||||
No Description Provided... Yet... | |||||
24 |
| ||||
No Description Provided... Yet... | |||||
25 |
| MRT Column Filtering Docs | |||
Define a custom filter component in a column. | |||||
26 |
|
| |||
No Description Provided... Yet... | |||||
27 |
|
| |||
Specify whether the filter should be a text input or a select input, or other type of pre-built input. | |||||
28 |
| MRT Data Columns Docs | |||
Render custom markup for a column footer. | |||||
29 |
| TanStack Table Grouping Docs | |||
Specify a value to be used for grouping rows on this column. If this option is not specified, the value derived from accessorKey / accessorFn will be used instead. | |||||
30 |
| ||||
Define a custom cell render for a grouped cell. | |||||
31 |
| MRT Data Columns Docs | |||
Render custom markup for a column header. | |||||
32 |
| TanStack Table ColumnDef Docs | |||
No Description Provided... Yet... | |||||
33 |
| TanStack Table ColumnDef Docs | |||
No Description Provided... Yet... | |||||
34 |
|
| |||
No Description Provided... Yet... | |||||
35 |
| Mantine ActionIcon API | |||
No Description Provided... Yet... | |||||
36 |
| Mantine ActionIcon API | |||
No Description Provided... Yet... | |||||
37 |
| Mantine UnstyledButton API | |||
No Description Provided... Yet... | |||||
38 |
| Mantine Select Docs | |||
No Description Provided... Yet... | |||||
39 |
| Mantine TextInput API | |||
No Description Provided... Yet... | |||||
40 |
| Mantine Autocomplete Docs | |||
No Description Provided... Yet... | |||||
41 |
| Mantine Checkbox Props | |||
No Description Provided... Yet... | |||||
42 |
| Mantine DateInput Docs | |||
No Description Provided... Yet... | |||||
43 |
| Mantine MultiSelect Docs | |||
No Description Provided... Yet... | |||||
44 |
| Mantine Slider Docs | |||
No Description Provided... Yet... | |||||
45 |
| Mantine Select Docs | |||
No Description Provided... Yet... | |||||
46 |
| Mantine TextInput Docs | |||
No Description Provided... Yet... | |||||
47 |
| Mantine Box API | |||
No Description Provided... Yet... | |||||
48 |
| Mantine Box API | |||
No Description Provided... Yet... | |||||
49 |
| Mantine Box API | |||
No Description Provided... Yet... | |||||
50 |
|
| |||
No Description Provided... Yet... | |||||
51 |
|
| |||
No Description Provided... Yet... | |||||
52 |
|
| |||
No Description Provided... Yet... | |||||
53 | |||||
No Description Provided... Yet... | |||||
54 | |||||
No Description Provided... Yet... | |||||
55 |
|
| |||
No Description Provided... Yet... | |||||
56 |
| ||||
No Description Provided... Yet... | |||||
57 |
| ||||
No Description Provided... Yet... | |||||
58 |
| ||||
No Description Provided... Yet... |
Wanna see the source code for this table? Check it out down below!
1import { useEffect, useMemo, useState } from 'react';2import Link from 'next/link';3import { MantineReactTable, type MRT_ColumnDef } from 'mantine-react-table';4import { Anchor, Text } from '@mantine/core';5import { useMediaQuery } from '@mantine/hooks';6import { SampleCodeSnippet } from '../mdx/SampleCodeSnippet';7import { type ColumnOption, columnOptions } from './columnOptions';8import { getPrimaryColor } from 'mantine-react-table/src/column.utils';910interface Props {11onlyOptions?: Set<keyof MRT_ColumnDef<ColumnOption>>;12}1314const ColumnOptionsTable = ({ onlyOptions }: Props) => {15const isDesktop = useMediaQuery('(min-width: 1200px)');1617const columns = useMemo(18() =>19[20{21accessorKey: 'columnOption',22enableClickToCopy: true,23header: 'Column Option',24mantineCopyButtonProps: ({ cell, row }) => ({25className: 'column-option',26id: `${cell.getValue<string>()}-column-option`,27}),28Cell: ({ renderedCellValue, row }) =>29row.original?.required ? (30<Text31component="strong"32sx={(theme) => ({33color: getPrimaryColor(theme),34})}35>36{renderedCellValue}*37</Text>38) : (39renderedCellValue40),41},42{43accessorKey: 'type',44header: 'Type',45enableGlobalFilter: false,46Cell: ({ cell }) => (47<SampleCodeSnippet language="typescript" noCopy>48{cell.getValue<string>()}49</SampleCodeSnippet>50),51},52{53accessorKey: 'required',54enableGlobalFilter: false,55header: 'Required',56},57{58accessorKey: 'defaultValue',59enableGlobalFilter: false,60header: 'Default Value',61Cell: ({ cell }) => (62<SampleCodeSnippet language="typescript" noCopy>63{cell.getValue<string>()}64</SampleCodeSnippet>65),66},67{68accessorKey: 'description',69enableGlobalFilter: false,70header: 'Description',71},72{73accessorKey: 'link',74disableFilters: true,75enableGlobalFilter: false,76header: 'More Info Links',77Cell: ({ cell, row }) => (78<Link href={cell.getValue() as string} passHref legacyBehavior>79<Anchor80target={81(cell.getValue() as string).startsWith('http')82? '_blank'83: undefined84}85rel="noopener"86>87{row.original?.linkText}88</Anchor>89</Link>90),91},92] as MRT_ColumnDef<ColumnOption>[],93[],94);9596const [columnPinning, setColumnPinning] = useState({});9798useEffect(() => {99if (typeof window !== 'undefined') {100if (isDesktop) {101setColumnPinning({102left: ['mrt-row-expand', 'mrt-row-numbers', 'columnOption'],103right: ['link'],104});105} else {106setColumnPinning({});107}108}109}, [isDesktop]);110111const data = useMemo(() => {112if (onlyOptions) {113return columnOptions.filter(({ columnOption }) =>114onlyOptions.has(columnOption),115);116}117return columnOptions;118}, [onlyOptions]);119120return (121<MantineReactTable122columns={columns}123data={data}124displayColumnDefOptions={{125'mrt-row-numbers': {126size: 10,127},128'mrt-row-expand': {129size: 10,130},131}}132enableColumnActions={!onlyOptions}133enableColumnFilterModes134enablePagination={false}135enablePinning136enableRowNumbers137enableBottomToolbar={false}138enableTopToolbar={!onlyOptions}139initialState={{140columnVisibility: { required: false, description: false },141density: 'xs',142showGlobalFilter: true,143sorting: [{ id: 'columnOption', desc: false }],144}}145mantineSearchTextInputProps={{146placeholder: 'Search Column Options',147sx: { minWidth: '18rem' },148variant: 'filled',149}}150mantinePaperProps={{151sx: { marginBottom: '24px' },152id: onlyOptions153? 'relevant-column-options-table'154: 'column-options-table',155}}156positionGlobalFilter="left"157renderDetailPanel={({ row }) => (158<Text color={row.original.description ? 'teal' : 'gray'}>159{row.original.description || 'No Description Provided... Yet...'}160</Text>161)}162rowNumberMode="static"163onColumnPinningChange={setColumnPinning}164state={{ columnPinning }}165/>166);167};168169export default ColumnOptionsTable;