Kbd
Key caps and shortcuts, parsed once for display, tooltips and aria-keyshortcuts.
import { Kbd, KbdGroup, KeyLegend, … } from "@arcadia/ui"keys takes display keys (["⌘", "N"], each split at its modifiers), a glyph string ("⌘⇧K") or a spec ("mod+shift+k", which renders ⌘ on macOS and Ctrl elsewhere). key is the boxed cap; plain is the unboxed quiet hint used in pills, fields and menus.
Kbd is visual only. Inside a control, mark it aria-hidden and put the shortcut on the control with aria-keyshortcuts, using ariaKeyShortcuts(keys), so the name stays the label. Button hint, MenuItem shortcut and IconButton shortcut do both for you.
Examples
Caps
Boxed caps for a shortcut on its own; plain for a hint inside something else. Multi-character keys widen with padding.
Legend
The keys a surface listens to, as one quiet footer line: caps, then a verb. Pickers, palettes and popovers all teach keys with KeyLegend, so a key reads the same everywhere.
Parsing
One parser feeds key caps, tooltips and aria-keyshortcuts: the spec, its display keys and its ARIA value.
"⌘⇧K"⌘⇧KMeta+Shift+K"mod+shift+k"⌘⇧KMeta+Shift+K"⇧Tab"⇧TabShift+Tab"^Tab"⌃TabControl+Tab"esc"EscEscapeA stray caret is read as Control and named keys take one spelling, so ^Tab and esc still draw right.
Kbd renders <kbd> and KbdGroup a row of them; both are text, never focusable, and have no keys of their own. Glyphs like ⌘ and ⇧ are read inconsistently by screen readers, which is why a shortcut belongs on its control as aria-keyshortcuts ("⌘⇧K" becomes Meta+Shift+K) while the caps stay aria-hidden.
Showing a shortcut doesn't bind it: the key handler is yours. Prefer mod in specs so the same shortcut shows ⌘ on macOS and Ctrl elsewhere, and avoid keys a screen reader or the browser already uses.
Kbd
size- "sm" | "md"Default"md"
md18px caps,sm16px caps (tooltips, dense rows).variant- "key" | "plain"Default"key"
key: a boxed key cap.plain: the unboxed quiet hint used in pills and menus.
Rest props go to <kbd> props and render.
keysrequired- string | readonly string[]
["⌘","N"],"⌘N", or a spec like"mod+shift+k"(seeshortcutKeys).size- "sm" | "md"Default"md"
variant- "key" | "plain"Default"key"
key: a boxed key cap.plain: the unboxed quiet hint used in pills and menus.className- string
- The part name a parent gives the group it renders (
ui-menu-item-shortcut), for its own rules.
Rest props go to <span> props and render.
hintsrequired- readonly KeyHint[]
Rest props go to <div> props and render.