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 |
| MRT Column Options API Reference | |||
2 |
| Usage Docs | |||
3 |
| TanStack Table Grouping Docs | |||
4 |
| TanStack Table Core Table Docs | |||
5 |
| TanStack Table Expanding Docs | |||
6 |
| TanStack Table Pagination Docs | |||
7 |
| MRT Column Filtering Docs | |||
8 |
|
| MRT Column Resizing Docs | ||
9 |
| ||||
10 |
| ||||
11 |
|
| TanStack Table Core Table Docs | ||
12 |
|
| TanStack Table Core Table Docs | ||
13 |
|
| TanStack Table Core Table Docs | ||
14 |
|
| TanStack Table Core Table Docs | ||
15 |
|
| TanStack Table Core Table Docs | ||
16 |
| TanStack Table Core Table Docs | |||
17 |
| MRT Display Columns Docs | |||
18 |
|
| MRT Editing Docs | ||
19 |
|
| MRT Customize Toolbars Docs | ||
20 |
|
| MRT Click to Copy Docs | ||
21 |
|
| MRT Column Actions Docs | ||
22 |
|
| MRT Column Ordering DnD Docs | ||
23 |
|
| MRT Column Filtering Docs | ||
24 |
|
| MRT Column Filtering Docs | ||
25 |
| MRT Column Ordering DnD Docs | |||
26 |
| MRT Column Resizing Docs | |||
27 |
| MRT Virtualization Docs | |||
28 |
|
| MRT Density Toggle Docs | ||
29 |
| MRT Editing Docs | |||
30 |
|
| MRT Expanding Sub Rows Docs | ||
31 |
| MRT Expanding Sub Rows Docs | |||
32 |
|
| TanStack Filters Docs | ||
33 |
|
| MRT Full Screen Toggle Docs | ||
34 |
|
| MRT Global Filtering Docs | ||
35 |
|
| MRT Global Filtering Docs | ||
36 |
|
| MRT Global Filtering Docs | ||
37 |
| MRT Aggregation and Grouping Docs | |||
38 |
|
| MRT Column Hiding Docs | ||
39 |
| TanStack Sorting Docs | |||
40 |
|
| MRT Row Selection Docs | ||
41 |
| ||||
42 |
|
| |||
43 |
| ||||
44 |
| ||||
45 |
| ||||
46 |
| Row Numbers Feature Guide | |||
47 |
| ||||
48 |
| ||||
49 |
| MRT Virtualization Docs | |||
50 |
|
| |||
51 |
|
| |||
52 |
|
| |||
53 |
| ||||
54 |
| ||||
55 |
|
| |||
56 |
|
| |||
57 |
|
| |||
58 |
|
| |||
59 |
|
| |||
60 |
| ||||
61 |
| TanStack Table Filters Docs | |||
62 |
|
| TanStack Filtering Docs | ||
63 |
| ||||
64 |
| TanStack Table Core Table Docs | |||
65 |
| ||||
66 |
| TanStack Table Filters Docs | |||
67 |
| TanStack Table Filters Docs | |||
68 |
| TanStack Table Filters Docs | |||
69 |
| TanStack Table Filters Docs | |||
70 |
| TanStack Table Grouping Docs | |||
71 |
| TanStack Table Expanding Docs | |||
72 |
| ||||
73 |
| TanStack Table Expanding Docs | |||
74 |
| TanStack Table Core Table Docs | |||
75 |
| TanStack Table Sorting Docs | |||
76 |
| TanStack Table Core Table Docs | |||
77 |
| ||||
78 |
| ||||
79 |
|
| TanStack Table Grouping Docs | ||
80 |
| ||||
81 |
| Table State Management Guide | |||
82 |
| TanStack Table Sorting Docs | |||
83 |
|
| TODO | ||
84 |
| Localization (i18n) Guide | |||
85 |
| TanStack Table Expanding Docs | |||
86 |
| TanStack Table Filters Docs | |||
87 |
| TanStack Table Grouping Docs | |||
88 |
| TanStack Table Pagination Docs | |||
89 |
| TanStack Table Sorting Docs | |||
90 |
|
| TanStack Table Filtering Docs | ||
91 |
| TanStack Table Sorting Docs | |||
92 |
| Memoize Components Guide | |||
93 |
| TanStack Table Core Docs | |||
94 |
| TanStack Table Core Docs | |||
95 |
| Material UI Toolbar Props | |||
96 |
| Material UI IconButton Props | |||
97 |
| Material UI IconButton Props | |||
98 |
| Material UI LinearProgress Props | |||
99 |
| Material UI TextField Props | |||
100 |
| Material UI Checkbox Props | |||
101 |
| Material UI Checkbox Props | |||
102 |
| Material UI Button Props | |||
103 |
| Material UI TextField Props | |||
104 |
| Material UI TableCell Props | |||
105 |
| Material UI Skeleton Props | |||
106 |
| Material UI TableBody Props | |||
107 |
| Material UI IconButton Props | |||
108 |
|
| Material UI TableRow Props | ||
109 |
| Material UI TableContainer Props | |||
110 |
| Material UI TableCell Props | |||
111 |
| Material UI TableCell Props | |||
112 |
| Material UI TableFooter Props | |||
113 |
| Material UI TableRow Props | |||
114 |
| Material UI IconButton Props | |||
115 |
| Material UI IconButton Props | |||
116 |
| Material UI Checkbox Props | |||
117 |
| Material UI TextField Props | |||
118 |
| Material UI TableCell Props | |||
119 |
| Material UI TableHead Props | |||
120 |
| Material UI TableRow Props | |||
121 |
| Material UI TablePagination Props | |||
122 |
| MUI Paper API Docs | |||
123 |
| MUI TableProps API Docs | |||
124 |
| Material UI Chip Props | |||
125 |
| Material UI Alert Props | |||
126 |
| Material UI Toolbar Props | |||
127 |
| ||||
128 |
| TanStack Table Filter Docs | |||
129 |
| TanStack Table Column Ordering Docs | |||
130 |
| TanStack Table Column Pinning Docs | |||
131 |
| TanStack Table Column Sizing Docs | |||
132 |
| TanStack Table Column Sizing Docs | |||
133 |
| TanStack Table Column Visibility Docs | |||
134 |
| MRT Density Toggle Docs | |||
135 |
| ||||
136 |
| ||||
137 |
| ||||
138 |
| MRT Editing Docs | |||
139 |
| ||||
140 |
| MRT Editing Docs | |||
141 |
| TanStack Table Expanding Docs | |||
142 |
| TanStack Table Filters Docs | |||
143 |
| TanStack Table Filters Docs | |||
144 |
| TanStack Table Grouping Docs | |||
145 |
| ||||
146 |
| ||||
147 |
| MRT Full Screen Toggle Docs | |||
148 |
| TanStack Table Pagination Docs | |||
149 |
| TanStack Table Row Selection Docs | |||
150 |
| ||||
151 |
| ||||
152 |
| ||||
153 |
| TanStack Table Sorting Docs | |||
154 |
| TanStack Table Pagination Docs | |||
155 |
| TanStack Table Expanding Docs | |||
156 |
| ||||
157 |
| ||||
158 |
| ||||
159 |
| ||||
160 |
| ||||
161 |
| ||||
162 |
| ||||
163 |
| ||||
164 |
| ||||
165 |
| ||||
166 |
| ||||
167 |
| ||||
168 |
| ||||
169 |
| ||||
170 |
| ||||
171 |
| ||||
172 |
| ||||
173 |
| ||||
174 |
|
| |||
175 |
| ||||
176 |
| ||||
177 |
|
| |||
178 |
| TanStack Table Sorting Docs | |||
179 |
| TanStack Table Sorting Docs | |||
180 |
| Table State Management Guide | |||
181 |
| ||||
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 legacyBehavior>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 enablePagination={false}166 enablePinning167 enableRowNumbers168 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 <Typography191 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};202203export default RootPropTable;204