Content

Kbd
v1.1.2
Ready for Production

Display keyboard shortcuts and key combinations with semantic styling. Built on the native HTML kbd element with CVA variants for size, danger state, and decorative vs. text rendering.

Prefer AI-assisted development?

This documentation is available via the Catalyst MCP Server. Learn how to connect →

Catalyst Kbd wraps the native <kbd> HTML element with built-in design tokens and CVA size/variant options — giving you a production-ready keyboard shortcut component with dark mode and danger state support out of the box.

Preview
⌘+K

Installation

npm install @pmi/catalyst-kbd
import { Kbd } from '@pmi/catalyst-kbd';

Variants

Decorative (default)

Renders with a border and background to visually stand out as a key badge.

Preview
⌘+K

Text

A minimal variant without borders or background — useful inside menus or inline prose.

Preview
⌘+K

Sizes

Three sizes are available: sm, md (default), and lg.

Preview
⌘+K⌘+K⌘+K

Common Patterns

Danger

Use the danger prop to signal a destructive keyboard action (e.g., Delete, Backspace).

Preview
⌘+K

Danger on Hover

Dynamically apply danger colors based on a parent's highlighted state using Tailwind group utilities.

Preview
⌘+K⌘+K

API Reference

Kbd

A styled <kbd> element. Forwards ref to the underlying HTMLElement. Accepts all standard HTML keyboard element attributes.

Prop

Type

Accessibility

The <kbd> element is semantic HTML — screen readers announce it as keyboard input automatically.

ARIA

  • No explicit ARIA roles are needed. The native <kbd> element conveys keyboard input semantics to assistive technology.
  • Ensure color contrast meets WCAG 2.2 AA (4.5:1) when using custom className overrides — the default tokens already comply.
  • When danger is used purely as a color signal, pair it with a text label or tooltip so color-blind users can still identify the destructive intent.

Choosing the Right Component

Use Kbd when you need to display a keyboard shortcut or key combination. Reach for a different primitive when:

If you need…Use instead
A label for status, category, or countBadge
A searchable command palette that lists keyboard shortcutsCommand
A non-interactive text snippet styled as codeStandard <code> element

On this page