Skip to main content

Kbd

A keyboard key or shortcut, shown as text.

Left out of Brand expressive Visitors come from social posts on their phones, and they are new customers deciding if they care. A keyboard shortcut serves neither. Use instead: Button

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

  • Use it when: Telling people the shortcut for an action.
  • Not when: Decoration, or the only way to discover an action.

Instead:

  • Command: Where shortcuts are often listed.

Words​

  • Headlines are short and bold. Three to six words.
  • Verbs that move: Join, Try, Go.
  • Playful in headlines, plain in errors.
  • Use: Join, Drop, Go, Love. Avoid: Synergy, Leverage, Kindly.

The labels components use, from the voice tokens:

  • content.action.commit: Go
  • content.action.cancel: Not now
  • content.action.destroy: Remove
  • content.action.retry: Try again
  • content.action.empty-action: Explore the drop

See Voice and tone for the whole voice.

Use it in code​

npx open-ds add kbd

The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.

Tokens it reads​

Kbd reads 10 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Kbd's tokens to change Kbd alone.

Changes with theme

Brand expressive decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.

PartIts token and the semantic it aliasesValue
Kbd
Gapcomponent.kbd.gapspace.gap.tightvar(--kbd-gap)space.8:0.5rem
Cornercomponent.kbd.radiusradius.badgevar(--kbd-radius)radius.999:9999px
Fill
Changes with theme
component.kbd.backgroundcolor.surface.sunkenvar(--kbd-background)Lighttaupe.light.100:#FCEFE6Darktaupe.dark.100:#33241F
Padding, left and rightcomponent.kbd.padding-xcomponent-spacing-map.x1var(--kbd-padding-x)space.4:0.25rem
Text sizecomponent.kbd.font-sizetype.caption.font-sizevar(--kbd-font-size)font.size.14:0.875rem
Weightcomponent.kbd.font-weighttype.label.font-weightvar(--kbd-font-weight)font.weight.700:700
Text
Changes with theme
component.kbd.labelcolor.text.mutedvar(--kbd-label)Lighttaupe.light.600:#6B544ADarktaupe.dark.400:#B5988A
Background 2
Changes with theme
component.kbd.background-2color.surface.canvasvar(--kbd-background-2)Lighttaupe.light.50:#FFF8F3Darktaupe.dark.0:#120B09
Label 2
Changes with theme
component.kbd.label-2color.surface.canvasvar(--kbd-label-2)Lighttaupe.light.50:#FFF8F3Darktaupe.dark.0:#120B09
Group
Gapcomponent.kbd.group.gapspace.gap.tightvar(--kbd-group-gap)space.8:0.5rem