State Options
Many of the state options you can pass here are the same as the ones you can pass to the useReactTable useTableInstance hook.
Here is a list of all the state options you can pass to
initialState
or state
.const table = useMantineReactTable({columns,data,initialState: {// all the state options you can pass here},state: {// or here - NOTE: state values will override initialState values},});return <MantineReactTable table={table} />;
# | State Option | Type | Default Value | More Info Links | |
---|---|---|---|---|---|
1 |
| ||||
No Description Provided... Yet... | |||||
2 |
|
| TanStack Table Filters Docs | ||
No Description Provided... Yet... | |||||
3 |
|
| TanStack Table Column Ordering Docs | ||
No Description Provided... Yet... | |||||
4 |
|
| TanStack Table Column Pinning Docs | ||
No Description Provided... Yet... | |||||
5 |
|
| TanStack Table Column Sizing Docs | ||
No Description Provided... Yet... | |||||
6 |
|
| TanStack Table Column Sizing Docs | ||
No Description Provided... Yet... | |||||
7 |
|
| TanStack Table Column Visibility Docs | ||
No Description Provided... Yet... | |||||
8 |
| ||||
No Description Provided... Yet... | |||||
9 |
|
| |||
No Description Provided... Yet... | |||||
10 |
| ||||
No Description Provided... Yet... | |||||
11 |
| ||||
No Description Provided... Yet... | |||||
12 |
| ||||
No Description Provided... Yet... | |||||
13 |
| ||||
No Description Provided... Yet... | |||||
14 |
|
| TanStack Table Expanding Docs | ||
No Description Provided... Yet... | |||||
15 |
| TanStack Table Filtering Docs | |||
No Description Provided... Yet... | |||||
16 |
| ||||
No Description Provided... Yet... | |||||
17 |
|
| TanStack Table Grouping Docs | ||
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 |
|
| |||
Shows progress bars and a spinner on the save buttons when true | |||||
23 |
|
| TanStack Table Pagination Docs | ||
No Description Provided... Yet... | |||||
24 |
|
| TanStack Table Row Selection Docs | ||
No Description Provided... Yet... | |||||
25 |
|
| |||
No Description Provided... Yet... | |||||
26 |
|
| |||
No Description Provided... Yet... | |||||
27 |
|
| |||
No Description Provided... Yet... | |||||
28 |
|
| |||
No Description Provided... Yet... | |||||
29 |
|
| |||
No Description Provided... Yet... | |||||
30 |
|
| |||
No Description Provided... Yet... | |||||
31 |
|
| TanStack Table Sorting Docs | ||
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 {4MantineReactTable,5type MRT_ColumnDef,6type MRT_TableState,7} from 'mantine-react-table';8import { Anchor, Text } from '@mantine/core';9import { useMediaQuery } from '@mantine/hooks';10import { SampleCodeSnippet } from '../mdx/SampleCodeSnippet';11import { type StateOption, stateOptions } from './stateOptions';1213interface Props {14onlyOptions?: Set<keyof MRT_TableState<StateOption>>;15}1617const StateOptionsTable = ({ onlyOptions }: Props) => {18const isDesktop = useMediaQuery('(min-width: 1200px)');1920const columns = useMemo(21() =>22[23{24accessorKey: 'stateOption',25enableClickToCopy: true,26header: 'State Option',27mantineCopyButtonProps: ({ cell }) => ({28className: 'state-option',29id: `${cell.getValue<string>()}-state-option`,30}),31},32{33accessorKey: 'type',34header: 'Type',35enableGlobalFilter: false,36Cell: ({ cell }) => (37<SampleCodeSnippet language="typescript" noCopy>38{cell.getValue<string>()}39</SampleCodeSnippet>40),41},42{43accessorKey: 'defaultValue',44enableGlobalFilter: false,45header: 'Default Value',46Cell: ({ cell }) => (47<SampleCodeSnippet language="typescript" noCopy>48{cell.getValue<string>()}49</SampleCodeSnippet>50),51},52{53accessorKey: 'description',54enableGlobalFilter: false,55header: 'Description',56},57{58accessorKey: 'link',59disableFilters: true,60enableGlobalFilter: false,61header: 'More Info Links',62Cell: ({ cell, row }) => (63<Link href={cell.getValue() as string} passHref legacyBehavior>64<Anchor65target={66(cell.getValue() as string).startsWith('http')67? '_blank'68: undefined69}70rel="noopener"71>72{row.original?.linkText}73</Anchor>74</Link>75),76},77] as MRT_ColumnDef<StateOption>[],78[],79);8081const [columnPinning, setColumnPinning] = useState({});8283useEffect(() => {84if (typeof window !== 'undefined') {85if (isDesktop) {86setColumnPinning({87left: ['mrt-row-expand', 'mrt-row-numbers', 'stateOption'],88right: ['link'],89});90} else {91setColumnPinning({});92}93}94}, [isDesktop]);9596const data = useMemo(() => {97if (onlyOptions) {98return stateOptions.filter(({ stateOption }) =>99onlyOptions.has(stateOption),100);101}102return stateOptions;103}, [onlyOptions]);104105return (106<MantineReactTable107columns={columns}108data={data}109displayColumnDefOptions={{110'mrt-row-numbers': {111size: 10,112},113'mrt-row-expand': {114size: 10,115},116}}117enableColumnActions={!onlyOptions}118enableColumnFilterModes119enablePagination={false}120enablePinning121enableRowNumbers122enableBottomToolbar={false}123enableTopToolbar={!onlyOptions}124initialState={{125columnVisibility: { description: false },126density: 'xs',127showGlobalFilter: true,128sorting: [{ id: 'stateOption', desc: false }],129}}130mantineSearchTextInputProps={{131placeholder: 'Search State Options',132sx: { minWidth: '18rem' },133variant: 'filled',134}}135mantinePaperProps={{136sx: { marginBottom: '24px' },137id: onlyOptions138? 'relevant-state-options-table'139: 'state-options-table',140}}141positionGlobalFilter="left"142renderDetailPanel={({ row }) => (143<Text color={row.original.description ? 'teal' : 'gray'}>144{row.original.description || 'No Description Provided... Yet...'}145</Text>146)}147rowNumberMode="static"148onColumnPinningChange={setColumnPinning}149state={{ columnPinning }}150/>151);152};153154export default StateOptionsTable;