MRT logoMaterial React Table

Props

Many of the props you can pass to <MaterialReactTable /> are the same as the ones you can pass to the TanStack Table useReactTable hook.

Here is a list of all the props you can pass to the root <MaterialReactTable />.

<MaterialReactTable
//all the props you can pass here
/>
1
Array<MRT_ColumnDef<TData>>
Column Options API Reference
2
Array<TData>
Usage Docs
3
Record<string, AggregationFn>
TanStack Table Grouping Docs
4
boolean
TanStack Table Core Table Docs
5
boolean
TanStack Table Expanding Docs
6
boolean
TanStack Table Pagination Docs
7
(MRT_FilterOption | string)[] | null
8
'onEnd' | 'onChange'
'onEnd'
TanStack Table Column Sizing Docs
9
boolean
false
TanStack Table Core Table Docs
10
boolean
false
TanStack Table Core Table Docs
11
boolean
false
TanStack Table Core Table Docs
12
boolean
false
TanStack Table Core Table Docs
13
boolean
false
TanStack Table Core Table Docs
14
Partial<MRT_ColumnDef<TData>>
15
{ [key: string]: MRT_ColumnDef<TData> }
16
'cell' | 'row' | 'table'
'row'
17
boolean
true
18
boolean
false
19
boolean
true
20
boolean
false
21
boolean
false
22
boolean
true
23
boolean
24
boolean
25
boolean
true
26
boolean
27
boolean
true
28
boolean
29
boolean
true
30
boolean
true
31
boolean
true
32
boolean
true
33
boolean
true
34
boolean
35
boolean
true
36
boolean
37
boolean
true
38
boolean
39
boolean
true
40
boolean
41
boolean
42
boolean
43
boolean
Row Numbers Feature Guide
44
boolean
45
boolean
46
boolean
47
boolean
true
48
boolean
true
49
boolean
true
50
boolean
51
boolean
52
boolean
true
53
boolean
true
54
boolean
true
55
boolean
true
56
boolean
true
57
(dataRow: TData) => TData[]
58
Record<string, FilterFn>
TanStack Table Filters Docs
59
boolean
60
(column: Column<TData, unknown>) => boolean
61
(table: Table<TData>) => () => RowModel<TData>
TanStack Table Core Table Docs
62
() => MRT_RowModel<TData>
63
() => Map<any, number>
TanStack Table Filters Docs
64
() => RowModel<TData>
TanStack Table Filters Docs
65
() => Map<any, number>
TanStack Table Filters Docs
66
() => RowModel<TData>
TanStack Table Filters Docs
67
(table: Table<TData>) => () => RowModel<TData>
TanStack Table Grouping Docs
68
(row: Row<TData>) => boolean
TanStack Table Expanding Docs
69
() => MRT_RowModel<TData>
70
(row: Row<TData>) => boolean
TanStack Table Expanding Docs
71
(
originalRow: TData,
index: number,
parent?: Row<TData>
) => string
TanStack Table Core Table Docs
72
(table: Table<TData>) => () => RowModel<TData>
TanStack Table Sorting Docs
73
(
originalRow: TData,
index: number
) => undefined | TData[]
TanStack Table Core Table Docs
74
MRT_FilterOption
75
(MRT_FilterOption | string)[] | null
76
false | 'reorder' | 'remove'
reorder
TanStack Table Grouping Docs
77
Partial<MRT_Icons>;
78
Partial<MRT_TableState<TData>>
Table State Management Guide
79
(e: unknown) => boolean
TanStack Table Sorting Docs
80
MRT_Localization
Localization (i18n) Guide
81
boolean
TanStack Table Expanding Docs
82
boolean
TanStack Table Filters Docs
83
boolean
TanStack Table Grouping Docs
84
boolean
TanStack Table Pagination Docs
85
boolean
TanStack Table Sorting Docs
86
number
TanStack Table Sorting Docs
87
'cell' | 'row' | 'table-body'
Memoize Components Guide
88
<T>(defaultOptions: T, options: Partial<T>) => T
TanStack Table Core Docs
89
TableMeta
TanStack Table Core Docs
90
ToolbarProps | ({ table }) => ToolbarProps
Material UI Toolbar Props
91
IconButtonProps | ({ table }) => IconButtonProps
Material UI IconButton Props
92
IconButtonProps | ({ row, table }) => IconButtonProps
Material UI IconButton Props
93
LinearProgressProps | ({ isTopToolbar, table }) => LinearProgressProps
Material UI LinearProgress Props
94
TextFieldProps | ({ table }) => TextFieldProps
Material UI TextField Props
95
CheckboxProps | ({ table }) => CheckboxProps
Material UI Checkbox Props
96
CheckboxProps | ({ row, table }) => CheckboxProps
Material UI Checkbox Props
97
ButtonProps | ({ cell, column, row, table }) => ButtonProps
Material UI Button Props
98
TextFieldProps | ({ cell, column, row, table }) => TextFieldProps
Material UI TextField Props
99
TableCellProps | ({ cell, column, row, table }) => TableCellProps
Material UI TableCell Props
100
SkeletonProps | ({ cell, column, row, table }) => SkeletonProps
Material UI Skeleton Props
101
TableBodyProps | ({ table }) => TableBodyProps
Material UI TableBody Props
102
IconButtonProps | ({ row, table }) => IconButtonProps
Material UI IconButton Props
103
TableRowProps | ({ row, table }) => TableRowProps
{ hover: true }
Material UI TableRow Props
104
TableContainerProps | ({ table }) => TableContainerProps
Material UI TableContainer Props
105
TableRowProps | ({ row, table }) => TableRowProps
Material UI TableRow Props
106
TableCellProps| ({table, column}) => TableCellProps
Material UI TableCell Props
107
TableFooterProps | ({ table }) => TableFooterProps);
Material UI TableFooter Props
108
TableRowProps | ({table, footerGroup}) => TableRowProps
Material UI TableRow Props
109
IconButtonProps | (({table, column}) => IconButtonProps);
Material UI IconButton Props
110
IconButtonProps | ({table, column}) => IconButtonProps
Material UI IconButton Props
111
CheckboxProps | ({ column, table}) => CheckboxProps
Material UI Checkbox Props
112
TextFieldProps | ({ table, column, rangeFilterIndex}) => TextFieldProps
Material UI TextField Props
113
TableCellProps | ({ table, column}) => TableCellProps
Material UI TableCell Props
114
TableHeadProps | ({ table }) => TableHeadProps
Material UI TableHead Props
115
TableRowProps | ({ table, headerGroup}) => TableRowProps
Material UI TableRow Props
116
Partial<TablePaginationProps> | ({ table }) => Partial<TablePaginationProps>
Material UI TablePagination Props
117
PaperProps | ({ table }} => PaperProps
MUI Paper API Docs
118
TableProps
MUI TableProps API Docs
119
ChipProps| ({ table }} => ChipProps
Material UI Chip Props
120
AlertProps | ({ table }) => AlertProps
Material UI Alert Props
121
ToolbarProps | ({ table }) => ToolbarProps
Material UI Toolbar Props
122
OnChangeFn<ColumnFiltersState>
TanStack Table Filter Docs
123
OnChangeFn<ColumnOrderState>
If provided, this function will be called with an updaterFn when state.columnOrder changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.
TanStack Table Column Ordering Docs
124
OnChangeFn<ColumnPinningState>
TanStack Table Column Pinning Docs
125
OnChangeFn<ColumnSizingState>
TanStack Table Column Sizing Docs
126
OnChangeFn<ColumnSizingInfoState>
TanStack Table Column Sizing Docs
127
OnChangeFn<ColumnVisibilityState>
TanStack Table Column Visibility Docs
128
OnChangeFn<DensityState>
129
OnChangeFn<MRT_Column<TData> | null>
130
OnChangeFn<MRT_Row<TData> | null>
131
OnChangeFn<MRT_Cell<TData> | null>
132
OnChangeFn<MRT_Row<TData> | null>
133
({ exitEditingMode, row, table, values}) => Promise<void> | void
134
OnChangeFn<ExpandedState>
TanStack Table Expanding Docs
135
OnChangeFn<{ [key: string]: MRT_FilterOption }>
136
OnChangeFn<GlobalFilterState>
TanStack Table Filters Docs
137
OnChangeFn<GlobalFilterState>
TanStack Table Filters Docs
138
OnChangeFn<GroupingState>
TanStack Table Grouping Docs
139
OnChangeFn<MRT_Column<TData> | null>
140
OnChangeFn<MRT_Row<TData> | null>
141
OnChangeFn<boolean>
142
OnChangeFn<PaginationState>
TanStack Table Pagination Docs
143
OnChangeFn<RowSelectionState>
TanStack Table Row Selection Docs
144
OnChangeFn<boolean>
145
OnChangeFn<boolean>
146
OnChangeFn<boolean>
147
OnChangeFn<SortingState>
TanStack Table Sorting Docs
148
number
TanStack Table Pagination Docs
149
boolean
TanStack Table Expanding Docs
150
'first' | 'last'
151
'first' | 'last'
152
'left' | 'right'
153
'bottom' | 'top' | 'both'
154
'bottom' | 'top' | 'none'
155
'bottom' | 'top' | 'both' | 'none'
156
ReactNode | ({ table }) => ReactNode
157
({ table }) => ReactNode
158
({ closeMenu, column, table }) => ReactNode[]
159
({ column, internalFilterOptions, onSelectFilterMode, table }) => ReactNode[]
160
({ row, table }) => ReactNode
161
({ internalFilterOptions, onSelectFilterMode, table }) => ReactNode[]
162
({ closeMenu, row, table }) => ReactNode[]
163
({ cell, row, table }) => ReactNode
164
({ table}) => ReactNode
165
ReactNode | ({ table }) => ReactNode
166
({ table }) => ReactNode
167
number
168
'original' | 'static'
'original'
169
'all' | 'page'
page
170
boolean
TanStack Table Sorting Docs
171
Record<string, SortingFn>
TanStack Table Sorting Docs
172
Partial<MRT_TableState<TData>>
Table State Management Guide
173
MutableRefObject<MRT_TableInstance<TData> | null>
174
MutableRefObject<Virtualizer | null>
175
Partial<VirtualizerOptions<HTMLDivElement>>

Wanna see the source code for this table? Check it out down below!


Source Code

1import React, { FC, useEffect, useMemo, useState } from 'react';
2import Link from 'next/link';
3import MaterialReactTable, {
4 MaterialReactTableProps,
5 MRT_ColumnDef,
6} from 'material-react-table';
7import {
8 Link as MuiLink,
9 Typography,
10 useMediaQuery,
11 useTheme,
12} from '@mui/material';
13import { SampleCodeSnippet } from '../mdx/SampleCodeSnippet';
14import { PropRow, rootProps } from './rootProps';
15
16interface Props {
17 onlyProps?: Set<keyof MaterialReactTableProps>;
18}
19
20const RootPropTable: FC<Props> = ({ onlyProps }) => {
21 const theme = useTheme();
22 const isDesktop = useMediaQuery('(min-width: 1200px)');
23
24 const columns = useMemo(
25 () =>
26 [
27 {
28 enableClickToCopy: true,
29 header: 'Prop Name',
30 accessorKey: 'propName',
31 muiTableBodyCellCopyButtonProps: ({ cell }) => ({
32 className: 'prop',
33 // component: 'a',
34 id: `${cell.getValue<string>()}-prop`,
35 // href: `#${cell.getValue<string>()}-prop`,
36 }),
37 Cell: ({ cell, row }) =>
38 row.original?.required ? (
39 <strong style={{ color: theme.palette.primary.dark }}>
40 {cell.getValue<string>()}*
41 </strong>
42 ) : (
43 cell.getValue<string>()
44 ),
45 },
46 {
47 header: 'Type',
48 accessorKey: 'type',
49 enableGlobalFilter: false,
50 Cell: ({ cell }) => (
51 <SampleCodeSnippet
52 className="language-js"
53 enableCopyButton={false}
54 style={{
55 backgroundColor: 'transparent',
56 fontSize: '0.9rem',
57 margin: 0,
58 padding: 0,
59 minHeight: 'unset',
60 }}
61 >
62 {cell.getValue<string>()}
63 </SampleCodeSnippet>
64 ),
65 },
66 {
67 header: 'Required',
68 accessorKey: 'required',
69 enableGlobalFilter: false,
70 },
71 {
72 header: 'Default Value',
73 accessorKey: 'defaultValue',
74 enableGlobalFilter: false,
75 Cell: ({ cell }) => (
76 <SampleCodeSnippet
77 className="language-js"
78 enableCopyButton={false}
79 style={{
80 backgroundColor: 'transparent',
81 fontSize: '0.9rem',
82 margin: 0,
83 padding: 0,
84 minHeight: 'unset',
85 }}
86 >
87 {cell.getValue<string>()}
88 </SampleCodeSnippet>
89 ),
90 },
91 {
92 header: 'Description',
93 accessorKey: 'description',
94 enableGlobalFilter: false,
95 },
96 {
97 header: 'More Info Links',
98 accessorKey: 'link',
99 disableFilters: true,
100 enableGlobalFilter: false,
101 Cell: ({ cell, row }) => (
102 <Link href={cell.getValue() as string} passHref>
103 <MuiLink
104 color={
105 row.original.source === 'MRT'
106 ? 'text.primary'
107 : row.original.source === 'Material UI'
108 ? 'primary.main'
109 : row.original.source === 'TanStack Table'
110 ? 'secondary.main'
111 : undefined
112 }
113 target={
114 (cell.getValue() as string).startsWith('http')
115 ? '_blank'
116 : undefined
117 }
118 rel="noreferrer"
119 >
120 {row.original?.linkText}
121 </MuiLink>
122 </Link>
123 ),
124 },
125 ] as MRT_ColumnDef<PropRow>[],
126 [theme],
127 );
128
129 const [columnPinning, setColumnPinning] = useState({});
130
131 useEffect(() => {
132 if (typeof window !== 'undefined') {
133 if (isDesktop) {
134 setColumnPinning({
135 left: ['mrt-row-expand', 'mrt-row-numbers', 'propName'],
136 right: ['link'],
137 });
138 } else {
139 setColumnPinning({});
140 }
141 }
142 }, [isDesktop]);
143
144 const data = useMemo(() => {
145 if (onlyProps) {
146 return rootProps.filter(({ propName }) => onlyProps.has(propName));
147 }
148 return rootProps;
149 }, [onlyProps]);
150
151 return (
152 <MaterialReactTable
153 columns={columns}
154 data={data}
155 displayColumnDefOptions={{
156 'mrt-row-numbers': {
157 size: 10,
158 },
159 'mrt-row-expand': {
160 size: 10,
161 },
162 }}
163 enableColumnActions={!onlyProps}
164 enableColumnFilterModes
165 enablePagination={false}
166 enablePinning
167 enableRowNumbers
168 enableBottomToolbar={false}
169 enableTopToolbar={!onlyProps}
170 initialState={{
171 columnVisibility: { required: false, description: false },
172 density: 'compact',
173 showGlobalFilter: true,
174 sorting: [
175 { id: 'required', desc: true },
176 { id: 'propName', desc: false },
177 ],
178 }}
179 muiSearchTextFieldProps={{
180 placeholder: 'Search All Props',
181 sx: { minWidth: '18rem' },
182 variant: 'outlined',
183 }}
184 muiTablePaperProps={{
185 sx: { mb: '1.5rem' },
186 id: onlyProps ? 'relevant-props-table' : 'props-table',
187 }}
188 positionGlobalFilter="left"
189 renderDetailPanel={({ row }) => (
190 <Typography
191 color={row.original.description ? 'secondary.main' : 'text.secondary'}
192 >
193 {row.original.description || 'No Description Provided... Yet...'}
194 </Typography>
195 )}
196 rowNumberMode="static"
197 onColumnPinningChange={setColumnPinning}
198 state={{ columnPinning }}
199 />
200 );
201};
202
203export default RootPropTable;
204