Skip to main content

Kbd

A keyboard key or shortcut, shown as text.

In Multi-brand

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Multi-brand: A shortcut shown beside an action on laptops, the action also reachable by tap. Not decoration, and never the only way in.

  • 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​

  • Shared structure: object, state, next step.
  • Brand tone lives in headlines and marketing copy, not in errors.
  • Errors and confirmations read the same in every brand.
  • Use: Get started, Plan, Order. Avoid: Brand-specific words in errors, Jargon.

The labels components use, from the voice tokens:

  • content.action.commit: Save
  • content.action.cancel: Cancel
  • content.action.destroy: Remove
  • content.action.retry: Try again
  • content.action.empty-action: Get started

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

Multi-brand decides what changes when you switch theme. Here a switch changes colors, type and shape, so the marked rows differ between its brands and 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
Corner
Changes with theme
component.kbd.radiusradius.badgevar(--kbd-radius)Aster Lightradius.4:0.25remAster Darkradius.4:0.25remBirch Lightradius.999:9999pxBirch Darkradius.999:9999pxCoral Lightradius.999:9999pxCoral Darkradius.999:9999px
Fill
Changes with theme
component.kbd.backgroundcolor.surface.sunkenvar(--kbd-background)Aster Lightslate-deep.light.100:#F1F5F9Aster Darkslate-deep.dark.100:#1E293BBirch Lightslate-deep.light.100:#F1F5F9Birch Darkslate-deep.dark.100:#1E293BCoral Lightslate-deep.light.100:#F1F5F9Coral Darkslate-deep.dark.100:#1E293B
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.13:0.8125rem
Weightcomponent.kbd.font-weighttype.label.font-weightvar(--kbd-font-weight)font.weight.600:600
Text
Changes with theme
component.kbd.labelcolor.text.mutedvar(--kbd-label)Aster Lightslate-deep.light.600:#4B5A6FAster Darkslate-deep.dark.400:#96A3B5Birch Lightslate-deep.light.600:#4B5A6FBirch Darkslate-deep.dark.400:#96A3B5Coral Lightslate-deep.light.600:#4B5A6FCoral Darkslate-deep.dark.400:#96A3B5
Background 2
Changes with theme
component.kbd.background-2color.surface.canvasvar(--kbd-background-2)Aster Lightslate-deep.light.50:#F8FAFCAster Darkslate-deep.dark.0:#020617Birch Lightslate-deep.light.50:#F8FAFCBirch Darkslate-deep.dark.0:#020617Coral Lightslate-deep.light.50:#F8FAFCCoral Darkslate-deep.dark.0:#020617
Label 2
Changes with theme
component.kbd.label-2color.surface.canvasvar(--kbd-label-2)Aster Lightslate-deep.light.50:#F8FAFCAster Darkslate-deep.dark.0:#020617Birch Lightslate-deep.light.50:#F8FAFCBirch Darkslate-deep.dark.0:#020617Coral Lightslate-deep.light.50:#F8FAFCCoral Darkslate-deep.dark.0:#020617
Group
Gapcomponent.kbd.group.gapspace.gap.tightvar(--kbd-group-gap)space.8:0.5rem