You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`to`| Required | `string | location` | - | The menu item's target. It is passed to a React Router [NavLink](https://reacttraining.com/react-router/web/api/NavLink) component. |
189
-
|`primaryText`| Required |`ReactNode`| - | The menu content, displayed when the menu isn't minimized. |
190
-
|`leftIcon`| Optional |`ReactNode`| - | The menu icon |
|`to`| Required | `string | location` | - | The menu item's target. It is passed to a React Router [NavLink](https://reacttraining.com/react-router/web/api/NavLink) component. |
189
+
|`primaryText`| Required |`ReactNode`| - | The menu content, displayed when the menu isn't minimized. |
190
+
|`keyboardShortcut`| Optional |`string`| - | The keyboard shortcut(s) to activate this menu item |
191
+
|`keyboardShortcut Representation`| Optional |`ReactNode`|`<KeyboardShortcut>`| A react node that displays the keyboard shortcut |
192
+
|`leftIcon`| Optional |`ReactNode`| - | The menu icon |
193
+
|`sx`| Optional |`SxProp`| - | Style overrides, powered by MUI System |
191
194
192
195
Additional props are passed down to [the underling Material UI `<MenuItem>` component](https://mui.com/material-ui/api/menu-item/).
193
196
197
+
### `to`
194
198
195
-
The `primaryText` prop accepts a string, that react-admin passes through the [translation utility](./Translation.md). Alternately, you can set the menu item content using the `children`, e.g. to display a badge on top of the menu item:
199
+
The menu item's target. It is passed to a React Router [NavLink](https://reacttraining.com/react-router/web/api/NavLink) component.
The menu content, displayed when the menu isn't minimized. It accepts a string, that react-admin passes through the [translation utility](./Translation.md). Alternately, you can set the menu item content using the `children`, e.g. to display a badge on top of the menu item:
Note that if you use the `children` prop, you'll have to translate the menu item content yourself using [`useTranslate`](./useTranslate.md). You'll also need to provide a `primaryText` either way, because it will be rendered in the tooltip when the side menu is collapsed.
214
233
234
+
### `keyboardShortcut`
235
+
236
+
The keyboard shortcut(s) to activate this menu item. Pass a string or an array of string that defines the supported keyboard shortcuts:
237
+
238
+
```tsx
239
+
exportconst MyMenu = () => (
240
+
<Menu>
241
+
<Menu.Item
242
+
to="/sales"
243
+
primaryText="Sales"
244
+
// G key then S key
245
+
keyboardShortcut="G>S"
246
+
/>
247
+
</Menu>
248
+
);
249
+
```
250
+
251
+

252
+
253
+
This leverages the [react-hotkeys-hook](https://github.com/JohannesKlauss/react-hotkeys-hook) library, checkout [their documentation](https://react-hotkeys-hook.vercel.app/docs/documentation/useHotkeys/basic-usage) for more examples.
254
+
255
+
### `keyboardShortcutRepresentation`
256
+
257
+
A React node that displays the keyboard shortcut. It defaults to `<KeyboardShortcut>`. You can customize it by providing your own:
258
+
259
+
```tsx
260
+
const CustomMenu = () => (
261
+
<Menu>
262
+
<Menu.Item
263
+
to="/sales"
264
+
primaryText="Sales"
265
+
keyboardShortcut="G>S"
266
+
// Render a simple textual representation of the shortcut
267
+
keyboardShortcutRepresentation="G then S"
268
+
/>
269
+
</Menu>
270
+
);
271
+
```
272
+
273
+

274
+
275
+
276
+
### `leftIcon`
277
+
215
278
The `letfIcon` prop allows setting the menu left icon.
|`&.RaMenuItemLink-active`| Applied to the underlying `MuiMenuItem`'s `activeClassName` prop |
304
+
|`& .RaMenuItemLink-icon`| Applied to the `ListItemIcon` component when `leftIcon` prop is set |
305
+
306
+
To override the style of all instances of `<MenuItemLink>` using the [application-wide style overrides](./AppTheme.md#theming-individual-components), use the `RaMenuItemLink` key.
235
307
236
308
**Tip**: The `<Menu.Item>` component makes use of the React Router [NavLink](https://reactrouter.com/docs/en/v6/components/nav-link) component, hence allowing to customize the active menu style. For instance, here is how to use a custom theme to show a left border for the active menu:
237
309
@@ -260,15 +332,6 @@ export const theme = {
260
332
};
261
333
```
262
334
263
-
You can use the `sx` prop to customize the style of the component.
|`&.RaMenuItemLink-active`| Applied to the underlying `MuiMenuItem`'s `activeClassName` prop |
268
-
|`& .RaMenuItemLink-icon`| Applied to the `ListItemIcon` component when `leftIcon` prop is set |
269
-
270
-
To override the style of all instances of `<MenuItemLink>` using the [application-wide style overrides](./AppTheme.md#theming-individual-components), use the `RaMenuItemLink` key.
271
-
272
335
## `<Menu.DashboardItem>`
273
336
274
337
The `<Menu.DashboardItem>` component displays a menu item for the dashboard.
0 commit comments