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 |
| ||||
154 |
| TanStack Table Sorting Docs | |||
155 |
| TanStack Table Pagination Docs | |||
156 |
| TanStack Table Expanding Docs | |||
157 |
| ||||
158 |
| ||||
159 |
| ||||
160 |
| ||||
161 |
| ||||
162 |
| ||||
163 |
| ||||
164 |
| ||||
165 |
| ||||
166 |
| ||||
167 |
| ||||
168 |
| ||||
169 |
| ||||
170 |
| ||||
171 |
| ||||
172 |
| ||||
173 |
| ||||
174 |
| ||||
175 |
|
| |||
176 |
| ||||
177 |
| ||||
178 |
|
| |||
179 |
| TanStack Table Sorting Docs | |||
180 |
| TanStack Table Sorting Docs | |||
181 |
| Table State Management Guide | |||
182 |
| ||||
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 id: `${cell.getValue<string>()}-prop`,34 }),35 Cell: ({ cell, row }) =>36 row.original?.required ? (37 <strong style={{ color: theme.palette.primary.dark }}>38 {cell.getValue<string>()}*39 </strong>40 ) : (41 cell.getValue<string>()42 ),43 },44 {45 header: 'Type',46 accessorKey: 'type',47 enableGlobalFilter: false,48 Cell: ({ cell }) => (49 <SampleCodeSnippet50 className="language-ts"51 enableCopyButton={false}52 style={{53 backgroundColor: 'transparent',54 fontSize: '0.9rem',55 margin: 0,56 padding: 0,57 minHeight: 'unset',58 }}59 >60 {cell.getValue<string>()}61 </SampleCodeSnippet>62 ),63 },64 {65 header: 'Required',66 accessorKey: 'required',67 enableGlobalFilter: false,68 },69 {70 header: 'Default Value',71 accessorKey: 'defaultValue',72 enableGlobalFilter: false,73 Cell: ({ cell }) => (74 <SampleCodeSnippet75 className="language-js"76 enableCopyButton={false}77 style={{78 backgroundColor: 'transparent',79 fontSize: '0.9rem',80 margin: 0,81 padding: 0,82 minHeight: 'unset',83 }}84 >85 {cell.getValue<string>()}86 </SampleCodeSnippet>87 ),88 },89 {90 header: 'Description',91 accessorKey: 'description',92 enableGlobalFilter: false,93 },94 {95 header: 'More Info Links',96 accessorKey: 'link',97 disableFilters: true,98 enableGlobalFilter: false,99 Cell: ({ cell, row }) => (100 <Link href={cell.getValue() as string} passHref legacyBehavior>101 <MuiLink102 color={103 row.original.source === 'MRT'104 ? 'text.primary'105 : row.original.source === 'Material UI'106 ? 'primary.main'107 : row.original.source === 'TanStack Table'108 ? 'secondary.main'109 : undefined110 }111 target={112 (cell.getValue() as string).startsWith('http')113 ? '_blank'114 : undefined115 }116 rel="noreferrer"117 >118 {row.original?.linkText}119 </MuiLink>120 </Link>121 ),122 },123 ] as MRT_ColumnDef<PropRow>[],124 [theme],125 );126127 const [columnPinning, setColumnPinning] = useState({});128129 useEffect(() => {130 if (typeof window !== 'undefined') {131 if (isDesktop) {132 setColumnPinning({133 left: ['mrt-row-expand', 'mrt-row-numbers', 'propName'],134 right: ['link'],135 });136 } else {137 setColumnPinning({});138 }139 }140 }, [isDesktop]);141142 const data = useMemo(() => {143 if (onlyProps) {144 return rootProps.filter(({ propName }) => onlyProps.has(propName));145 }146 return rootProps;147 }, [onlyProps]);148149 return (150 <MaterialReactTable151 columns={columns}152 data={data}153 displayColumnDefOptions={{154 'mrt-row-numbers': {155 size: 10,156 },157 'mrt-row-expand': {158 size: 10,159 },160 }}161 enableColumnActions={!onlyProps}162 enableColumnFilterModes163 enablePagination={false}164 enablePinning165 enableRowNumbers166 enableBottomToolbar={false}167 enableTopToolbar={!onlyProps}168 initialState={{169 columnVisibility: { required: false, description: false },170 density: 'compact',171 showGlobalFilter: true,172 sorting: [173 { id: 'required', desc: true },174 { id: 'propName', desc: false },175 ],176 }}177 muiSearchTextFieldProps={{178 placeholder: 'Search All Props',179 sx: { minWidth: '18rem' },180 variant: 'outlined',181 }}182 muiTablePaperProps={{183 sx: { mb: '1.5rem' },184 id: onlyProps ? 'relevant-props-table' : 'props-table',185 }}186 positionGlobalFilter="left"187 renderDetailPanel={({ row }) => (188 <Typography189 color={row.original.description ? 'secondary.main' : 'text.secondary'}190 >191 {row.original.description || 'No Description Provided... Yet...'}192 </Typography>193 )}194 rowNumberMode="static"195 onColumnPinningChange={setColumnPinning}196 state={{ columnPinning }}197 />198 );199};200201export default RootPropTable;202