0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
The kbd element represents user keyboard input, displaying keys and key combinations in a distinctive style that resembles physical keyboard keys.
Description
The <kbd> element represents keyboard input from the user. VB styles it with a raised appearance resembling physical keyboard keys — monospace font, border, and a subtle box-shadow. It is part of VB's code-family styling alongside <code>, <samp>, and <var>.
When to Use
Keyboard shortcuts: Document hotkeys and shortcut combinations
Form instructions: Explain keyboard navigation
Application tutorials: Guide users through keyboard interactions
<p>In Vim: <kbd><kbd>:</kbd><kbd>w</kbd><kbd>q</kbd></kbd> to save and quit.</p><p>Save: <kbd><kbd>Ctrl</kbd>+<kbd>S</kbd></kbd></p>
Nested kbd
The HTML spec uses nesting to mean one input made of several keys: the outer <kbd> is the whole sequence or combination, each inner <kbd> is one key. VB draws the cap on the inner elements only. A <kbd> that has a <kbd> child loses its own border, background, shadow and padding and keeps the surrounding text size, so the inner caps are the same size as a standalone cap.
Separate <kbd> elements with a + between them (<kbd>Ctrl</kbd> + <kbd>S</kbd>) read the same and need no wrapper. Use the nested form when the combination needs to be one element, for example to style or select it as a unit.
Platform-aware shortcuts
Add data-hotkey to have VB render the right keys for the reader's platform: ⌘K on a Mac, Ctrl+K elsewhere. The text you write is the fallback before JavaScript runs. VB replaces it with nested caps and a visually hidden spoken form ("Command K").
Named keys get short labels (escape → Esc, arrowup → ↑, pageup → PgUp). Write the plus key as plus or ctrl++. To localise key names, set data-label-ctrl="Strg" (or any data-label-key) on the element or on <html>. The attribute page has the full mapping.
Key caps inside buttons
A button sets its own text colour, which can be white on a primary fill. Inside button, .button and [role="button"], a cap therefore keeps the button's text colour. Its edge and a translucent fill are derived from that colour, so the cap is always at least as legible as the button label.
kbd {font-family: var(--font-mono);font-size: 0.85em;background: var(--color-surface-raised);padding: var(--size-2xs) var(--size-xs);border-radius: var(--radius-s);border: var(--border-width-thin) solid var(--color-border);box-shadow: 01px0var(--color-border);}/* Nested: only the inner kbd is a cap */kbd:has(> kbd) {font-size: inherit;background: none;border: none;box-shadow: none;padding: 0;}/* Inside buttons: cap follows the button's text colour */:is(button, .button, [role="button"]) kbd {color: inherit;border-color: color-mix(in oklab, currentColor 45%, transparent);/* + a translucent fill at the text's opposite lightness */}
The border and box-shadow create a 3D key-cap appearance. Browser translation will translate key names unless you add the HTML translate="no"attribute: <kbd translate="no">Ctrl</kbd>.
Accessibility
Screen readers announce <kbd> as plain text — the key-cap styling is not conveyed, so the surrounding words must say it is a key
Use the plus symbol (+) between keys in combinations for clarity
Mac glyphs (⌘ ⌥ ⇧ ⌃) are read inconsistently by screen readers. Spell the names out in hand-written text, or use data-hotkey, which adds a visually hidden spoken form
Do not put aria-label on <kbd>: it has a generic role, so the label is prohibited and usually ignored
Provide context: "Press X to do Y"
Document shortcuts in a discoverable location
Always provide alternative methods for keyboard-shortcut-only actions
Components Using kbd
VB web components that display keyboard shortcuts use <kbd> styling: