KeybindingHint
KeybindingHint indicates the presence of an available keyboard shortcut. It renders platform-appropriate key glyphs to help users discover and remember keybindings.
React examples
Default
Use the keys prop to describe the keys involved in the shortcut. Combine keys with + to form chords, and separate chords with a space to form sequences. The fake key name Mod represents Command on macOS and Control on other platforms.
Sequences and chords
Sequences (keys pressed one after another) are separated by a space. Chords (keys pressed simultaneously) are joined with +. See hotkey format details for the full syntax.
Format
- Condensed (default): Best for compact contexts like menus and tooltips where each key is rendered as a separate glyph.
- Full: Joins keys with
+and is better suited for prose or longer-form copy.
Size
Use size="small" for very dense surfaces. The default normal size matches the height of body text.
Variant
Set the variant prop so the hint maintains sufficient contrast against the surface it appears on.
normal(default): Use on neutral backgrounds and default buttons.onEmphasis: Use on emphasized backgrounds such as banners or popovers with strong fills.onPrimary: Use inside primary buttons. The IconButtonkeybindingHintprop applies the correct variant automatically.
More code examples
See the KeybindingHint Storybook stories
Usage
- Use
KeybindingHintto expose keyboard shortcuts that are already wired up elsewhere. The component is purely visual — it does not register any keyboard handlers. - Pair the hint with the action it accelerates so users understand what the shortcut does. Common patterns are the trailing visual of a Button, the trailing visual of an ActionList item, or inside a tooltip on an IconButton.
- Use
Modinstead ofControlorCommandso the hint renders the correct modifier per platform. - Avoid rendering hints for shortcuts that are not actually available in the current context.
Props
KeybindingHint
| Name | Default | Description |
|---|---|---|
keys | stringThe keys involved in this keybinding. | |
format | 'condensed' | 'condensed' | 'full'Control the display format. |
variant | 'normal' | 'normal' | 'onEmphasis'Set to |
size | 'normal' | 'small' | 'normal'Control the size of the hint. |