@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,89 @@
1
+ import { useMemo, useState } from 'react';
2
+ import { MaterialReactTable, type MRT_ColumnDef } from 'material-react-table';
3
+ import { Box, IconButton } from '@mui/material';
4
+ import {
5
+ Edit as EditIcon,
6
+ Delete as DeleteIcon,
7
+ Email as EmailIcon,
8
+ } from '@mui/icons-material';
9
+ import { data as initialData, type Person } from './makeData';
10
+
11
+ export const Example = () => {
12
+ const columns = useMemo<MRT_ColumnDef<Person>[]>(
13
+ //column definitions...
14
+ () => [
15
+ {
16
+ accessorKey: 'firstName',
17
+ header: 'First Name',
18
+ },
19
+ {
20
+ accessorKey: 'lastName',
21
+ header: 'Last Name',
22
+ },
23
+ {
24
+ accessorKey: 'address',
25
+ header: 'Address',
26
+ },
27
+ {
28
+ accessorKey: 'city',
29
+ header: 'City',
30
+ },
31
+ {
32
+ accessorKey: 'state',
33
+ header: 'State',
34
+ },
35
+ ],
36
+ [],
37
+ //end
38
+ );
39
+
40
+ const [data, setData] = useState<Person[]>(initialData);
41
+
42
+ return (
43
+ <MaterialReactTable
44
+ columns={columns}
45
+ data={data}
46
+ layoutMode="grid"
47
+ displayColumnDefOptions={{
48
+ 'mrt-row-actions': {
49
+ size: 180, //if using layoutMode that is not 'semantic', the columns will not auto-size, so you need to set the size manually
50
+ grow: false,
51
+ },
52
+ }}
53
+ enableRowActions
54
+ renderRowActions={({ row, table }) => (
55
+ <Box sx={{ display: 'flex', flexWrap: 'nowrap', gap: '8px' }}>
56
+ <IconButton
57
+ color="primary"
58
+ onClick={() =>
59
+ window.open(
60
+ `mailto:kevinvandy@mailinator.com?subject=Hello ${row.original.firstName}!`,
61
+ )
62
+ }
63
+ >
64
+ <EmailIcon />
65
+ </IconButton>
66
+ <IconButton
67
+ color="secondary"
68
+ onClick={() => {
69
+ table.setEditingRow(row);
70
+ }}
71
+ >
72
+ <EditIcon />
73
+ </IconButton>
74
+ <IconButton
75
+ color="error"
76
+ onClick={() => {
77
+ data.splice(row.index, 1); //assuming simple data table
78
+ setData([...data]);
79
+ }}
80
+ >
81
+ <DeleteIcon />
82
+ </IconButton>
83
+ </Box>
84
+ )}
85
+ />
86
+ );
87
+ };
88
+
89
+ export default Example;
@@ -0,0 +1,64 @@
1
+ import { useMemo } from 'react';
2
+ import {
3
+ MaterialReactTable,
4
+ MRT_ActionMenuItem,
5
+ type MRT_ColumnDef,
6
+ } from 'material-react-table';
7
+ import { data, type Person } from './makeData';
8
+ import { Edit, Delete } from '@mui/icons-material';
9
+
10
+ export const Example = () => {
11
+ const columns = useMemo<MRT_ColumnDef<Person>[]>(
12
+ //column definitions...
13
+ () => [
14
+ {
15
+ accessorKey: 'firstName',
16
+ header: 'First Name',
17
+ },
18
+ {
19
+ accessorKey: 'lastName',
20
+ header: 'Last Name',
21
+ },
22
+ {
23
+ accessorKey: 'address',
24
+ header: 'Address',
25
+ },
26
+ {
27
+ accessorKey: 'city',
28
+ header: 'City',
29
+ },
30
+ {
31
+ accessorKey: 'state',
32
+ header: 'State',
33
+ },
34
+ ],
35
+ [],
36
+ //end
37
+ );
38
+
39
+ return (
40
+ <MaterialReactTable
41
+ columns={columns}
42
+ data={data}
43
+ enableRowActions
44
+ renderRowActionMenuItems={({ row, table }) => [
45
+ <MRT_ActionMenuItem //or just use a normal MUI MenuItem component
46
+ icon={<Edit />}
47
+ key="edit"
48
+ label="Edit"
49
+ onClick={() => console.info('Edit')}
50
+ table={table}
51
+ />,
52
+ <MRT_ActionMenuItem
53
+ icon={<Delete />}
54
+ key="delete"
55
+ label="Delete"
56
+ onClick={() => console.info('Delete')}
57
+ table={table}
58
+ />,
59
+ ]}
60
+ />
61
+ );
62
+ };
63
+
64
+ export default Example;
@@ -0,0 +1,98 @@
1
+ import { useMemo, useState } from 'react';
2
+ import {
3
+ MaterialReactTable,
4
+ useMaterialReactTable,
5
+ type MRT_ColumnDef,
6
+ type MRT_RowSelectionState,
7
+ } from 'material-react-table';
8
+
9
+ //data definitions...
10
+ interface Person {
11
+ userId: string;
12
+ firstName: string;
13
+ lastName: string;
14
+ age: number;
15
+ address: string;
16
+ city: string;
17
+ state: string;
18
+ }
19
+ //end
20
+
21
+ const data = [
22
+ //data definitions...
23
+ {
24
+ userId: '3f25309c-8fa1-470f-811e-cdb082ab9017', //we'll use this as a unique row id
25
+ firstName: 'Dylan',
26
+ lastName: 'Murray',
27
+ age: 22,
28
+ address: '261 Erdman Ford',
29
+ city: 'East Daphne',
30
+ state: 'Kentucky',
31
+ },
32
+ {
33
+ userId: 'be731030-df83-419c-b3d6-9ef04e7f4a9f',
34
+ firstName: 'Raquel',
35
+ lastName: 'Kohler',
36
+ age: 18,
37
+ address: '769 Dominic Grove',
38
+ city: 'Columbus',
39
+ state: 'Ohio',
40
+ },
41
+ //end
42
+ ];
43
+
44
+ const Example = () => {
45
+ const columns = useMemo<MRT_ColumnDef<Person>[]>(
46
+ //column definitions...
47
+ () => [
48
+ {
49
+ accessorKey: 'firstName',
50
+ header: 'First Name',
51
+ },
52
+ {
53
+ accessorKey: 'lastName',
54
+ header: 'Last Name',
55
+ },
56
+ {
57
+ accessorKey: 'age',
58
+ header: 'Age',
59
+ },
60
+ {
61
+ accessorKey: 'address',
62
+ header: 'Address',
63
+ },
64
+ {
65
+ accessorKey: 'city',
66
+ header: 'City',
67
+ },
68
+ {
69
+ accessorKey: 'state',
70
+ header: 'State',
71
+ },
72
+ ],
73
+ [], //end
74
+ );
75
+
76
+ //optionally, you can manage the row selection state yourself
77
+ const [rowSelection, setRowSelection] = useState<MRT_RowSelectionState>({});
78
+
79
+ const table = useMaterialReactTable({
80
+ columns,
81
+ data,
82
+ enableRowSelection: true,
83
+ enableMultiRowSelection: false, //use radio buttons instead of checkboxes
84
+ getRowId: (row) => row.userId, //give each row a more useful id
85
+ muiTableBodyRowProps: ({ row }) => ({
86
+ //add onClick to row to select upon clicking anywhere in the row
87
+ onClick: row.getToggleSelectedHandler(),
88
+ sx: { cursor: 'pointer' },
89
+ }),
90
+ positionToolbarAlertBanner: 'bottom', //move the alert banner to the bottom
91
+ onRowSelectionChange: setRowSelection, //connect internal row selection state to your own
92
+ state: { rowSelection }, //pass our managed row selection state to the table to use
93
+ });
94
+
95
+ return <MaterialReactTable table={table} />;
96
+ };
97
+
98
+ export default Example;
@@ -0,0 +1,138 @@
1
+ import { useEffect, useMemo, useRef, useState } from 'react';
2
+ import {
3
+ MaterialReactTable,
4
+ useMaterialReactTable,
5
+ type MRT_ColumnDef,
6
+ type MRT_SortingState,
7
+ type MRT_RowVirtualizer,
8
+ } from 'material-react-table';
9
+ import { makeData, type Person } from './makeData';
10
+
11
+ const Example = () => {
12
+ const columns = useMemo<MRT_ColumnDef<Person>[]>(
13
+ //column definitions...
14
+ () => [
15
+ {
16
+ accessorKey: 'firstName',
17
+ header: 'First Name',
18
+ size: 150,
19
+ },
20
+ {
21
+ accessorKey: 'middleName',
22
+ header: 'Middle Name',
23
+ size: 170,
24
+ },
25
+ {
26
+ accessorKey: 'lastName',
27
+ header: 'Last Name',
28
+ size: 150,
29
+ },
30
+ {
31
+ accessorKey: 'email',
32
+ header: 'Email Address',
33
+ size: 300,
34
+ },
35
+ {
36
+ accessorKey: 'phoneNumber',
37
+ header: 'Phone Number',
38
+ size: 250,
39
+ },
40
+ {
41
+ accessorKey: 'address',
42
+ header: 'Address',
43
+ size: 300,
44
+ },
45
+ {
46
+ accessorKey: 'zipCode',
47
+ header: 'Zip Code',
48
+ },
49
+ {
50
+ accessorKey: 'city',
51
+ header: 'City',
52
+ size: 220,
53
+ },
54
+ {
55
+ accessorKey: 'state',
56
+ header: 'State',
57
+ },
58
+ {
59
+ accessorKey: 'country',
60
+ header: 'Country',
61
+ size: 350,
62
+ },
63
+ {
64
+ accessorKey: 'petName',
65
+ header: 'Pet Name',
66
+ },
67
+ {
68
+ accessorKey: 'age',
69
+ header: 'Age',
70
+ },
71
+ {
72
+ accessorKey: 'salary',
73
+ header: 'Salary',
74
+ },
75
+ {
76
+ accessorKey: 'dateOfBirth',
77
+ header: 'Date of Birth',
78
+ },
79
+ {
80
+ accessorKey: 'dateOfJoining',
81
+ header: 'Date of Joining',
82
+ },
83
+ {
84
+ accessorKey: 'isActive',
85
+ header: 'Is Active',
86
+ },
87
+ ],
88
+ [],
89
+ //end
90
+ );
91
+
92
+ //optionally access the underlying virtualizer instance
93
+ const rowVirtualizerInstanceRef = useRef<MRT_RowVirtualizer>(null);
94
+
95
+ const [data, setData] = useState<Person[]>([]);
96
+ const [isLoading, setIsLoading] = useState(true);
97
+ const [sorting, setSorting] = useState<MRT_SortingState>([]);
98
+
99
+ useEffect(() => {
100
+ if (typeof window !== 'undefined') {
101
+ setData(makeData(10_000));
102
+ setIsLoading(false);
103
+ }
104
+ }, []);
105
+
106
+ useEffect(() => {
107
+ //scroll to the top of the table when the sorting changes
108
+ try {
109
+ rowVirtualizerInstanceRef.current?.scrollToIndex?.(0);
110
+ } catch (error) {
111
+ console.error(error);
112
+ }
113
+ }, [sorting]);
114
+
115
+ const table = useMaterialReactTable({
116
+ columns,
117
+ data, //10,000 rows
118
+ defaultDisplayColumn: { enableResizing: true },
119
+ enableBottomToolbar: false,
120
+ enableColumnResizing: true,
121
+ enableColumnVirtualization: true,
122
+ enableGlobalFilterModes: true,
123
+ enablePagination: false,
124
+ enableColumnPinning: true,
125
+ enableRowNumbers: true,
126
+ enableRowVirtualization: true,
127
+ muiTableContainerProps: { sx: { maxHeight: '600px' } },
128
+ onSortingChange: setSorting,
129
+ state: { isLoading, sorting },
130
+ rowVirtualizerInstanceRef, //optional
131
+ rowVirtualizerOptions: { overscan: 5 }, //optionally customize the row virtualizer
132
+ columnVirtualizerOptions: { overscan: 2 }, //optionally customize the column virtualizer
133
+ });
134
+
135
+ return <MaterialReactTable table={table} />;
136
+ };
137
+
138
+ export default Example;
@@ -0,0 +1,119 @@
1
+ ## Accessibility / Keyboard Navigation Guide
2
+
3
+ Material React Table tries to get the basics of data grid accessibility right out of the box. But since you can easily add event handlers to just about any interaction inside of the table, you can heavily customize the accessibility of your table to your needs too.
4
+
5
+ ### Relevant Table Options
6
+
7
+ Relevant table options (get_mrt_api has full details):
8
+
9
+ - `enableKeyboardShortcuts` - type `boolean` - default `true`
10
+
11
+ ### Keyboard Navigation
12
+
13
+ > New in v3
14
+
15
+ Material React Table V3 introduces a new table option that is `true` by default: `enableKeyboardShortcuts`
16
+
17
+ #### `enableKeyboardShortcuts`
18
+
19
+ This option enables the following keyboard shortcuts:
20
+
21
+ - `Tab` - Moves the focus to the next cell or element in the table (standard browser behavior)
22
+ - `Arrow Up` - Moves the focus 1 cell up
23
+ - `Arrow Down` - Moves the focus 1 cell down
24
+ - `Arrow Left` - Moves the focus 1 cell left
25
+ - `Arrow Right` - Moves the focus 1 cell right
26
+ - `Home` - Moves the focus to the first cell in the current row
27
+ - `End` - Moves the focus to the last cell in the current row
28
+ - `Page Up` - Moves the focus to the first cell in the current column
29
+ - `Page Down` - Moves the focus to the last cell in the current column
30
+ - `Ctrl/Cmd + Home` - Moves the focus to the first cell in the table (top left in left-to-right languages)
31
+ - `Ctrl/Cmd + End` - Moves the focus to the last cell in the table (bottom right in left-to-right languages)
32
+ - `Enter` - Performs certain actions in the currently focused cell such as sorting, row selection, row expansion, row pinning, etc.
33
+ - `Space` - Also performs certain actions in the currently focused cell such as sorting, row selection, row expansion, row pinning, etc.
34
+ - `Ctrl/Cmd + Enter` - Opens column actions menu on a header
35
+ - `Escape` - Exits full screen mode
36
+
37
+ A `tabIndex={0}` is also automatically added to all cells, headers, and footers when `enableKeyboardShortcuts` is enabled to allow for keyboard focus.
38
+
39
+ ### Custom Keyboard Shortcuts
40
+
41
+ You do not have to use the provided keyboard shortcuts. You can turn off `enableKeyboardShortcuts` and add your own keyboard shortcuts using the `onKeyDown` event handler on all of the table cells (or any other element).
42
+
43
+ You can also add custom focus styles to any element using the `sx` prop.
44
+
45
+ ```tsx
46
+ const table = useMaterialReactTable({
47
+ columns,
48
+ data,
49
+ //add custom keyboard shortcuts
50
+ defaultColumn: {
51
+ //header
52
+ muiTableHeadCellProps: {
53
+ onKeyDown: (event) => {
54
+ if (event.key === 't' && event.metaKey) {
55
+ alert('You pressed the custom shortcut!');
56
+ }
57
+ },
58
+ tabIndex: 0, //allow for keyboard focus
59
+ },
60
+ //body
61
+ muiTableBodyCellProps: {
62
+ onKeyDown: (event) => {
63
+ if (event.key === 't' && event.metaKey) {
64
+ alert('You pressed the custom shortcut!');
65
+ }
66
+ },
67
+ //add custom focus styles
68
+ sx: {
69
+ '&:focus-visible': {
70
+ //or just `&:focus` if you want all focus events to be visible
71
+ outline: '2px solid red',
72
+ outlineOffset: '-2px',
73
+ },
74
+ },
75
+ tabIndex: 0, //allow for keyboard focus
76
+ },
77
+ },
78
+ enableKeyboardShortcuts: false, //turn off default keyboard shortcuts from MRT
79
+ });
80
+ ```
81
+
82
+ ### Custom Focus Styles
83
+
84
+ An outline is automatically added to all elements when they are focused. You can easily customize the color of the outline by setting `cellNavigationOutlineColor` property in the `mrtTheme` table option.
85
+
86
+ ```tsx
87
+ const table = useMaterialReactTable({
88
+ columns,
89
+ data,
90
+ mrtTheme: {
91
+ cellNavigationOutlineColor 'limegreen'
92
+ }
93
+ });
94
+ ```
95
+
96
+ Or, of course, you can just use the `sx` props to override any styles you want, just like any other style override in MRT.
97
+
98
+ ```tsx
99
+ const table = useMaterialReactTable({
100
+ columns,
101
+ data,
102
+ defaultColumn: {
103
+ muiTableBodyCellProps: {
104
+ sx: {
105
+ '&:focus-visible': {
106
+ outline: '4px solid red',
107
+ outlineOffset: '-4px',
108
+ },
109
+ },
110
+ },
111
+ },
112
+ });
113
+ ```
114
+
115
+ ### Full Screen Mode
116
+
117
+ Now in V3, a focus trap is applied to the table when in full screen mode. This is to prevent the user from navigating outside of the table when using the arrow keys.
118
+
119
+ The user can exit full screen mode by pressing `Escape`.