Skip to content

Commit eb48bad

Browse files
committed
Document the keyboardShortcutRepresentation prop
1 parent 0560b25 commit eb48bad

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

docs/Menu.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,14 @@ export const MyMenu = () => (
183183
);
184184
```
185185

186-
| Prop | Required | Type | Default | Description |
187-
| ------------------ | -------- | -------------------- | ------- | ---------------------------------------- |
188-
| `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 | string[]` | - | The keyboard shortcut(s) to activate this menu item |
191-
| `leftIcon` | Optional | `ReactNode` | - | The menu icon |
192-
| `sx` | Optional | `SxProp` | - | Style overrides, powered by MUI System |
186+
| Prop | Required | Type | Default | Description |
187+
| -------------------------------- | -------- | -------------------- | -------------------- | ---------------------------------------- |
188+
| `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 | string[]` | - | The keyboard shortcut(s) to activate this menu item |
191+
| `keyboardShortcutRepresentation` | 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 |
193194

194195
Additional props are passed down to [the underling Material UI `<MenuItem>` component](https://mui.com/material-ui/api/menu-item/).
195196

@@ -240,14 +241,34 @@ export const MyMenu = () => (
240241
<Menu.Item
241242
to="/sales"
242243
primaryText="Sales"
243-
keyboardShortcut="ctrl+alt+S"
244+
// Letter G then letter S
245+
keyboardShortcut="G>S"
244246
/>
245247
</Menu>
246248
);
247249
```
248250

249251
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/) for more examples.
250252

253+
### `keyboardShortcutRepresentation`
254+
255+
A React node that displays the keyboard shortcut. It defaults to `<KeyboardShortcut>`. You can customize it by providing your own:
256+
257+
```tsx
258+
const CustomMenu = () => (
259+
<Menu>
260+
<Menu.Item
261+
to="/sales"
262+
primaryText="Sales"
263+
keyboardShortcut="G>S"
264+
// Render a simple textual representation of the shortcut
265+
keyboardShortcutRepresentation="G then S"
266+
/>
267+
</Menu>
268+
);
269+
```
270+
271+
251272
### `leftIcon`
252273

253274
The `letfIcon` prop allows setting the menu left icon.

0 commit comments

Comments
 (0)