Skip to content

Kbd

A keyboard shortcut display component. keys is split by spaces into multiple keycaps joined with +; non-interactive.

Basic usage

Combined shortcuts

Semantic key names

keys supports semantic key names auto-mapped to symbols (e.g. command → ⌘, shift → ⇧). Each mapped keycap embeds an <abbr title="full name"> for screen readers and hover tooltips; unmapped names render literally (e.g. k, f1):

Semantic key name mapping

Single key & empty state

Single key & empty state

Custom content

Slot content takes priority

⌘CSpace

Variants

raised (default, 3D) / outline (bordered) / subtle (light background) / plain (text only):

Four variants

Sizes

Three sizes

Color

Accepts 11 preset names (auto-adapting to light/dark themes) or any CSS color value (takes effect immediately, overriding presets and defaults). Tints the keycap background:

Preset palette

Custom color values

Composition

Group multiple kbd with oas-space (spacing control):

Grouping

Nest inside other components via slot projection:

Nesting in a button

Command palette

API

Attributes

AttributeDescriptionTypeDefault
colorCustom color: accepts 11 preset names (mapped to --oas-preset-*-text compliant tokens) or any CSS color value; keycap background is tinted and the border followsstring
keysSpace-separated key sequence, e.g. "ctrl shift k"string
sizeSize tier: small / medium (default) / large; invalid values fall back to medium with a warningstring
variantStyle: raised (default, 3D keycap) / outline (bordered) / subtle (light background) / plain (text only); invalid values fall back to raised with a warningstring

Slots

NameDescription
default

Note: empty keys renders a single empty keycap; slot content takes priority when provided. The component is purely presentational with role="text" and dispatches no events.

Released under the MIT OR Apache-2.0 License.