Officina UI
Components

Shortcut

Platform-aware keyboard shortcut display that maps mod keys to native symbols.

Shortcut renders a key combo from a keys string like "mod+k" (or an array of tokens) as a row of Kbd badges. It detects the platform and translates keys accordingly — mod becomes ⌘ on macOS and Ctrl elsewhere, with similar mapping for shift, alt, enter, and arrows. By default keys sit flush together; set withPlus to render visible + separators.

Example

Preview
Command menu CtrlKSave CtrlSSubmit ShiftEnter
import { Shortcut } from '@officina/ui';

function Hints() {
  return (
    <div>
      <Shortcut keys="mod+k" />
      <Shortcut keys="shift+enter" withPlus />
    </div>
  );
}

API

PropTypeDefaultDescription
keys*string | string[]—Combo like `"mod+k"`, `"shift+enter"`, or an array of keys.
withPlusbooleanfalseRender `+` separators between keys.

On this page