Description
Blueprint has KeyComboTag for rendering hotkey combos, but no standalone component for displaying a styled <kbd> element. KeyComboTag is tightly coupled to the hotkey system; it parses combo strings through normalizeKeyCombo, maps platform-specific icons, etc. If you just want to show a keyboard key in a tooltip or some inline text, there's no good way to do that today.
We already have the CSS for this (.bp6-key, .bp6-key-combo) and KeyComboTag renders <kbd> elements internally, but that styling isn't usable on its own.
Prior art
All three are thin wrappers around the HTML <kbd> element with consistent styling.
Possible API
// Single key
<Kbd>⌘</Kbd>
// Combination (could reuse existing .bp6-key-combo styles)
<KbdCombo>
<Kbd>Ctrl</Kbd>
<Kbd>Shift</Kbd>
<Kbd>K</Kbd>
</KbdCombo>
// Or as a simple string-based API similar to KeyComboTag
<KbdCombo keys={["Ctrl", "Shift", "K"]} />
Context
Came up during review of #7237. KeyComboTag internally renders <kbd> elements but isn't designed for general use outside the hotkeys system.
Description
Blueprint has
KeyComboTagfor rendering hotkey combos, but no standalone component for displaying a styled<kbd>element.KeyComboTagis tightly coupled to the hotkey system; it parses combo strings throughnormalizeKeyCombo, maps platform-specific icons, etc. If you just want to show a keyboard key in a tooltip or some inline text, there's no good way to do that today.We already have the CSS for this (
.bp6-key,.bp6-key-combo) andKeyComboTagrenders<kbd>elements internally, but that styling isn't usable on its own.Prior art
Kbdfor single keys,KbdGroupfor combinationsKbdwith size prop (xs through xl)<kbd>wrapper with theme integrationAll three are thin wrappers around the HTML
<kbd>element with consistent styling.Possible API
Context
Came up during review of #7237.
KeyComboTaginternally renders<kbd>elements but isn't designed for general use outside the hotkeys system.