Skip to content

Kbd

Keyboard key + shortcut renderer. Platform-aware `mod` glyph, built-in modifier/arrow/enter aliases, outlined + soft variants.

Data Display@sisyphos-ui/kbdView on npmView as Markdown

Preview

tsx
Esc

Installation

Install the individual package:

$ pnpm add @sisyphos-ui/kbd @sisyphos-ui/core

Or use the umbrella package that bundles everything:

$ pnpm add @sisyphos-ui/ui

Usage

Import the component styles and the component itself:

snippet.tsxtsx
import "@sisyphos-ui/kbd/styles.css";
import { Kbd } from "@sisyphos-ui/kbd";

Shortcut string

Parsed on `+` and whitespace. Modifier aliases (`cmd`, `ctrl`, `shift`, …) map to glyphs; `mod` resolves to ⌘ on macOS and ⌃ elsewhere.

tsx
KPS

Visible separator

`separator` accepts any `ReactNode` — a plus, a dot, a custom divider — rendered between each key.

tsx
KP

Variants

`outlined` (default) has a border and light shadow; `soft` sits on a muted fill.

tsx
KK

Sizes

Scales via font-size; chip padding follows in `em`.

tsx
KKKKK

In prose

Drop `<Kbd>` into a paragraph — `vertical-align: middle` keeps it on the text baseline.

tsx

Press K to open the command menu, or Esc to dismiss it.

API

PropTypeDefaultDescription
variant"outlined" | "soft""outlined"Chip style.
size"xs" | "sm" | "md" | "lg" | "xl""sm"Size scale.
childrenReactNodeFree-form content; rendered inside a single `<kbd>`.
keysstring[]Explicit list of keys. Aliases normalized to glyphs.
shortcutstringShortcut string split on `+` and whitespace (e.g. `"cmd+k"`).
separatorReactNodeRendered between keys. Omit to join them visually.

The full API including refs, ARIA attributes, and HTML passthroughs lives in the package README.

Was this page helpful?