Skip to content

[core][FR] Kbd component #7973

@ggdouglas

Description

@ggdouglas

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions