Props
Many of the props that you can pass to
<MaterialReactTable />
are the same as the ones that you can pass to the TanStack Table useReactTable hook.
Here is a list of all the props that 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 aggegationFn 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 |
| ||||
No Description Provided... Yet... | |||||
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 | |||||
No Description Provided... Yet... | |||||
65 | |||||
No Description Provided... Yet... | |||||
66 | |||||
No Description Provided... Yet... | |||||
67 | |||||
No Description Provided... Yet... | |||||
68 | |||||
No Description Provided... Yet... | |||||
69 | |||||
No Description Provided... Yet... | |||||
70 | |||||
No Description Provided... Yet... | |||||
71 | |||||
No Description Provided... Yet... | |||||
72 | |||||
No Description Provided... Yet... | |||||
73 | |||||
No Description Provided... Yet... | |||||
74 | |||||
No Description Provided... Yet... | |||||
75 |
| ||||
No Description Provided... Yet... | |||||
76 | |||||
No Description Provided... Yet... | |||||
77 | |||||
No Description Provided... Yet... | |||||
78 | |||||
No Description Provided... Yet... | |||||
79 | |||||
No Description Provided... Yet... | |||||
80 | |||||
No Description Provided... Yet... | |||||
81 | |||||
No Description Provided... Yet... | |||||
82 | |||||
No Description Provided... Yet... | |||||
83 | |||||
No Description Provided... Yet... | |||||
84 | |||||
No Description Provided... Yet... | |||||
85 | |||||
No Description Provided... Yet... | |||||
86 | |||||
No Description Provided... Yet... | |||||
87 | |||||
No Description Provided... Yet... | |||||
88 | |||||
No Description Provided... Yet... | |||||
89 | |||||
No Description Provided... Yet... | |||||
90 |
| Material UI IconButton Props | |||
No Description Provided... Yet... | |||||
91 |
| Material UI IconButton Props | |||
No Description Provided... Yet... | |||||
92 |
| Material UI LinearProgress Props | |||
No Description Provided... Yet... | |||||
93 |
| Material UI TextField Props | |||
No Description Provided... Yet... | |||||
94 |
| Material UI Checkbox Props | |||
No Description Provided... Yet... | |||||
95 |
| Material UI Checkbox Props | |||
No Description Provided... Yet... | |||||
96 |
| Material UI Button Props | |||
No Description Provided... Yet... | |||||
97 |
| Material UI TextField Props | |||
No Description Provided... Yet... | |||||
98 |
| Material UI TableCell Props | |||
No Description Provided... Yet... | |||||
99 |
| Material UI Skeleton Props | |||
No Description Provided... Yet... | |||||
100 | Material UI TableBody Props | ||||
No Description Provided... Yet... | |||||
101 | |||||
No Description Provided... Yet... | |||||
102 | |||||
No Description Provided... Yet... | |||||
103 | |||||
No Description Provided... Yet... | |||||
104 | |||||
No Description Provided... Yet... | |||||
105 | |||||
No Description Provided... Yet... | |||||
106 | |||||
No Description Provided... Yet... | |||||
107 | |||||
No Description Provided... Yet... | |||||
108 | |||||
No Description Provided... Yet... | |||||
109 | |||||
No Description Provided... Yet... | |||||
110 | |||||
No Description Provided... Yet... | |||||
111 | |||||
No Description Provided... Yet... | |||||
112 | |||||
No Description Provided... Yet... | |||||
113 | |||||
No Description Provided... Yet... | |||||
114 | |||||
No Description Provided... Yet... | |||||
115 | |||||
No Description Provided... Yet... | |||||
116 | MUI Paper API Docs | ||||
No Description Provided... Yet... | |||||
117 |
| MUI TableProps API Docs | |||
No Description Provided... Yet... | |||||
118 | |||||
No Description Provided... Yet... | |||||
119 | |||||
No Description Provided... Yet... | |||||
120 | |||||
No Description Provided... Yet... | |||||
121 | |||||
No Description Provided... Yet... | |||||
122 | |||||
No Description Provided... Yet... | |||||
123 | |||||
No Description Provided... Yet... | |||||
124 | |||||
No Description Provided... Yet... | |||||
125 | |||||
No Description Provided... Yet... | |||||
126 | |||||
No Description Provided... Yet... | |||||
127 | |||||
No Description Provided... Yet... | |||||
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 | |||||
No Description Provided... Yet... | |||||
135 | |||||
No Description Provided... Yet... | |||||
136 | |||||
No Description Provided... Yet... | |||||
137 | |||||
No Description Provided... Yet... | |||||
138 | |||||
No Description Provided... Yet... | |||||
139 | |||||
No Description Provided... Yet... | |||||
140 | |||||
No Description Provided... Yet... | |||||
141 | |||||
No Description Provided... Yet... | |||||
142 | |||||
No Description Provided... Yet... | |||||
143 | |||||
No Description Provided... Yet... | |||||
144 | |||||
No Description Provided... Yet... | |||||
145 | |||||
No Description Provided... Yet... | |||||
146 | |||||
No Description Provided... Yet... | |||||
147 |
| ||||
No Description Provided... Yet... | |||||
148 | |||||
No Description Provided... Yet... | |||||
149 |
| ||||
No Description Provided... Yet... | |||||
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 | |||||
No Description Provided... Yet... | |||||
171 | |||||
No Description Provided... Yet... | |||||
172 | |||||
No Description Provided... Yet... | |||||
173 | |||||
No Description Provided... Yet... | |||||
174 | |||||
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