Kbd
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.
<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
Toutes les props acceptées par ce composant, avec leur type, valeur par défaut et 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
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.
- 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.
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
Keyboard shortcuts (combinations)
Variants