KeybindingHint

Indicates the presence of a keybinding available for an action.
  • Draft
  • Not reviewed for accessibility

Use KeybindingHint to make keyboard shortcuts discoverable. Can render visual keybinding hints in condensed (abbreviated) form or expanded form, and provides accessible alternative text for screen reader users.

  • Move down control down arrow
  • Unsubscribe ithen j
  • Delete shift control delete
import {KeybindingHint} from '@primer/react/drafts'

Examples

Single keys

Use the full names of the keys as returned by KeyboardEvent.key. Key names are case-insensitive.

Special key names

Because the + and space characters are used to build chords and sequences as described below, their names must be spelled out to be used as keys.

Chords

Chords are multiple keys that are pressed at the same time. Combine keys in a chord with +. Keys are automatically sorted into a standardized order so that modifiers come first.

Platform-dependent modifier

Typical chords use Command on MacOS and Control on other devices. To automatically render Command or Control based on the user's operating system, use the special key name Mod.

Sequences

Sequences are keys or chords that are pressed one after the other. Combine elements in a sequence with a space. For example, a b means "press a, then press b".

Full display format

The default condensed format should be used on UI elements like buttons, menuitems, and inputs. In long-form text (prose), the full variant can be used instead to help the text flow better.

onEmphasis variant

When rendering on 'emphasis' colors, use the onEmphasis variant.

Props

KeybindingHint

NameTypeDefaultDescription
keys
string

The keys involved in this keybinding.

format
'condensed' | 'full'
'condensed'

Control the display format.

variant
'normal' | 'onEmphasis'
'normal'

Set to onEmphasis for display on 'emphasis' colors.

Status

Alpha

  • Component props and basic example usage of the component are documented on primer.style/react.
  • Component does not have any unnecessary third-party dependencies.
  • Component can adapt to different themes.
  • Component can adapt to different screen sizes.
  • Component has robust unit test coverage (100% where achievable).
  • Component has visual regression coverage of its default and interactive states.
  • Component does not introduce any axe violations.
  • Component has been manually reviewed by the accessibility team and any resulting issues have been addressed.

Beta

  • Component is used in a production application.
  • Common usage examples are documented on primer.style/react.
  • Common usage examples are documented in storybook stories.
  • Component has been reviewed by a systems designer and any resulting issues have been addressed.
  • Component does not introduce any performance regressions.

Stable

  • Component API has been stable with no breaking changes for at least one month.
  • Feedback on API usability has been sought from developers using the component and any resulting issues have been addressed.
  • Component has corresponding design guidelines documented in the interface guidelines.
  • Component has corresponding Figma component in the Primer Web library.
  • Tooling (such as linters, codemods, etc.) exists to prevent further use of alternatives.