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