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
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
API
Attributes
| Attribute | Description | Type | Default |
|---|---|---|---|
color | Custom color: accepts 11 preset names (mapped to --oas-preset-*-text compliant tokens) or any CSS color value; keycap background is tinted and the border follows | string | — |
keys | Space-separated key sequence, e.g. "ctrl shift k" | string | — |
size | Size tier: small / medium (default) / large; invalid values fall back to medium with a warning | string | — |
variant | Style: raised (default, 3D keycap) / outline (bordered) / subtle (light background) / plain (text only); invalid values fall back to raised with a warning | string | — |
Slots
| Name | Description |
|---|---|
| default | — |
Note: empty
keysrenders a single empty keycap; slot content takes priority when provided. The component is purely presentational withrole="text"and dispatches no events.