Skip to content

Kbd

One keyboard key, for shortcut hints in menus, tooltips and help text.

PrimitivesServer-rendered

Examples

Shortcuts

One key per Kbd. Put the keys of a chord side by side.

Light
⌘K
Esc/
Dark
⌘K
Esc/
Example
<Inline gap="1"><Kbd>⌘</Kbd><Kbd>K</Kbd></Inline>
<Kbd>Esc</Kbd>
<Kbd>/</Kbd>

In help text

Light

Press ⌘ K to search servers, skills and settings.

Dark

Press ⌘ K to search servers, skills and settings.

Example
<Text size="sm" tone="ink-2">
  Press <Kbd>⌘</Kbd> <Kbd>K</Kbd> to search servers, skills and settings.
</Text>

Usage

Usage
import { Kbd } from '@switchboard/ui'

<Kbd>⌘</Kbd><Kbd>K</Kbd>

Props

Every component also takes mix, for css() and mixins applied after its own style.

Kbd

Kbd props
PropTypeDefaultDescription
childrenRemixNode–The key: a symbol (⌘, ⇧) or a short name (Esc, Enter).
mixMix–Extra css() or mixins, applied after the key style.

Also accepts every <kbd> attribute.

Accessibility

  • Renders a native <kbd>, which screen readers read as its text.
  • Symbols such as ⌘ are read inconsistently; where the shortcut matters, also write the name ("Command K").

Guidance

Do

  • Show the shortcut next to the action it triggers.
  • Use the symbol printed on the key.

Don’t

  • Put a whole chord in one Kbd.
  • Make a shortcut the only way to reach an action.