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 2 | 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 Column Filtering Docs | ||
34 |
|
| TanStack Filters Docs | ||
35 |
|
| MRT Full Screen Toggle Docs | ||
36 |
|
| MRT Global Filtering Docs | ||
37 |
|
| MRT Global Filtering Docs | ||
38 |
|
| MRT Global Filtering Docs | ||
39 |
| MRT Aggregation and Grouping Docs | |||
40 |
|
| MRT Column Hiding Docs | ||
41 |
| TanStack Sorting Docs | |||
42 |
|
| MRT Row Selection Docs | ||
43 |
| ||||
44 |
|
| |||
45 |
| ||||
46 |
| ||||
47 |
| ||||
48 |
| Row Numbers Feature Guide | |||
49 |
| ||||
50 |
| ||||
51 |
| MRT Virtualization Docs | |||
52 |
|
| |||
53 |
|
| |||
54 |
|
| |||
55 |
| ||||
56 |
| ||||
57 |
|
| |||
58 |
|
| |||
59 |
|
| |||
60 |
|
| |||
61 |
|
| |||
62 |
| ||||
63 |
| TanStack Table Filters Docs | |||
64 |
|
| TanStack Filtering Docs | ||
65 |
| ||||
66 |
| TanStack Table Core Table Docs | |||
67 |
| ||||
68 |
| TanStack Table Filters Docs | |||
69 |
| TanStack Table Filters Docs | |||
70 |
| TanStack Table Filters Docs | |||
71 |
| TanStack Table Filters Docs | |||
72 |
| TanStack Table Grouping Docs | |||
73 |
| TanStack Table Expanding Docs | |||
74 |
| ||||
75 |
| TanStack Table Expanding Docs | |||
76 |
| TanStack Table Core Table Docs | |||
77 |
| TanStack Table Sorting Docs | |||
78 |
| TanStack Table Core Table Docs | |||
79 |
| ||||
80 |
| ||||
81 |
|
| TanStack Table Grouping Docs | ||
82 |
| ||||
83 |
| Table State Management Guide | |||
84 |
| TanStack Table Sorting Docs | |||
85 |
|
| TODO | ||
86 |
| Localization (i18n) Guide | |||
87 |
| TanStack Table Expanding Docs | |||
88 |
| TanStack Table Filters Docs | |||
89 |
| TanStack Table Grouping Docs | |||
90 |
| TanStack Table Pagination Docs | |||
91 |
| TanStack Table Sorting Docs | |||
92 |
|
| TanStack Table Filtering Docs | ||
93 |
| TanStack Table Sorting Docs | |||
94 |
| Memoize Components Guide | |||
95 |
| TanStack Table Core Docs | |||
96 |
| TanStack Table Core Docs | |||
97 |
| Material UI Toolbar Props | |||
98 |
| Material UI IconButton Props | |||
99 |
| Material UI IconButton Props | |||
100 |
| Material UI LinearProgress Props | |||
101 |
| Material UI TextField Props | |||
102 |
| Material UI Checkbox Props | |||
103 |
| Material UI Checkbox Props | |||
104 |
| Material UI Button Props | |||
105 |
| Material UI TextField Props | |||
106 |
| Material UI TableCell Props | |||
107 |
| Material UI Skeleton Props | |||
108 |
| Material UI TableBody Props | |||
109 |
| Material UI IconButton Props | |||
110 |
|
| Material UI TableRow Props | ||
111 |
| Material UI TableContainer Props | |||
112 |
| Material UI TableCell Props | |||
113 |
| Material UI TableCell Props | |||
114 |
| Material UI TableFooter Props | |||
115 |
| Material UI TableRow Props | |||
116 |
| Material UI IconButton Props | |||
117 |
| Material UI IconButton Props | |||
118 |
| Material UI Checkbox Props | |||
119 |
| Material UI Slider Props | |||
120 |
| Material UI TextField Props | |||
121 |
| Material UI TableCell Props | |||
122 |
| Material UI TableHead Props | |||
123 |
| Material UI TableRow Props | |||
124 |
| Material UI TablePagination Props | |||
125 |
| Material UI Paper API Docs | |||
126 |
| Material UI TableProps API Docs | |||
127 |
| Material UI Chip Props | |||
128 |
| Material UI Alert Props | |||
129 |
| Material UI Toolbar Props | |||
130 |
| ||||
131 |
| TanStack Table Filter Docs | |||
132 |
| TanStack Table Column Ordering Docs | |||
133 |
| TanStack Table Column Pinning Docs | |||
134 |
| TanStack Table Column Sizing Docs | |||
135 |
| TanStack Table Column Sizing Docs | |||
136 |
| TanStack Table Column Visibility Docs | |||
137 |
| MRT Density Toggle Docs | |||
138 |
| ||||
139 |
| ||||
140 |
| ||||
141 |
| MRT Editing Docs | |||
142 |
| ||||
143 |
| MRT Editing Docs | |||
144 |
| TanStack Table Expanding Docs | |||
145 |
| TanStack Table Filters Docs | |||
146 |
| TanStack Table Filters Docs | |||
147 |
| TanStack Table Grouping Docs | |||
148 |
| ||||
149 |
| ||||
150 |
| MRT Full Screen Toggle Docs | |||
151 |
| TanStack Table Pagination Docs | |||
152 |
| TanStack Table Row Selection Docs | |||
153 |
| ||||
154 |
| ||||
155 |
| ||||
156 |
| ||||
157 |
| TanStack Table Sorting Docs | |||
158 |
| TanStack Table Pagination Docs | |||
159 |
| TanStack Table Expanding Docs | |||
160 |
| ||||
161 |
| ||||
162 |
| ||||
163 |
| ||||
164 |
| ||||
165 |
| ||||
166 |
| ||||
167 |
| ||||
168 |
| ||||
169 |
| ||||
170 |
| ||||
171 |
| ||||
172 |
| ||||
173 |
| ||||
174 |
| ||||
175 |
| ||||
176 |
| ||||
177 |
| ||||
178 |
| ||||
179 |
|
| |||
180 |
| ||||
181 |
| ||||
182 |
|
| |||
183 |
| TanStack Table Sorting Docs | |||
184 |
| TanStack Table Sorting Docs | |||
185 |
| Table State Management Guide | |||
186 |
| ||||
187 |
| ||||
Wanna see the source code for this table? Check it out down below!
1import React, { useEffect, useMemo, useState } from 'react';2import Link from 'next/link';3import {4 MaterialReactTable,5 type MaterialReactTableProps,6 type MRT_ColumnDef,7} from 'material-react-table';8import {9 Link as MuiLink,10 Typography,11 useMediaQuery,12 useTheme,13} from '@mui/material';14import { SampleCodeSnippet } from '../mdx/SampleCodeSnippet';15import { type PropRow, rootProps } from './rootProps';1617interface Props {18 onlyProps?: Set<keyof MaterialReactTableProps>;19}2021const RootPropTable = ({ onlyProps }: Props) => {22 const theme = useTheme();23 const isDesktop = useMediaQuery('(min-width: 1200px)');2425 const columns = useMemo<MRT_ColumnDef<PropRow>[]>(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: ({ renderedCellValue, row }) =>36 row.original?.required ? (37 <strong style={{ color: theme.palette.primary.dark }}>38 {renderedCellValue}*39 </strong>40 ) : (41 renderedCellValue42 ),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<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<string>().startsWith('http')113 ? '_blank'114 : undefined115 }116 rel="noopener"117 >118 {row.original?.linkText}119 </MuiLink>120 </Link>121 ),122 },123 ],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