@mini_7/material-react-table-mcp 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/README.md +68 -0
  2. package/data/MIGRATION.md +136 -0
  3. package/data/api.json +5379 -0
  4. package/data/examples/advanced.tsx +309 -0
  5. package/data/examples/aggregation-and-grouping.tsx +153 -0
  6. package/data/examples/aggregation-multi.tsx +105 -0
  7. package/data/examples/alternate-column-filtering.tsx +49 -0
  8. package/data/examples/alternate-detail-panel.tsx +81 -0
  9. package/data/examples/alternate-pagination.tsx +23 -0
  10. package/data/examples/basic.tsx +109 -0
  11. package/data/examples/chart-detail-panel.tsx +89 -0
  12. package/data/examples/column-actions-space.tsx +44 -0
  13. package/data/examples/column-alignment.tsx +70 -0
  14. package/data/examples/custom-column-actions.tsx +109 -0
  15. package/data/examples/custom-column-filtering-ui.tsx +89 -0
  16. package/data/examples/custom-headless.tsx +125 -0
  17. package/data/examples/custom-top-toolbar.tsx +88 -0
  18. package/data/examples/customize-display-columns.tsx +85 -0
  19. package/data/examples/customize-filter-components.tsx +101 -0
  20. package/data/examples/customize-filter-modes.tsx +73 -0
  21. package/data/examples/customize-filter-variants.tsx +116 -0
  22. package/data/examples/customize-global-filter-component.tsx +52 -0
  23. package/data/examples/customize-remove-column-grouping.tsx +94 -0
  24. package/data/examples/customize-row-selection.tsx +54 -0
  25. package/data/examples/customize-table-styles.tsx +100 -0
  26. package/data/examples/disable-column-actions.tsx +37 -0
  27. package/data/examples/disable-column-hiding.tsx +90 -0
  28. package/data/examples/disable-density-toggle.tsx +49 -0
  29. package/data/examples/dynamic-columns.tsx +189 -0
  30. package/data/examples/editing-crud-cell.tsx +377 -0
  31. package/data/examples/editing-crud-modal.tsx +370 -0
  32. package/data/examples/editing-crud-row.tsx +333 -0
  33. package/data/examples/editing-crud-table.tsx +369 -0
  34. package/data/examples/editing-crud-tree.tsx +416 -0
  35. package/data/examples/enable-cell-actions.tsx +76 -0
  36. package/data/examples/enable-click-to-copy.tsx +39 -0
  37. package/data/examples/enable-column-grouping.tsx +120 -0
  38. package/data/examples/enable-column-ordering.tsx +48 -0
  39. package/data/examples/enable-column-pinning.tsx +69 -0
  40. package/data/examples/enable-column-resizing.tsx +56 -0
  41. package/data/examples/enable-column-virtualization.tsx +27 -0
  42. package/data/examples/enable-detail-panel-conditionally.tsx +78 -0
  43. package/data/examples/enable-detail-panel-virtualized.tsx +80 -0
  44. package/data/examples/enable-expanding-tree.tsx +110 -0
  45. package/data/examples/enable-filter-facet-values.tsx +65 -0
  46. package/data/examples/enable-row-dragging.tsx +137 -0
  47. package/data/examples/enable-row-numbers-original.tsx +48 -0
  48. package/data/examples/enable-row-numbers-static.tsx +48 -0
  49. package/data/examples/enable-row-ordering.tsx +57 -0
  50. package/data/examples/enable-row-pinning-select.tsx +76 -0
  51. package/data/examples/enable-row-pinning-static.tsx +50 -0
  52. package/data/examples/enable-row-pinning-sticky.tsx +69 -0
  53. package/data/examples/enable-row-selection.tsx +96 -0
  54. package/data/examples/enable-row-virtualization.tsx +101 -0
  55. package/data/examples/enable-sticky-header.tsx +59 -0
  56. package/data/examples/expanding-tree-expanded.tsx +121 -0
  57. package/data/examples/expanding-tree-flat-parse.tsx +125 -0
  58. package/data/examples/expanding-tree-root-expanded.tsx +151 -0
  59. package/data/examples/export-to-csv.tsx +114 -0
  60. package/data/examples/export-to-pdf.tsx +104 -0
  61. package/data/examples/external-toolbar.tsx +108 -0
  62. package/data/examples/font-awesome-icons.tsx +106 -0
  63. package/data/examples/infinite-scrolling.tsx +208 -0
  64. package/data/examples/lazy-detail-panel.tsx +262 -0
  65. package/data/examples/lazy-sub-rows.tsx +190 -0
  66. package/data/examples/linear-progress.tsx +66 -0
  67. package/data/examples/loading.tsx +50 -0
  68. package/data/examples/localization-i18n-ar.tsx +65 -0
  69. package/data/examples/localization-i18n-az.tsx +60 -0
  70. package/data/examples/localization-i18n-bg.tsx +60 -0
  71. package/data/examples/localization-i18n-cs.tsx +60 -0
  72. package/data/examples/localization-i18n-da.tsx +60 -0
  73. package/data/examples/localization-i18n-de.tsx +60 -0
  74. package/data/examples/localization-i18n-el.tsx +60 -0
  75. package/data/examples/localization-i18n-en.tsx +60 -0
  76. package/data/examples/localization-i18n-es.tsx +60 -0
  77. package/data/examples/localization-i18n-et.tsx +60 -0
  78. package/data/examples/localization-i18n-fa.tsx +66 -0
  79. package/data/examples/localization-i18n-fi.tsx +60 -0
  80. package/data/examples/localization-i18n-fr.tsx +60 -0
  81. package/data/examples/localization-i18n-he.tsx +66 -0
  82. package/data/examples/localization-i18n-hr.tsx +60 -0
  83. package/data/examples/localization-i18n-hu.tsx +60 -0
  84. package/data/examples/localization-i18n-hy.tsx +65 -0
  85. package/data/examples/localization-i18n-id.tsx +60 -0
  86. package/data/examples/localization-i18n-it.tsx +60 -0
  87. package/data/examples/localization-i18n-ja.tsx +60 -0
  88. package/data/examples/localization-i18n-ko.tsx +60 -0
  89. package/data/examples/localization-i18n-nl.tsx +60 -0
  90. package/data/examples/localization-i18n-no.tsx +60 -0
  91. package/data/examples/localization-i18n-np.tsx +60 -0
  92. package/data/examples/localization-i18n-pl.tsx +60 -0
  93. package/data/examples/localization-i18n-pt-BR.tsx +60 -0
  94. package/data/examples/localization-i18n-pt.tsx +60 -0
  95. package/data/examples/localization-i18n-ro.tsx +60 -0
  96. package/data/examples/localization-i18n-ru.tsx +60 -0
  97. package/data/examples/localization-i18n-sk.tsx +60 -0
  98. package/data/examples/localization-i18n-sr-Cyrl-RS.tsx +60 -0
  99. package/data/examples/localization-i18n-sr-Latn-RS.tsx +60 -0
  100. package/data/examples/localization-i18n-sv.tsx +60 -0
  101. package/data/examples/localization-i18n-tr.tsx +60 -0
  102. package/data/examples/localization-i18n-uk.tsx +60 -0
  103. package/data/examples/localization-i18n-vi.tsx +60 -0
  104. package/data/examples/localization-i18n-zh-hans.tsx +60 -0
  105. package/data/examples/localization-i18n-zh-hant.tsx +60 -0
  106. package/data/examples/manual-selection.tsx +105 -0
  107. package/data/examples/minimal.tsx +78 -0
  108. package/data/examples/mui-theme.tsx +136 -0
  109. package/data/examples/multi-sorting.tsx +58 -0
  110. package/data/examples/persistent-state.tsx +184 -0
  111. package/data/examples/react-query.tsx +182 -0
  112. package/data/examples/remote.tsx +150 -0
  113. package/data/examples/row-actions-buttons.tsx +89 -0
  114. package/data/examples/row-actions-menu-items.tsx +64 -0
  115. package/data/examples/single-row-selection.tsx +98 -0
  116. package/data/examples/virtualized.tsx +138 -0
  117. package/data/guides/accessibility.md +119 -0
  118. package/data/guides/aggregation.md +210 -0
  119. package/data/guides/async-loading.md +132 -0
  120. package/data/guides/best-practices.md +363 -0
  121. package/data/guides/cell-actions.md +139 -0
  122. package/data/guides/click-to-copy.md +67 -0
  123. package/data/guides/column-actions.md +69 -0
  124. package/data/guides/column-filtering.md +366 -0
  125. package/data/guides/column-grouping.md +192 -0
  126. package/data/guides/column-hiding.md +133 -0
  127. package/data/guides/column-ordering-dnd.md +99 -0
  128. package/data/guides/column-pinning.md +72 -0
  129. package/data/guides/column-resizing.md +157 -0
  130. package/data/guides/column-size.md +162 -0
  131. package/data/guides/customize-components.md +395 -0
  132. package/data/guides/customize-icons.md +35 -0
  133. package/data/guides/data-columns.md +292 -0
  134. package/data/guides/density-toggle.md +46 -0
  135. package/data/guides/detail-panel.md +195 -0
  136. package/data/guides/display-columns.md +135 -0
  137. package/data/guides/editing.md +367 -0
  138. package/data/guides/expanding-sub-rows.md +194 -0
  139. package/data/guides/full-screen-toggle.md +63 -0
  140. package/data/guides/global-filtering.md +237 -0
  141. package/data/guides/localization.md +57 -0
  142. package/data/guides/memoization.md +157 -0
  143. package/data/guides/pagination.md +171 -0
  144. package/data/guides/row-actions.md +116 -0
  145. package/data/guides/row-numbers.md +24 -0
  146. package/data/guides/row-ordering-dnd.md +51 -0
  147. package/data/guides/row-pinning.md +96 -0
  148. package/data/guides/row-selection.md +237 -0
  149. package/data/guides/sorting.md +190 -0
  150. package/data/guides/state-management.md +165 -0
  151. package/data/guides/sticky-header.md +41 -0
  152. package/data/guides/table-event-listeners.md +103 -0
  153. package/data/guides/toolbar-customization.md +251 -0
  154. package/data/guides/virtualization.md +183 -0
  155. package/data/index.json +1930 -0
  156. package/data/reference/mrt-components.md +183 -0
  157. package/data/reference/mrt-hooks.md +125 -0
  158. package/data/skills/composable-components/SKILL.md +189 -0
  159. package/data/skills/customization/SKILL.md +190 -0
  160. package/data/skills/drag-and-drop-ordering/SKILL.md +227 -0
  161. package/data/skills/editing/SKILL.md +243 -0
  162. package/data/skills/filtering/SKILL.md +213 -0
  163. package/data/skills/getting-started/SKILL.md +213 -0
  164. package/data/skills/localization/SKILL.md +182 -0
  165. package/data/skills/migrate-v3-to-v4/SKILL.md +161 -0
  166. package/data/skills/state-and-server-data/SKILL.md +200 -0
  167. package/data/skills/virtualization/SKILL.md +203 -0
  168. package/dist/data.js +137 -0
  169. package/dist/index.js +232 -0
  170. package/package.json +50 -0
@@ -0,0 +1,395 @@
1
+ ## Customize (Style) Components Guide
2
+
3
+ One of the strengths of Material React Table is that it exposes a majority of all the underlying Material UI component props used to build the table.
4
+
5
+ Additionally, in one of the sections below, you will learn [how to customize and use a Material UI Theme](#material-ui-theme) to customize colors, typography, or any other default CSS that is used by Material React Table.
6
+
7
+ ### Relevant Table Options
8
+
9
+ All props labeled `mui...Props` get forwarded to Material UI components. Here is a list of all the props that are exposed in both the root props and column options.
10
+
11
+ Relevant table options (get_mrt_api has full details):
12
+
13
+ - `muiBottomToolbarProps` - type `BoxProps | ({ table }) => BoxProps`
14
+ - `muiColumnActionsButtonProps` - type `IconButtonProps | (({table, column}) => IconButtonProps);`
15
+ - `muiColumnDragHandleProps` - type `IconButtonProps | ({table, column}) => IconButtonProps`
16
+ - `muiCopyButtonProps` - type `ButtonProps | ({ cell, column, row, table }) => ButtonProps`
17
+ - `muiDetailPanelProps` - type `TableCellProps | ({ row, table }) => TableCellProps`
18
+ - `muiEditRowDialogProps` - type `IconButtonProps | ({ table }) => IconButtonProps`
19
+ - `muiEditTextFieldProps` - type `TextFieldProps | ({ cell, column, row, table }) => TextFieldProps`
20
+ - `muiExpandAllButtonProps` - type `IconButtonProps | ({ table }) => IconButtonProps`
21
+ - `muiExpandButtonProps` - type `IconButtonProps | ({ row, table }) => IconButtonProps`
22
+ - `muiFilterAutocompleteProps` - type `AutocompleteProps | ({ column, rangeFilterIndex, table }) => AutocompleteProps`
23
+ - `muiFilterCheckboxProps` - type `CheckboxProps | ({ column, table}) => CheckboxProps`
24
+ - `muiFilterDatePickerProps` - type `DatePickerProps | ({ column, rangeFilterIndex, table }) => DatePickerProps`
25
+ - `muiFilterSliderProps` - type `SliderProps | ({ column, table}) => SliderProps`
26
+ - `muiFilterTextFieldProps` - type `TextFieldProps | ({ table, column, rangeFilterIndex}) => TextFieldProps`
27
+ - `muiLinearProgressProps` - type `LinearProgressProps | ({ isTopToolbar, table }) => LinearProgressProps`
28
+ - `muiPaginationProps` - type `Partial<PaginationProps> | ({ table }) => Partial<PaginationProps>`
29
+ - `muiRowDragHandleProps` - type `IconButtonProps | ({ row, table }) => IconButtonProps`
30
+ - `muiSearchTextFieldProps` - type `TextFieldProps | ({ table }) => TextFieldProps`
31
+ - `muiSelectAllCheckboxProps` - type `CheckboxProps | ({ table }) => CheckboxProps`
32
+ - `muiSelectCheckboxProps` - type `CheckboxProps | ({ row, table }) => CheckboxProps`
33
+ - `muiSkeletonProps` - type `SkeletonProps | ({ cell, column, row, table }) => SkeletonProps`
34
+ - `muiTableBodyCellProps` - type `TableCellProps | ({ cell, column, row, table }) => TableCellProps`
35
+ - `muiTableBodyProps` - type `TableBodyProps | ({ table }) => TableBodyProps`
36
+ - `muiTableBodyRowProps` - type `TableRowProps | ({ isDetailPanel, row, table }) => TableRowProps` - default `{ hover: true }`
37
+ - `muiTableContainerProps` - type `TableContainerProps | ({ table }) => TableContainerProps`
38
+ - `muiTableFooterCellProps` - type `TableCellProps| ({table, column}) => TableCellProps`
39
+ - `muiTableFooterProps` - type `TableFooterProps | ({ table }) => TableFooterProps);`
40
+ - `muiTableFooterRowProps` - type `TableRowProps | ({table, footerGroup}) => TableRowProps`
41
+ - `muiTableHeadCellProps` - type `TableCellProps | ({ table, column}) => TableCellProps`
42
+ - `muiTableHeadProps` - type `TableHeadProps | ({ table }) => TableHeadProps`
43
+ - `muiTableHeadRowProps` - type `TableRowProps | ({ table, headerGroup}) => TableRowProps`
44
+ - `muiTablePaperProps` - type `PaperProps | ({ table }} => PaperProps`
45
+ - `muiTableProps` - type `TableProps | ({ table }} => TableProps`
46
+ - `muiToolbarAlertBannerChipProps` - type `ChipProps| ({ table }} => ChipProps`
47
+ - `muiToolbarAlertBannerProps` - type `AlertProps | ({ table }) => AlertProps`
48
+ - `muiTopToolbarProps` - type `BoxProps | ({ table }) => BoxProps`
49
+
50
+ ### Relevant Column Options
51
+
52
+ Some of the column options expose the same props as above, but on a per column basis.
53
+
54
+ Relevant column options (get_mrt_api has full details):
55
+
56
+ - `muiColumnActionsButtonProps` - type `IconButtonProps | ({ column, table }) => IconButtonProps`
57
+ - `muiCopyButtonProps` - type `ButtonProps | ({ cell, column, row, table }) => ButtonProps`
58
+ - `muiEditTextFieldProps` - type `TextFieldProps | ({ cell, column, row, table }) => TextFieldProps`
59
+ - `muiFilterAutocompleteProps` - type `AutocompleteProps | ({ column, rangeFilterIndex, table }) => AutocompleteProps`
60
+ - `muiFilterCheckboxProps` - type `CheckboxProps | ({ column, table }) => CheckboxProps`
61
+ - `muiFilterDatePickerProps` - type `DatePickerProps | ({ column, rangeFilterIndex, table }) => DatePickerProps`
62
+ - `muiFilterSliderProps` - type `SliderProps | ({ column, table}) => SliderProps`
63
+ - `muiFilterTextFieldProps` - type `TextFieldProps | ({ column, rangeFilterIndex, table }) => TextFieldProps`
64
+ - `muiTableBodyCellProps` - type `TableCellProps | ({ cell, table }) => TableCellProps`
65
+ - `muiTableFooterCellProps` - type `TableCellProps | ({ column, table }) => TableCellProps`
66
+ - `muiTableHeadCellProps` - type `TableCellProps | ({ column, table }) => TableCellProps`
67
+
68
+ ### Material UI Props and Types
69
+
70
+ Each prop can either be passed as an object or as a callback function where you get access to the underlying `table` instance and any other relevant callback parameters, such as `cell`, `row`, `column`, etc. This lets you easily run conditional logic on the props you pass. Let's take a look at a few examples.
71
+
72
+ > All `mui...Props` props are strongly typed and you should get ts hints as you write them. API docs are available on the [Material UI website](https://mui.com/material-ui/api/table/) for each component.
73
+
74
+ #### Static Prop Objects
75
+
76
+ ```jsx
77
+ const table = useMaterialReactTable({
78
+ columns,
79
+ data,
80
+ enableRowSelection: true,
81
+ //passing the static object variant if no dynamic logic is needed
82
+ muiSelectCheckboxProps: {
83
+ color: 'secondary', //makes all checkboxes use the secondary color
84
+ },
85
+ });
86
+
87
+ return <MaterialReactTable table={table} />;
88
+ ```
89
+
90
+ #### Callback Functions to Dynamically Set Prop Values
91
+
92
+ ```jsx
93
+ const table = useMaterialReactTable({
94
+ columns,
95
+ data,
96
+ enableRowSelection: true,
97
+ //passing the callback function variant. (You should get type hints for all the callback parameters available)
98
+ muiSelectCheckboxProps: ({ row }) => ({
99
+ color: 'secondary',
100
+ disabled: row.original.isAccountLocked, //access the row data to determine if the checkbox should be disabled
101
+ }),
102
+ });
103
+
104
+ return <MaterialReactTable table={table} />;
105
+ ```
106
+
107
+ ### Styling Material UI Components
108
+
109
+ Each `mui...Prop` has multiple options for you to add styling to the component. You could simply pass `className` or `style` props to any `mui...Props` prop, but there is also the `sx` table option, which is the recommended way to style Material UI components in Material React Table.
110
+
111
+ #### The SX Prop
112
+
113
+ > NOTE: These docs are still written for the Emotion version of the `sx` prop. Pigment CSS docs will be added here later.
114
+
115
+ The recommended way to style Material UI components in Material React Table will be the [`sx` prop](https://mui.com/system/basics/#the-sx-prop) throughout this docs site, as it is both the most simple and the most powerful way to style Material UI components as of Material UI V6. They can work and be as simple as a `style` prop, but behind the scenes, they work more like emotion styled-components by using `mui/system`.
116
+
117
+ Don't worry, `className` and `style` props will still work, but let's show off some of the more elegant syntax you can use with the `sx` table option.
118
+
119
+ 1. The `sx` prop can be used just as simply as a `style` prop by default (though it applies CSS classes using Emotion under the hood).
120
+
121
+ ```jsx
122
+ const table = useMaterialReactTable({
123
+ columns,
124
+ data,
125
+ muiTableHeadCellProps: {
126
+ //simple styling with the `sx` prop, works just like a style prop in this example
127
+ sx: {
128
+ fontWeight: 'normal',
129
+ fontSize: '14px',
130
+ },
131
+ },
132
+ });
133
+
134
+ return <MaterialReactTable table={table} />;
135
+ ```
136
+
137
+ 2. The `sx` prop gets easy access to your _muiTheme_ without you having to call the theme from a `useTheme` hook.
138
+
139
+ ```jsx
140
+ const table = useMaterialReactTable({
141
+ columns,
142
+ data,
143
+ muiTableHeadCellProps: {
144
+ //no useTheme hook needed, just use the `sx` prop with the theme callback
145
+ sx: (theme) => ({
146
+ color: theme.palette.text.secondary,
147
+ }),
148
+ },
149
+ });
150
+
151
+ return <MaterialReactTable table={table} />;
152
+ ```
153
+
154
+ 3. The `sx` prop gives you a much more concise way to add media queries to your styling.
155
+
156
+ ```jsx
157
+ const table = useMaterialReactTable({
158
+ columns,
159
+ data,
160
+ muiTableHeadCellProps: {
161
+ //easier way to create media queries, no useMediaQuery hook needed.
162
+ sx: {
163
+ fontSize: {
164
+ xs: '10px',
165
+ sm: '11px',
166
+ md: '12px',
167
+ lg: '13px',
168
+ xl: '14px',
169
+ },
170
+ },
171
+ },
172
+ });
173
+
174
+ return <MaterialReactTable table={table} />;
175
+ ```
176
+
177
+ 4. The `sx` prop still let's you use the `&` syntax to target nested elements.
178
+
179
+ ```jsx
180
+ const table = useMaterialReactTable({
181
+ columns,
182
+ data,
183
+ muiTableHeadCellProps: {
184
+ sx: {
185
+ //use the `&` syntax to target nested elements by their class
186
+ '& .Mui-TableHeadCell-Content': {
187
+ padding: '0',
188
+ },
189
+ //use the `&` syntax to target hover state
190
+ '&:hover': {
191
+ fontWeight: 'bold',
192
+ },
193
+ },
194
+ },
195
+ });
196
+ ```
197
+
198
+ There are many more advantages to using the `sx` prop, but that is all we will discuss in these docs. You can learn more about it the official [Material UI Docs](https://mui.com/system/getting-started/the-sx-prop/).
199
+
200
+ ### Conditional Styling
201
+
202
+ Using the `sx`, `style`, or `className` props and the parameters from the callback functions (cell, column, row, table instance APIs, etc.), you can easily add conditional styling to your Material UI components. Here's a few examples
203
+
204
+ #### Style Selected Rows
205
+
206
+ ```jsx
207
+ const table = useMaterialReactTable({
208
+ muiTableBodyRowProps: ({ row }) => ({
209
+ //conditionally style selected rows
210
+ sx: {
211
+ fontWeight: row.getIsSelected() ? 'bold' : 'normal',
212
+ },
213
+ }),
214
+ });
215
+ ```
216
+
217
+ #### Style Expanded Rows
218
+
219
+ ```jsx
220
+ const table = useMaterialReactTable({
221
+ muiTableBodyRowProps: ({ row }) => ({
222
+ //conditionally style expanded rows
223
+ sx: {
224
+ fontWeight: row.getIsExpanded() ? 'bold' : 'normal',
225
+ },
226
+ }),
227
+ });
228
+ ```
229
+
230
+ #### Style Pinned Columns
231
+
232
+ ```jsx
233
+ const table = useMaterialReactTable({
234
+ muiTableHeadCellProps: ({ column }) => ({
235
+ //conditionally style pinned columns
236
+ sx: {
237
+ backgroundColor: column.getIsPinned() ? '#f5f5f5' : 'inherit',
238
+ },
239
+ }),
240
+ muiTableBodyCellProps: ({ column }) => ({
241
+ //conditionally style pinned columns
242
+ sx: {
243
+ fontWeight: column.getIsPinned() ? 'bold' : 'normal',
244
+ },
245
+ }),
246
+ });
247
+ ```
248
+
249
+ There are hundreds of table, column, header, row, and cell instance APIs that you can use for conditional styling and other logic. See the [Table Instance APIs](/docs/api/table-instance-apis), [Column Instance APIs](/docs/api/column-instance-apis), [Row Instance APIs](/docs/api/row-instance-apis), and [Cell Instance APIs](/docs/api/cell-instance-apis) docs for more info.
250
+
251
+ ### Material UI Theme
252
+
253
+ Material React Table respects your Material UI Theme. If you have already set up Material UI and a global Material UI Theme, you should already be set. But if you have not, you should visit the official [Material UI Theming Docs](https://mui.com/material-ui/customization/theming/) to learn how to set that up.
254
+
255
+ ```jsx
256
+ function App() {
257
+ //Have you setup your Mui Theme globally in your app root?
258
+ return (
259
+ <ThemeProvider theme={createTheme({...})}>
260
+ ...rest of your application
261
+ </ThemeProvider>
262
+ );
263
+ }
264
+ ```
265
+
266
+ #### Customize Theme Just for your Table
267
+
268
+ Thanks to Material UI allowing you to [nest multiple Theme Providers](https://mui.com/material-ui/customization/theming/#nesting-the-theme), you can change your Material UI Theme just for the `<MaterialReactTable />` component by wrapping a `<ThemeProvider theme={createTheme(...)}>` around just your table. The values in this theme will only effect the `<MaterialReactTable />` component, and not the rest of your site. It will also inherit values from your global theme, so you do not have to redefine everything again. You can just tweak the values you want to change.
269
+
270
+ ```jsx
271
+ import { createTheme, ThemeProvider } from '@mui/material';
272
+ //in one of your normal components
273
+ return (
274
+ <ThemeProvider theme={createTheme({...})}>
275
+ <MaterialReactTable table={table} />
276
+ </ThemeProvider>
277
+ );
278
+ ```
279
+
280
+ #### Custom Material UI Theme Example
281
+
282
+ > Live example: `mui-theme` (call get_mrt_example with that id).
283
+
284
+ ### MRT Theme Values
285
+
286
+ > New in V3
287
+
288
+ Material React Table has a new `mrtTheme` table option where you can change a few of the default color values used by Material React Table.
289
+
290
+ The default background color of the table toolbars and table are controlled by the `mrtTheme.baseBackgroundColor` value. Dragging borders, selected or pinned rows, and filter match highlighting are also configurable in the `mrtTheme` object.
291
+
292
+ Here is the default `mrtTheme` object used internally if not overridden:
293
+
294
+ ```jsx
295
+ const baseBackgroundColor =
296
+ themeOverrides?.baseBackgroundColor ??
297
+ (theme.palette.mode === 'dark'
298
+ ? lighten(theme.palette.background.default, 0.05)
299
+ : theme.palette.background.default);
300
+ return {
301
+ baseBackgroundColor,
302
+ draggingBorderColor: theme.palette.primary.main,
303
+ matchHighlightColor:
304
+ theme.palette.mode === 'dark'
305
+ ? darken(theme.palette.warning.dark, 0.25)
306
+ : lighten(theme.palette.warning.light, 0.5),
307
+ menuBackgroundColor: lighten(baseBackgroundColor, 0.07),
308
+ pinnedRowBackgroundColor: alpha(theme.palette.primary.main, 0.1),
309
+ selectedRowBackgroundColor: alpha(theme.palette.primary.main, 0.2),
310
+ };
311
+ ```
312
+
313
+ ### Customize Table Paper Styling
314
+
315
+ You can customize both the props and the styles of the internal `<Paper />` component that wraps the table by passing in a `muiTablePaperProps` table option. This is useful if you want to change the elevation of the paper, or add a border radius, or any other styling you want to do to the paper.
316
+
317
+ ```jsx
318
+ const table = useMaterialReactTable({
319
+ columns,
320
+ data,
321
+ muiTablePaperProps: {
322
+ elevation: 0, //change the mui box shadow
323
+ //customize paper styles
324
+ sx: {
325
+ borderRadius: '0',
326
+ border: '1px dashed #e0e0e0',
327
+ },
328
+ },
329
+ });
330
+
331
+ return <MaterialReactTable table={table} />;
332
+ ```
333
+
334
+ ### Customize Table Body, Rows, Columns, and Cells
335
+
336
+ #### Stripe Rows Example
337
+
338
+ If you need to style many of the rows or columns in a consistent manner, it usually makes sense to style the `<TableBody />` component itself. For example if you want to stripe the rows, you can do something like this:
339
+
340
+ ```jsx
341
+ const table = useMaterialReactTable({
342
+ columns,
343
+ data,
344
+ muiTableBodyProps: {
345
+ sx: {
346
+ //stripe the rows, make odd rows a darker color
347
+ '& tr:nth-of-type(odd) > td': {
348
+ backgroundColor: '#f5f5f5',
349
+ },
350
+ },
351
+ },
352
+ });
353
+
354
+ return <MaterialReactTable table={table} />;
355
+ ```
356
+
357
+ #### Stripe Columns Example
358
+
359
+ Similarly, if you want to stripe the columns, you can do something like this:
360
+
361
+ ```jsx
362
+ const table = useMaterialReactTable({
363
+ columns,
364
+ data,
365
+ muiTableBodyProps: {
366
+ sx: {
367
+ //stripe the rows, make odd rows a darker color
368
+ '& td:nth-of-type(odd)': {
369
+ backgroundColor: '#f5f5f5',
370
+ },
371
+ },
372
+ },
373
+ muiTableBodyCellProps: {
374
+ sx: {
375
+ borderRight: '2px solid #e0e0e0', //add a border between columns
376
+ },
377
+ },
378
+ });
379
+ ```
380
+
381
+ > Live example: `customize-table-styles` (call get_mrt_example with that id).
382
+
383
+ ### Customize No Rows overlay
384
+
385
+ As part of the customization options, we allow you to override the No Records overlay.
386
+
387
+ ```jsx
388
+ const table = useMaterialReactTable({
389
+ columns,
390
+ data,
391
+ renderEmptyRowsFallback: ({ table }) => (
392
+ <span>Customized No Rows Overlay</span>
393
+ ),
394
+ });
395
+ ```
@@ -0,0 +1,35 @@
1
+ ## Custom Icons Feature Guide
2
+
3
+ Material React Table uses [Material Icons](https://mui.com/material-ui/material-icons) by default for all of its internal icons.
4
+
5
+ If you need to, you can customize and replace some or all of the icons with your own custom icons. You can either use other Material Icons or icons from a completely different library.
6
+
7
+ ### Relevant Table Options
8
+
9
+ Relevant table options (get_mrt_api has full details):
10
+
11
+ - `icons` - type `Partial<MRT_Icons>;`
12
+
13
+ ### Replace with Custom Icons
14
+
15
+ To replace a default icon, specify the icon in the `icons` table option. You should get TS hints for the name of the icons you can replace, but you can also consult [this source file](https://github.com/gyminii/material-react-table/blob/v4/packages/material-react-table/src/icons.ts) for a list of all the icons you can replace.
16
+
17
+ ```jsx
18
+ <MaterialReactTable
19
+ columns={columns}
20
+ data={data}
21
+ icons={{
22
+ //change sort icon, connect internal props so that it gets styled correctly
23
+ ArrowDownwardIcon: (props) => <FontAwesomeIcon icon={faSortDown} {...props} />,
24
+ SearchIcon: () => <FontAwesomeIcon icon={faSearch} />,
25
+ SortIcon: (props) => (<FontAwesomeIcon icon={faArrowDownWideShort} {...props} />), //best practice
26
+ }}
27
+ ```
28
+
29
+ Some icons have `style` props that get applied to them internally. So, in order to preserve the ability of those Icons to be styled with the correct paddings, margins, or rotations, you should pass in `{...props}` to your custom icon component as a best practice.
30
+
31
+ ### Font Awesome Example
32
+
33
+ Here is an example where we use icons from a completely different library, [Font Awesome](https://fontawesome.com/).
34
+
35
+ > Live example: `font-awesome-icons` (call get_mrt_example with that id).