Kbd

Typography
stable

Keyboard shortcut renderer using semantic <kbd> elements with filled, outlined and tonal variants.

Structure

Anatomy

Visual breakdown of the component's internal structure with BEM class call-outs.

Anatomy of OrigamKbdSchematic of the Kbd component with 3 numbered parts: root key, combination wrapper, and separator. SINGLE KEY Ctrl 1 COMBINATION Ctrl + S 2 3 Renders native <kbd> HTML elements — always semantic
Anatomy of <origam-kbd>. Single-key mode ① renders one <kbd>; combination mode ② wraps individual keys in nested <kbd> elements separated by a ③ span.
1.origam-kbd
Root <kbd> element. In single-key mode, renders the key directly. The v-contrast directive auto-adjusts text color for accessibility.
2.origam-kbd__key
Individual key element in combination mode. Each item in the combination array renders as a nested <kbd class="origam-kbd__key">.
3.origam-kbd__separator
Character rendered between keys in combination mode. aria-hidden="true" so screen readers skip it. Default: "+".

API

Props

All props accepted by this component, with their type, default value and description.

text
string
Single key label (e.g. "⌘", "Ctrl", "A"). Overridden by the default slot.
combination
string[]
Composed shortcut rendered as individual nested <kbd> elements (e.g. ["Ctrl", "Shift", "Z"]).
separator
string
'+'
Character shown between each key in a combination. Defaults to "+".
variant
'outlined'
Visual style. "outlined" (default) shows a border and shadow; "filled" uses a surface background; "tonal" uses a tinted background without border.
id
string
class
string | Array<string> | object
style
string | Array<string> | object | StyleValue
color
Foreground color override for the key text.
bgColor
Background color override for the key surface.
size
'default'
Controls the font-size of the key label via design tokens.
border
boolean | number | string | TDirectionBoth | Array<TDirectionBoth>
false
Applies a border. Pass true for the default border.
borderTop
boolean | number | string
borderLeft
boolean | number | string
borderBottom
boolean | number | string
borderRight
boolean | number | string
borderBlock
boolean | number | string
borderInline
boolean | number | string
borderInlineStart
boolean | number | string
borderInlineEnd
boolean | number | string
borderBlockStart
boolean | number | string
borderBlockEnd
boolean | number | string
borderColor
string
borderStyle
string
borderTopColor
TColor
borderRightColor
TColor
borderBottomColor
TColor
borderLeftColor
TColor
borderInlineStartColor
TColor
borderInlineEndColor
TColor
borderBlockStartColor
TColor
borderBlockEndColor
TColor
elevation
TElevation
Border-radius token or boolean.
roundedTopRight
boolean | number | string
roundedTopLeft
boolean | number | string
roundedBottomLeft
boolean | number | string
roundedBottomRight
boolean | number | string
roundedStartStart
boolean | number | string
roundedStartEnd
boolean | number | string
roundedEndStart
boolean | number | string
roundedEndEnd
boolean | number | string
fontSize
TFontSize
fontWeight
TFontWeight
fontFamily
TFontFamily

API

Slots

Content slots exposed by this component.

#default
Custom key label content. Overrides the text prop. Use when you need formatted or rich text inside the key.

API

Exposed members

Properties and methods accessible via template ref (defineExpose). Use them for programmatic control.

<T extends object>(props: T, exclude?: string[]) => Partial<T>
Utility to forward a filtered subset of props to a child component.
Ref<string>
Reactive CSS string generated by useStyle from the computed kbdStyles.
string
Unique style-sheet ID for this instance.
() => void
Injects the computed style sheet. Called automatically on mount.
() => void
Removes the injected style sheet. Called automatically on unmount.
Ref<boolean>
True once the style sheet has been injected into the DOM.

Customisation

CSS variables

CSS custom properties exposed by this component. Override them to customise the component without losing theme compatibility.

Key background color. Overridden per variant.
Key foreground color. Auto-adjusted by v-contrast directive.
Key border color.
Border width. Set to 0 for tonal variant.
Key border radius. Overridden by the rounded prop.
Monospace font family for the key label.
Key label font weight.
3D key shadow. Composed of a bottom border-like shadow and an inset highlight. Cleared for tonal/combination variants.
Gap between keys in combination mode.
Color of the separator character between keys.

Inclusion

Accessibility

ARIA roles, keyboard navigation and focus management. Sourced from the real component template.

Notes

  • Uses native <kbd> HTML elements — screen readers announce these as keyboard input, requiring no ARIA role override.
  • The separator span in combination mode carries aria-hidden="true" so screen readers skip the "+" character and only read the key names.
  • The v-contrast directive automatically adjusts the text color to ensure WCAG contrast requirements are met against the background.

Foundation

Design tokens

Excerpt from this component's token declarations — the --origam-<component>---<property> variables, declared in its hand-maintained token sheet with no build step.

Source
color
var(--origam-color__surface---overlay)
Default key background.
dimension
var(--origam-radius---sm)
Default key border radius (4px).
fontFamily
var(--origam-font__family---mono)
Monospace font stack for key labels.
fontWeight
var(--origam-font__weight---medium)
Key label font weight.
shadow
var(--origam-shadow---xs)
Key shadow for the 3D depth effect.
dimension
var(--origam-space---1)
Gap between keys in combination mode.

Interactive

Playground

Edit props live and see the component update in real time. The generated code snippet updates as you change values.

Rendering the live preview…

Usage

Examples

Ready-to-paste code snippets for your templates.

Single keys

vue

Keyboard shortcuts (combinations)

vue

Variants

vue