Kbd

Typography
stable

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

Structure

Anatomie

Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.

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

Toutes les props acceptées par ce composant, avec leur type, valeur par défaut et 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

Emplacements de contenu exposés par ce composant.

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

API

Membres exposés

Propriétés et méthodes accessibles via ref template (defineExpose). Utilisés pour le contrôle programmatique.

<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.

Personnalisation

Variables CSS

Propriétés CSS personnalisées exposées par ce composant. Surchargez-les pour personnaliser sans perdre la compatibilité avec le thème.

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

Accessibilité

Rôles ARIA, navigation clavier et gestion du focus. Sourcé depuis le template réel du composant.

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.

Fondation

Design tokens

Extrait des tokens de ce composant — les variables --origam-<composant>---<propriété>, déclarées dans sa feuille de tokens tenue à la main, sans étape de build.

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.

Interactif

Playground

Modifiez les props en direct et observez le composant se mettre à jour. Le snippet de code généré suit vos changements.

Rendu de l’aperçu en cours…

Usage

Exemples

Extraits de code prêts à coller dans vos templates.

Single keys

vue

Keyboard shortcuts (combinations)

vue

Variants

vue