Kbd
Display one keyboard key as shortcut notation.
Anatomy#
Usage#
Use Kbd to display one key in a shortcut hint. Combine keys with KbdGroup. Showing a shortcut does not register a keyboard handler.
Key aliases#
Known aliases such as meta, command, shift, escape, and arrowup resolve to a symbol or
short label (⌘, ⇧, Esc, ↑), matched case-insensitively. Any other value renders as written.
Pass symbol={false} to render the value as written instead. An alias also gets a spoken name from
the locale messages; translations overrides it per instance. Set aria-label when assistive
technology needs a different name than the visible keycap. It takes precedence over the alias name.
Root styling#
Kbd renders one <kbd> root, so use class and style for an individual keycap. Configure
kbd.base.root in your Theme to share keycap presentation. variant (default, outline,
invert) and size (sm, md, lg) select the built-in treatments. root is the only slot, so
classes and styles only duplicate class and style.
Examples#
Hint search and cancel shortcuts#
Place keycaps in instructional copy. Registration of those shortcuts stays in application code.
Show how to close a dialog#
Use a single Kbd when the hint is one key rather than a chord.
API Reference#
Props#
Props for the Kbd component. Renders a <kbd> element by default.