On this page

Kbd

When to show a key, how to write it, and tokens.

Draft. Ported from the shadcn-vue Kbd and restyled with Beehexa tokens. Not yet approved; the API may still change.

Kbd shows a key on the keyboard, or keys pressed together, as a small key cap.

When to use

  • A list of keyboard shortcuts, such as a help panel.
  • A key in instructions: “Press / to search.”
  • A shortcut next to a menu item, inside the menu’s shortcut slot.

When not to use

  • As a button. A key cap is not clickable.
  • For a status or a count. Use a Badge.
  • To show a shortcut only in a tooltip. People need to find shortcuts in one place they can read (Tooltip).

Content

  • Write keys as printed: Ctrl, Shift, Alt, Esc, Enter, Tab; letters in upper case: K.
  • Mac and Windows: show the keys of the platform people are on (⌘ on Mac, Ctrl elsewhere).
  • Keys pressed together: one Kbd per key inside a KbdGroup, with a “+” between them.

Tokens

Part Tokens
Height kbd.height (20 px, the height of a status label); at least as wide
Padding space.050 at the sides
Shape radius.025 (keyboard shortcuts) with a color.border edge
Colours color.background.neutral, color.text.subtle; in a tooltip, no fill and color.text.inverse
Text font.code.default
Group space.050 between keys