cv-shortcut
Command-hint primitive for keyboard shortcut labels.
Shortcut resolution, platform-specific labels, and command matching remain owned by consumers. cv-shortcut only renders a label or key list.
Usage
Use cv-shortcut as secondary command metadata in menus, command rows, toolbars, and dense panels. Do not use it as a button or as a keyboard listener. Resolve platform-specific shortcuts in the owning model or application code, then pass the rendered keys into the component.
Rendering inputs
Use label for static markup with the default + separator. Use keys for explicit key lists, either as a comma-separated attribute or as a JavaScript property; a non-empty keys value is rendered instead of parsing label.
<cv-shortcut label="Ctrl + K"></cv-shortcut>
<cv-shortcut keys="Shift,Enter" separator="/"></cv-shortcut>
<cv-shortcut id="programmatic-shortcut"></cv-shortcut>
<script type="module">
document.querySelector('#programmatic-shortcut').keys = ['Meta', 'Shift', 'P']
</script>Usage guidance
- Pair shortcuts with visible command labels; never rely on keycaps alone.
- Keep platform detection and command matching outside
cv-shortcut. - Use
aria-labelwhen rendered key text is abbreviated or symbolic.
Anatomy
<cv-shortcut> (host)
└── <span part="base" aria-label="...">
├── <cv-kbd part="key">
├── <span part="separator">
└── <cv-kbd part="key">When label and keys are empty, the default slot is rendered instead.
Attributes And Properties
| Name | Type | Default | Description |
|---|---|---|---|
label | String | "" | Preformatted shortcut label such as Ctrl + K |
keys | String or readonly string[] | [] | Comma-separated attribute or property key list rendered as cv-kbd |
separator | String | "+" | Separator used to split label and render between keys |
aria-label | String | "" | Accessible label override |
Slots
| Slot | Description |
|---|---|
(default) | Fallback custom rendering when no keys exist |
CSS Parts
| Part | Description |
|---|---|
base | Root wrapper |
key | Inner cv-kbd keycap |
separator | Separator between keycaps |
CSS Custom Properties
| Property | Default | Description |
|---|---|---|
--cv-shortcut-gap | var(--cv-space-1, 4px) | Gap between keys/separators |
--cv-shortcut-separator-color | var(--cv-color-text-muted, #9aa6bd) | Separator text color |
--cv-shortcut-separator-font-size | 0.8em | Separator font size |
--cv-kbd-* | inherited by inner cv-kbd keycaps where defined | Keycap sizing, color, border |
Events
None.