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/>
# | Prop Name | Type | Default Value | More Info Links | |
---|---|---|---|---|---|
1 |
| Column Options API Reference | |||
The array of column defs to use for the table. | |||||
2 |
| Usage Docs | |||
The data for the table to display. This array should match the type you provided to table.setRowType<...>, but in theory could be an array of anything. It's common for each item in the array to be an object of key/values but this is not required. Columns can access this data via string/index or a functional accessor to return anything they want. When the data option changes reference (compared via Object.is), the table will reprocess the data. Any other data processing that relies on the core data model (such as grouping, sorting, filtering, etc) will also be reprocessed. | |||||
3 |
| TanStack Table Grouping Docs | |||
This option allows you to define custom aggregation functions that can be referenced in a column's aggregationFn option by their key | |||||
4 |
| TanStack Table Core Table Docs | |||
Set this option to override any of the autoReset... feature options. | |||||
5 |
| TanStack Table Expanding Docs | |||
Enable this setting to automatically reset the expanded state of the table when grouping state changes. | |||||
6 |
| TanStack Table Pagination Docs | |||
If set to true, pagination will be reset to the first page when page-altering state changes eg. data is updated, filters change, grouping changes, etc. | |||||
7 |
| ||||
No Description Provided... Yet... | |||||
8 |
|
| TanStack Table Column Sizing Docs | ||
Determines when the columnSizing state is updated. onChange updates the state when the user is dragging the resize handle. onEnd updates the state when the user releases the resize handle. | |||||
9 |
|
| TanStack Table Core Table Docs | ||
Set this option to true to output all debugging information to the console. | |||||
10 |
|
| TanStack Table Core Table Docs | ||
Set this option to true to output column debugging information to the console. | |||||
11 |
|
| TanStack Table Core Table Docs | ||
Set this option to true to output header debugging information to the console. | |||||
12 |
|
| TanStack Table Core Table Docs | ||
Set this option to true to output row debugging information to the console. | |||||
13 |
|
| TanStack Table Core Table Docs | ||
Set this option to true to output table debugging information to the console. | |||||
14 |
| ||||
Default column options to use for all column defs supplied to the table. This is useful for providing default cell/header/footer renderers, sorting/filtering/grouping options, etc. | |||||
15 |
| ||||
Customize and override the column definition options for the built-in display columns. (Select, Expand, Row Actions, etc.) | |||||
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 |
|
| |||
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 |
|
| |||
No Description Provided... Yet... | |||||
32 |
|
| |||
No Description Provided... Yet... | |||||
33 |
|
| |||
No Description Provided... Yet... | |||||
34 |
| ||||
No Description Provided... Yet... | |||||
35 |
|
| |||
No Description Provided... Yet... | |||||
36 |
| ||||
No Description Provided... Yet... | |||||
37 |
|
| |||
If true, the user can select multiple rows at once with a checkbox. If false, the user can only select one row at a time with a radio button. | |||||
38 |
| ||||
No Description Provided... Yet... | |||||
39 |
|
| |||
No Description Provided... Yet... | |||||
40 |
| ||||
No Description Provided... Yet... | |||||
41 |
| ||||
No Description Provided... Yet... | |||||
42 |
| ||||
No Description Provided... Yet... | |||||
43 |
| Row Numbers Feature Guide | |||
No Description Provided... Yet... | |||||
44 |
| ||||
No Description Provided... Yet... | |||||
45 |
| ||||
No Description Provided... Yet... | |||||
46 |
| ||||
No Description Provided... Yet... | |||||
47 |
|
| |||
No Description Provided... Yet... | |||||
48 |
|
| |||
No Description Provided... Yet... | |||||
49 |
|
| |||
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 |
| TanStack Table Filters Docs | |||
This option allows you to define custom filter functions that can be referenced in a column's filterFn option by their key | |||||
59 |
| ||||
No Description Provided... Yet... | |||||
60 |
| ||||
No Description Provided... Yet... | |||||
61 |
| TanStack Table Core Table Docs | |||
Material React Table uses the default core row model function from TanStack Table, but you can override its implementation here. It is called once per table and should return a new function which will calculate and return the row model for the table. | |||||
62 |
| ||||
No Description Provided... Yet... | |||||
63 |
| TanStack Table Filters Docs | |||
A function that computes and returns a min/max tuple derived from column.getFacetedRowModel. Useful for displaying faceted result values. | |||||
64 |
| TanStack Table Filters Docs | |||
Returns the row model with all other column filters applied, excluding its own filter. Useful for displaying faceted result counts. | |||||
65 |
| TanStack Table Filters Docs | |||
A function that computes and returns a Map of unique values and their occurrences derived from column.getFacetedRowModel. Useful for displaying faceted result values. | |||||
66 |
| TanStack Table Filters Docs | |||
Returns the row model with all other column filters applied, excluding its own filter. Useful for displaying faceted result counts. | |||||
67 |
| TanStack Table Grouping Docs | |||
Returns the row model after grouping has taken place, but no further. | |||||
68 |
| TanStack Table Expanding Docs | |||
If provided, allows you to override the default behavior of determining whether a row is currently expanded. | |||||
69 |
| ||||
No Description Provided... Yet... | |||||
70 |
| TanStack Table Expanding Docs | |||
If provided, allows you to override the default behavior of determining whether a row can be expanded. | |||||
71 |
| TanStack Table Core Table Docs | |||
This optional function is used to derive a unique ID for any given row. If not provided the rows index is used (nested rows join together with . using their grandparents' index eg. index.index.index). If you need to identify individual rows that are originating from any server-side operations, it's suggested you use this function to return an ID that makes sense regardless of network IO/ambiguity eg. a userId, taskId, database ID field, etc. | |||||
72 |
| TanStack Table Sorting Docs | |||
This function is used to retrieve the sorted row model. If using server-side sorting, this function is not required. To use client-side sorting, pass the exported getSortedRowModel() from your adapter to your table or implement your own. | |||||
73 |
| TanStack Table Core Table Docs | |||
This optional function is used to access the sub rows for any given row. If you are using nested rows, you will need to use this function to return the sub rows object (or undefined) from the row. | |||||
74 |
| ||||
The filter function to use for global filtering. | |||||
75 |
| ||||
No Description Provided... Yet... | |||||
76 |
|
| TanStack Table Grouping Docs | ||
Grouping columns are automatically reordered by default to the start of the columns list. If you would rather remove them or leave them as-is, set the appropriate mode here. | |||||
77 |
| ||||
No Description Provided... Yet... | |||||
78 |
| Table State Management Guide | |||
Use this option to optionally pass initial state to the table. This state will be used when resetting various table states either automatically by the table (eg. options.autoResetPagination) or via functions like table.resetRowSelection(). Most reset function allow you optionally pass a flag to reset to a blank/default state instead of the initial state. Table state will not be reset when this object changes, which also means that the initial state object does not need to be stable. | |||||
79 |
| TanStack Table Sorting Docs | |||
Pass a custom function that will be used to determine if a multi-sort event should be triggered. It is passed the event from the sort toggle handler and should return true if the event should trigger a multi-sort. | |||||
80 |
| Localization (i18n) Guide | |||
No Description Provided... Yet... | |||||
81 |
| TanStack Table Expanding Docs | |||
Enables manual row expansion. If this is set to true, getExpandedRowModel will not be used to expand rows and you would be expected to perform the expansion in your own data model. This is useful if you are doing server-side expansion. | |||||
82 |
| TanStack Table Filters Docs | |||
Disables the getFilteredRowModel from being used to filter data. This may be useful if your table needs to dynamically support both client-side and server-side filtering. | |||||
83 |
| TanStack Table Grouping Docs | |||
Enables manual grouping. If this option is set to true, the table will not automatically group rows using getGroupedRowModel() and instead will expect you to manually group the rows before passing them to the table. This is useful if you are doing server-side grouping and aggregation. | |||||
84 |
| TanStack Table Pagination Docs | |||
Enables manual pagination. If this option is set to true, the table will not automatically paginate rows using getPaginationRowModel() and instead will expect you to manually paginate the rows before passing them to the table. This is useful if you are doing server-side pagination and aggregation. | |||||
85 |
| TanStack Table Sorting Docs | |||
Enables manual sorting for the table. If this is true, you will be expected to sort your data before it is passed to the table. This is useful if you are doing server-side sorting. | |||||
86 |
| TanStack Table Sorting Docs | |||
Set a maximum number of columns that can be multi-sorted. | |||||
87 |
| Memoize Components Guide | |||
No Description Provided... Yet... | |||||
88 |
| TanStack Table Core Docs | |||
This option is used to optionally implement the merging of table options. Some framework like solid-js use proxies to track reactivity and usage, so merging reactive objects needs to be handled carefully. This option inverts control of this process to the adapter. | |||||
89 |
| TanStack Table Core Docs | |||
You can pass any object to options.meta and access it anywhere the table is available via table.options.meta This type is global to all tables. | |||||
90 |
| Material UI Toolbar Props | |||
No Description Provided... Yet... | |||||
91 |
| Material UI IconButton Props | |||
No Description Provided... Yet... | |||||
92 |
| Material UI IconButton Props | |||
No Description Provided... Yet... | |||||
93 |
| Material UI LinearProgress Props | |||
No Description Provided... Yet... | |||||
94 |
| Material UI TextField Props | |||
No Description Provided... Yet... | |||||
95 |
| Material UI Checkbox Props | |||
No Description Provided... Yet... | |||||
96 |
| Material UI Checkbox Props | |||
No Description Provided... Yet... | |||||
97 |
| Material UI Button Props | |||
No Description Provided... Yet... | |||||
98 |
| Material UI TextField Props | |||
No Description Provided... Yet... | |||||
99 |
| Material UI TableCell Props | |||
No Description Provided... Yet... | |||||
100 |
| Material UI Skeleton Props | |||
No Description Provided... Yet... | |||||
101 |
| Material UI TableBody Props | |||
No Description Provided... Yet... | |||||
102 |
| Material UI IconButton Props | |||
No Description Provided... Yet... | |||||
103 |
|
| Material UI TableRow Props | ||
No Description Provided... Yet... | |||||
104 |
| Material UI TableContainer Props | |||
No Description Provided... Yet... | |||||
105 |
| Material UI TableRow Props | |||
No Description Provided... Yet... | |||||
106 |
| Material UI TableCell Props | |||
No Description Provided... Yet... | |||||
107 |
| Material UI TableFooter Props | |||
No Description Provided... Yet... | |||||
108 |
| Material UI TableRow Props | |||
No Description Provided... Yet... | |||||
109 |
| Material UI IconButton Props | |||
No Description Provided... Yet... | |||||
110 |
| Material UI IconButton Props | |||
No Description Provided... Yet... | |||||
111 |
| Material UI Checkbox Props | |||
No Description Provided... Yet... | |||||
112 |
| Material UI TextField Props | |||
No Description Provided... Yet... | |||||
113 |
| Material UI TableCell Props | |||
No Description Provided... Yet... | |||||
114 |
| Material UI TableHead Props | |||
No Description Provided... Yet... | |||||
115 |
| Material UI TableRow Props | |||
No Description Provided... Yet... | |||||
116 |
| Material UI TablePagination Props | |||
No Description Provided... Yet... | |||||
117 |
| MUI Paper API Docs | |||
No Description Provided... Yet... | |||||
118 |
| MUI TableProps API Docs | |||
No Description Provided... Yet... | |||||
119 |
| Material UI Chip Props | |||
No Description Provided... Yet... | |||||
120 |
| Material UI Alert Props | |||
No Description Provided... Yet... | |||||
121 |
| Material UI Toolbar Props | |||
No Description Provided... Yet... | |||||
122 |
| TanStack Table Filter Docs | |||
If provided, this function will be called with an updaterFn when state.columnFilters 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. | |||||
123 |
|
| TanStack Table Column Ordering Docs | ||
No Description Provided... Yet... | |||||
124 |
| TanStack Table Column Pinning Docs | |||
If provided, this function will be called with an updaterFn when state.columnPinning 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. | |||||
125 |
| TanStack Table Column Sizing Docs | |||
This optional function will be called when the columnSizing state changes. If you provide this function, you will be responsible for maintaining its state yourself. You can pass this state back to the table via the state.columnSizing table option. | |||||
126 |
| TanStack Table Column Sizing Docs | |||
This optional function will be called when the columnSizingInfo state changes. If you provide this function, you will be responsible for maintaining its state yourself. You can pass this state back to the table via the state.columnSizingInfo table option. | |||||
127 |
| TanStack Table Column Visibility Docs | |||
If provided, this function will be called with an updaterFn when state.columnVisibility 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. | |||||
128 |
| ||||
No Description Provided... Yet... | |||||
129 |
| ||||
No Description Provided... Yet... | |||||
130 |
| ||||
No Description Provided... Yet... | |||||
131 |
| ||||
No Description Provided... Yet... | |||||
132 |
| ||||
No Description Provided... Yet... | |||||
133 |
| ||||
No Description Provided... Yet... | |||||
134 |
| TanStack Table Expanding Docs | |||
This function is called when the expanded table state changes. If a function is provided, you will be responsible for managing this state on your own. To pass the managed state back to the table, use the tableOptions.state.expanded option. | |||||
135 |
| ||||
No Description Provided... Yet... | |||||
136 |
| TanStack Table Filters Docs | |||
If provided, this function will be called with an updaterFn when state.globalFilter 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. | |||||
137 |
| TanStack Table Filters Docs | |||
If provided, this function will be called with an updaterFn when state.globalFilter 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. | |||||
138 |
| TanStack Table Grouping Docs | |||
If this function is provided, it will be called when the grouping state changes and you will be expected to manage the state yourself. You can pass the managed state back to the table via the tableOptions.state.grouping option. | |||||
139 |
| ||||
No Description Provided... Yet... | |||||
140 |
| ||||
No Description Provided... Yet... | |||||
141 |
| ||||
No Description Provided... Yet... | |||||
142 |
| TanStack Table Pagination Docs | |||
If this function is provided, it will be called when the pagination state changes and you will be expected to manage the state yourself. You can pass the managed state back to the table via the tableOptions.state.pagination option. | |||||
143 |
| TanStack Table Row Selection Docs | |||
If provided, this function will be called with an updaterFn when state.rowSelection 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. | |||||
144 |
| ||||
No Description Provided... Yet... | |||||
145 |
| ||||
No Description Provided... Yet... | |||||
146 |
| ||||
No Description Provided... Yet... | |||||
147 |
| TanStack Table Sorting Docs | |||
If provided, this function will be called with an updaterFn when state.sorting 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. | |||||
148 |
| TanStack Table Pagination Docs | |||
When manually controlling pagination, you should supply a total pageCount value to the table if you know it. If you do not know how many pages there are, you can set this to -1. | |||||
149 |
| TanStack Table Expanding Docs | |||
If true expanded rows will be paginated along with the rest of the table (which means expanded rows may span multiple pages). If false expanded rows will not be considered for pagination (which means expanded rows will always render on their parents page. This also means more rows will be rendered than the set page size) | |||||
150 |
| ||||
No Description Provided... Yet... | |||||
151 |
| ||||
No Description Provided... Yet... | |||||
152 |
| ||||
No Description Provided... Yet... | |||||
153 |
| ||||
No Description Provided... Yet... | |||||
154 |
| ||||
No Description Provided... Yet... | |||||
155 |
| ||||
No Description Provided... Yet... | |||||
156 |
| ||||
No Description Provided... Yet... | |||||
157 |
| ||||
No Description Provided... Yet... | |||||
158 |
| ||||
No Description Provided... Yet... | |||||
159 |
| ||||
No Description Provided... Yet... | |||||
160 |
| ||||
No Description Provided... Yet... | |||||
161 |
| ||||
No Description Provided... Yet... | |||||
162 |
| ||||
No Description Provided... Yet... | |||||
163 |
| ||||
No Description Provided... Yet... | |||||
164 |
| ||||
No Description Provided... Yet... | |||||
165 |
| ||||
No Description Provided... Yet... | |||||
166 |
| ||||
No Description Provided... Yet... | |||||
167 |
| ||||
No Description Provided... Yet... | |||||
168 |
|
| |||
No Description Provided... Yet... | |||||
169 |
|
| |||
No Description Provided... Yet... | |||||
170 |
| TanStack Table Sorting Docs | |||
Set to true for sorting toggles on this column to start in the descending direction. | |||||
171 |
| TanStack Table Sorting Docs | |||
This option allows you to define custom sorting functions that can be referenced in a column's sortingFn option by their key. Example: | |||||
172 |
| Table State Management Guide | |||
No Description Provided... Yet... | |||||
173 |
| ||||
No Description Provided... Yet... | |||||
174 |
| ||||
No Description Provided... Yet... | |||||
175 |
| ||||
No Description Provided... Yet... |
Wanna see the source code for this table? Check it out down below!
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';1516interface Props {17 onlyProps?: Set<keyof MaterialReactTableProps>;18}1920const RootPropTable: FC<Props> = ({ onlyProps }) => {21 const theme = useTheme();22 const isDesktop = useMediaQuery('(min-width: 1200px)');2324 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 <SampleCodeSnippet52 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 <SampleCodeSnippet77 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 <MuiLink104 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 : undefined112 }113 target={114 (cell.getValue() as string).startsWith('http')115 ? '_blank'116 : undefined117 }118 rel="noreferrer"119 >120 {row.original?.linkText}121 </MuiLink>122 </Link>123 ),124 },125 ] as MRT_ColumnDef<PropRow>[],126 [theme],127 );128129 const [columnPinning, setColumnPinning] = useState({});130131 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]);143144 const data = useMemo(() => {145 if (onlyProps) {146 return rootProps.filter(({ propName }) => onlyProps.has(propName));147 }148 return rootProps;149 }, [onlyProps]);150151 return (152 <MaterialReactTable153 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 enableColumnFilterModes165 enableColumnOrdering={!onlyProps}166 enablePagination={false}167 enablePinning168 enableRowNumbers169 enableBottomToolbar={false}170 enableTopToolbar={!onlyProps}171 initialState={{172 columnVisibility: { required: false, description: false },173 density: 'compact',174 showGlobalFilter: true,175 sorting: [176 { id: 'required', desc: true },177 { id: 'propName', desc: false },178 ],179 }}180 muiSearchTextFieldProps={{181 placeholder: 'Search All Props',182 sx: { minWidth: '18rem' },183 variant: 'outlined',184 }}185 muiTablePaperProps={{186 sx: { mb: '1.5rem' },187 id: onlyProps ? 'relevant-props-table' : 'props-table',188 }}189 positionGlobalFilter="left"190 renderDetailPanel={({ row }) => (191 <Typography192 color={row.original.description ? 'secondary.main' : 'text.secondary'}193 >194 {row.original.description || 'No Description Provided... Yet...'}195 </Typography>196 )}197 rowNumberMode="static"198 state={{ columnPinning }}199 />200 );201};202203export default RootPropTable;204