Table Options (Props)
Many of the options you can pass to
useMaterialReactTableare the same as the ones you can pass to the TanStack Table useReactTable hook.
Here is a list of all the table options that you can pass to the useMaterialReactTable hook.
const table = useMaterialReactTable({// all the options that you can pass here});//Note: you can also pass table options directly to the MaterialReactTable component instead of the useMaterialReactTable hook//But this will not be encouraged as it will be deprecated in the futurereturn <MaterialReactTable table={table} />;
# | 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 |
| ||||
| 27 |
| MRT Column Resizing Docs | |||
| 28 |
| MRT Virtualization Docs | |||
| 29 |
|
| MRT Density Toggle Docs | ||
| 30 |
| MRT Editing Docs | |||
| 31 |
|
| MRT Expanding Sub Rows Docs | ||
| 32 |
| MRT Expanding Sub Rows Docs | |||
| 33 |
|
| TanStack Filters Docs | ||
| 34 |
|
| MRT Column Filtering Docs | ||
| 35 |
|
| TanStack Filters Docs | ||
| 36 |
|
| MRT Full Screen Toggle Docs | ||
| 37 |
|
| MRT Global Filtering Docs | ||
| 38 |
|
| MRT Global Filtering Docs | ||
| 39 |
|
| MRT Global Filtering Docs | ||
| 40 |
| MRT Aggregation and Grouping Docs | |||
| 41 |
|
| MRT Column Hiding Docs | ||
| 42 |
| TanStack Sorting Docs | |||
| 43 |
|
| MRT Row Selection Docs | ||
| 44 |
| ||||
| 45 |
|
| |||
| 46 |
| ||||
| 47 |
| ||||
| 48 |
| Row Numbers Feature Guide | |||
| 49 |
| ||||
| 50 |
| ||||
| 51 |
| ||||
| 52 |
| MRT Virtualization Docs | |||
| 53 |
|
| |||
| 54 |
|
| |||
| 55 |
|
| |||
| 56 |
| ||||
| 57 |
| ||||
| 58 |
|
| |||
| 59 |
|
| |||
| 60 |
|
| |||
| 61 |
|
| |||
| 62 |
|
| |||
| 63 |
| ||||
| 64 |
| TanStack Table Filters Docs | |||
| 65 |
|
| TanStack Filtering Docs | ||
| 66 |
| ||||
| 67 |
| TanStack Table Core Table Docs | |||
| 68 |
| ||||
| 69 |
| TanStack Table Filters Docs | |||
| 70 |
| TanStack Table Filters Docs | |||
| 71 |
| TanStack Table Filters Docs | |||
| 72 |
| TanStack Table Filters Docs | |||
| 73 |
| TanStack Table Grouping Docs | |||
| 74 |
| TanStack Table Expanding Docs | |||
| 75 |
| ||||
| 76 |
| TanStack Table Expanding Docs | |||
| 77 |
| TanStack Table Core Table Docs | |||
| 78 |
| TanStack Table Sorting Docs | |||
| 79 |
| TanStack Table Core Table Docs | |||
| 80 |
| ||||
| 81 |
| ||||
| 82 |
|
| TanStack Table Grouping Docs | ||
| 83 |
| ||||
| 84 |
| Table State Management Guide | |||
| 85 |
| TanStack Table Sorting Docs | |||
| 86 |
|
| |||
| 87 |
|
| TODO | ||
| 88 |
| Localization (i18n) Guide | |||
| 89 |
| TanStack Table Expanding Docs | |||
| 90 |
| TanStack Table Filters Docs | |||
| 91 |
| TanStack Table Grouping Docs | |||
| 92 |
| TanStack Table Pagination Docs | |||
| 93 |
| TanStack Table Sorting Docs | |||
| 94 |
|
| TanStack Table Filtering Docs | ||
| 95 |
| TanStack Table Sorting Docs | |||
| 96 |
| Memoize Components Guide | |||
| 97 |
| TanStack Table Core Docs | |||
| 98 |
| TanStack Table Core Docs | |||
| 99 |
| Material UI Toolbar Props | |||
| 100 |
| Material UI IconButton Props | |||
| 101 |
| Material UI IconButton Props | |||
| 102 |
| Material UI Button Props | |||
| 103 |
| Material UI TableCell Props | |||
| 104 |
| Material UI TextField Props | |||
| 105 |
| Material UI IconButton Props | |||
| 106 |
| Material UI IconButton Props | |||
| 107 |
| Material UI Checkbox Props | |||
| 108 |
| Material UI Slider Props | |||
| 109 |
| Material UI TextField Props | |||
| 110 |
| Material UI LinearProgress Props | |||
| 111 |
| Material UI IconButton Props | |||
| 112 |
| Material UI TextField Props | |||
| 113 |
| Material UI Checkbox Props | |||
| 114 |
| Material UI Checkbox Props | |||
| 115 |
| Material UI Skeleton Props | |||
| 116 |
| Material UI TableCell Props | |||
| 117 |
| Material UI TableBody Props | |||
| 118 |
|
| Material UI TableRow Props | ||
| 119 |
| Material UI TableContainer Props | |||
| 120 |
| Material UI TableCell Props | |||
| 121 |
| Material UI TableFooter Props | |||
| 122 |
| Material UI TableRow Props | |||
| 123 |
| Material UI TableCell Props | |||
| 124 |
| Material UI TableHead Props | |||
| 125 |
| Material UI TableRow Props | |||
| 126 |
| Material UI TablePagination Props | |||
| 127 |
| Material UI Paper API Docs | |||
| 128 |
| Material UI TableProps API Docs | |||
| 129 |
| Material UI Chip Props | |||
| 130 |
| Material UI Alert Props | |||
| 131 |
| Material UI Toolbar Props | |||
| 132 |
| ||||
| 133 |
| TanStack Table Filter Docs | |||
| 134 |
| TanStack Table Column Ordering Docs | |||
| 135 |
| TanStack Table Column Pinning Docs | |||
| 136 |
| TanStack Table Column Sizing Docs | |||
| 137 |
| TanStack Table Column Sizing Docs | |||
| 138 |
| TanStack Table Column Visibility Docs | |||
| 139 |
| MRT Density Toggle Docs | |||
| 140 |
| ||||
| 141 |
| ||||
| 142 |
| ||||
| 143 |
| MRT Editing Docs | |||
| 144 |
| ||||
| 145 |
| MRT Editing Docs | |||
| 146 |
| TanStack Table Expanding Docs | |||
| 147 |
| TanStack Table Filters Docs | |||
| 148 |
| TanStack Table Filters Docs | |||
| 149 |
| TanStack Table Grouping Docs | |||
| 150 |
| ||||
| 151 |
| ||||
| 152 |
| MRT Full Screen Toggle Docs | |||
| 153 |
| TanStack Table Pagination Docs | |||
| 154 |
| TanStack Table Pinning Docs | |||
| 155 |
| TanStack Table Row Selection Docs | |||
| 156 |
| ||||
| 157 |
| ||||
| 158 |
| ||||
| 159 |
| ||||
| 160 |
| TanStack Table Sorting Docs | |||
| 161 |
| TanStack Table Pagination Docs | |||
| 162 |
| TanStack Table Expanding Docs | |||
| 163 |
| ||||
| 164 |
| ||||
| 165 |
| ||||
| 166 |
| ||||
| 167 |
| ||||
| 168 |
| ||||
| 169 |
| ||||
| 170 |
| ||||
| 171 |
| ||||
| 172 |
| ||||
| 173 |
| ||||
| 174 |
| ||||
| 175 |
| ||||
| 176 |
| ||||
| 177 |
| ||||
| 178 |
| ||||
| 179 |
| ||||
| 180 |
| ||||
| 181 |
| ||||
| 182 |
|
| |||
| 183 |
|
| |||
| 184 |
| ||||
| 185 |
| ||||
| 186 |
|
| |||
| 187 |
| TanStack Table Sorting Docs | |||
| 188 |
| TanStack Table Sorting Docs | |||
| 189 |
| Table State Management Guide | |||
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 MRT_TableOptions,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 TableOption, tableOptions } from './tableOptions';1617interface Props {18 onlyOptions?: Set<keyof MRT_TableOptions<TableOption>>;19}2021const TableOptionsTable = ({ onlyOptions }: Props) => {22 const theme = useTheme();23 const isDesktop = useMediaQuery('(min-width: 1200px)');2425 const columns = useMemo<MRT_ColumnDef<TableOption>[]>(26 () => [27 {28 enableClickToCopy: true,29 header: 'Prop Name',30 accessorKey: 'tableOption',31 muiCopyButtonProps: ({ 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', 'tableOption'],134 right: ['link'],135 });136 } else {137 setColumnPinning({});138 }139 }140 }, [isDesktop]);141142 const data = useMemo(() => {143 if (onlyOptions) {144 return tableOptions.filter(({ tableOption }) =>145 onlyOptions.has(tableOption),146 );147 }148 return tableOptions;149 }, [onlyOptions]);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={!onlyOptions}164 enableColumnFilterModes165 enablePagination={false}166 enableColumnPinning167 enableRowNumbers168 enableBottomToolbar={false}169 enableTopToolbar={!onlyOptions}170 initialState={{171 columnVisibility: { required: false, description: false },172 density: 'compact',173 showGlobalFilter: true,174 sorting: [175 { id: 'required', desc: true },176 { id: 'tableOption', 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: onlyOptions ? '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 TableOptionsTable;204