Kbd
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.
<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. Thev-contrastdirective auto-adjusts text color for accessibility. - 2.origam-kbd__key
- Individual key element in combination mode. Each item in the
combinationarray 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.
- textstring
- Single key label (e.g. "⌘", "Ctrl", "A"). Overridden by the default slot.
- combinationstring[]
- Composed shortcut rendered as individual nested <kbd> elements (e.g. ["Ctrl", "Shift", "Z"]).
- separatorstring'+'
- Character shown between each key in a combination. Defaults to "+".
- Visual style. "outlined" (default) shows a border and shadow; "filled" uses a surface background; "tonal" uses a tinted background without border.
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- color
- Foreground color override for the key text.
- bgColor
- Background color override for the key surface.
- Controls the font-size of the key label via design tokens.
- borderboolean | number | string | TDirectionBoth | Array<TDirectionBoth>false
- Applies a border. Pass true for the default border.
- borderTopboolean | number | string
- borderLeftboolean | number | string
- borderBottomboolean | number | string
- borderRightboolean | number | string
- borderBlockboolean | number | string
- borderInlineboolean | number | string
- borderInlineStartboolean | number | string
- borderInlineEndboolean | number | string
- borderBlockStartboolean | number | string
- borderBlockEndboolean | number | string
- borderColorstring
- borderStylestring
- borderTopColorTColor
- borderRightColorTColor
- borderBottomColorTColor
- borderLeftColorTColor
- borderInlineStartColorTColor
- borderInlineEndColorTColor
- borderBlockStartColorTColor
- borderBlockEndColorTColor
- elevationTElevation
- Border-radius token or boolean.
- roundedTopRightboolean | number | string
- roundedTopLeftboolean | number | string
- roundedBottomLeftboolean | number | string
- roundedBottomRightboolean | number | string
- roundedStartStartboolean | number | string
- roundedStartEndboolean | number | string
- roundedEndStartboolean | number | string
- roundedEndEndboolean | number | string
- fontSizeTFontSize
- fontWeightTFontWeight
- fontFamilyTFontFamily
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.
- colorvar(--origam-color__surface---overlay)
- Default key background.
- dimensionvar(--origam-radius---sm)
- Default key border radius (4px).
- fontFamilyvar(--origam-font__family---mono)
- Monospace font stack for key labels.
- fontWeightvar(--origam-font__weight---medium)
- Key label font weight.
- shadowvar(--origam-shadow---xs)
- Key shadow for the 3D depth effect.
- dimensionvar(--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
Keyboard shortcuts (combinations)
Variants