Kbd

A key in a hairline box, and ShortcutHint, the platform's modifier and a key pushed to the end of a menu row: ⌘ on Apple devices, Ctrl elsewhere.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { Kbd, ShortcutHint } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Esc

Props

children

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoUse ShortcutHint at the end of a menu row for a modifier shortcut, like opening search. It shows ⌘ on Apple devices and Ctrl elsewhere.
DoPut each key in its own Kbd, like ⌘ then K, so the reader sees how many keys to press.
Don'tWrite ⌘ or Ctrl by hand for a modifier shortcut. Half the firm would read the wrong key; ShortcutHint picks the platform's.
Don'tMake a shortcut the only way to an action. Put the action in a menu or button too, so it works by pointer and touch.

Props

Kbd

PropTypeDefaultDescription
children *ReactNode—What it shows inside.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

ShortcutHint

PropTypeDefaultDescription
chord *string—The key pressed with the modifier, like "K".
classNamestring—Classes added to the root element, merged with its own. Tokens only.

Code

What the playground shows, ready to copy.

import { Kbd } from "@leap-crm/design-system";

<Kbd>Esc</Kbd>