Skip to main content
Copy for LLM

Kbd

Kbd stands for the HTML <kbd> element — short for "keyboard input" — and is the standard semantic tag for representing user keystrokes (W3C HTML spec). The <x-wirekit::kbd> component wraps that element into a small, raised "keycap" — a <kbd> tag with a monospace font, a subtle border, a tinted background, and a rounded corner. Use it whenever you describe a keyboard input the user is meant to press.

Two common patterns:

  • Inline shortcut hints — sprinkle a single <x-wirekit::kbd> into running text to label a key (e.g. press <x-wirekit::kbd size="sm">Esc</x-wirekit::kbd> to close). The component sits inline in the text, and size="sm" fits a line of body text.
  • Key combinations — wrap multiple <x-wirekit::kbd> in a <x-wirekit::row gap="xs"> to render shortcut sequences like <x-wirekit::kbd size="sm">⌘</x-wirekit::kbd> <x-wirekit::kbd size="sm">K</x-wirekit::kbd>. Each key gets its own <kbd> element, so each one keeps its own keycap.

The component renders the HTML <kbd> element, which carries no role of its own: a screen reader reads its text as it reads the text around it, and the keycap is for the eye. For platform-specific glyphs (⌘ Cmd on macOS, Ctrl on Windows / Linux, ⇧ Shift, ⌥ Opt, ⌃ Ctrl-on-Mac, ↵ Enter), prefer the symbol on macOS / iOS surfaces and the spelled-out label everywhere else — or detect the platform and swap server-side.

Live Sandbox

This is a hydrated playground for the component. Toggle "Live preview" on the block below to swap the static HTML render for a real Livewire instance — every prop in the component's sandbox schema becomes an editable form field inside the iframe, so you can try different prop combinations live without writing any local code.

Sandbox
Cmd

Basic Usage

Single key
K

Key Combinations

Keyboard shortcut
⌘ K

A Shortcut for the Reader's Platform

shortcut draws the keys of a shortcut written the way x-wk-shortcut takes it, as the overview of keyboard shortcuts draws them: ⌘ S on a Mac and Ctrl S elsewhere, the words among the keys in the reader's language (Strg on a German keyboard), and a sequence with "then" between its steps. With a shortcut it can read the slot is not used. One it cannot read, such as cmd+shfit+s, is reported through strict validation, and the slot is drawn in its place.

Shortcuts drawn for the reader's platform
⌘ S Ctrl S ⌥ ⇧ N Alt Shift N G then D

The server draws the keys of both kinds of platform and guesses the reader's from the request, and WireKit's script then shows the one the browser reports. A single-key shortcut such as g d is drawn only while single keys work: the reader's switch in the overview and a screen with data-wk-single-keys="off" hide it, as they turn the shortcut off. A page that a wire:navigate hop opens hides it from its first paint as well. A tooltip draws the shortcut of its control this way.

Sizes

Kbd sizes
Esc Enter Space

In Context

Shortcut hint in text

Press ⌘ K to open the command palette.

Props

Prop Type Default Description
size string 'md' Size: sm, md, lg
shortcut string|null null A shortcut such as cmd+s, shift+? or g d, drawn as its keys for the reader's platform. See A Shortcut for the Reader's Platform
scope string|null null Scoped personalization name

Accessibility

  • <kbd> has no role of its own, so a screen reader reads the key's text in the sentence around it. A symbol such as ⌘ is read by its name where the screen reader knows one; where it might not, spell the key out.
  • With shortcut the words among the keys, such as "then" in a sequence, are written in the reader's language, so a sequence reads as one.

Keyboard Interaction

This component is purely presentational and does not respond to keyboard input.

Pitfalls

  • Think twice before putting <x-wirekit::kbd> inside a <button>. Not for the font — the element sets --font-wk-mono on itself and keeps it wherever it lands. The reason is semantic: <kbd> marks up input the READER is being asked to type, and a button already says "activate me". Nesting the two makes the shortcut look like a second control. Render the hint beside the button rather than inside it.

Design Tokens

Token Used for
--font-wk-mono Monospace font family
--color-wk-border Key border
--color-wk-bg-muted Key background
--color-wk-text Key text color
--radius-wk-sm Border radius
--border-wk-width Border width

Updated in WireKit v2.74.0 (2026-11-24)

Was this page helpful?

Thank you for your feedback!

Voting requires cookies or local storage. What we store