Kbd

Kbd renders a keyboard key label as a small embossed keycap, and KbdGroup lays several keycaps out in a row for multi-key shortcuts. Both are thin wrappers around native kbd and span elements with Tailwind styling.

Kbd
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

pnpm dlx shadcn@latest add @seamui/kbd

Requires @seamui in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { Kbd, KbdGroup } from "@/components/ui/kbd"<KbdGroup>  <Kbd>⌘</Kbd>  <Kbd>K</Kbd></KbdGroup>
  • Showing a keyboard shortcut next to a menu item, button, or tooltip, such as ⌘K or Ctrl+S.
  • Listing a multi-key combination by grouping several Kbd elements inside KbdGroup.
  • Displaying a single key name (Enter, Esc, Shift) inline within body text or help copy.
  • Adding a compact keycap icon or symbol label where a visual key cue is needed but a full badge would be too heavy.

Examples

Shortcut combination in a group

Two keys joined in a KbdGroup to show the Cmd+K command palette shortcut.

shortcut-combination-in-a-group.tsx
import { Kbd, KbdGroup } from "@/components/ui/kbd"export function CommandHint() {  return (    <KbdGroup>      <Kbd>⌘</Kbd>      <Kbd>K</Kbd>    </KbdGroup>  )}

Shortcut beside a menu item label

A Kbd placed at the end of a menu row to advertise the Save shortcut.

shortcut-beside-a-menu-item-label.tsx
import { Kbd, KbdGroup } from "@/components/ui/kbd"export function SaveMenuItem() {  return (    <div className="flex items-center justify-between gap-6">      <span>Save</span>      <KbdGroup>        <Kbd>Ctrl</Kbd>        <Kbd>S</Kbd>      </KbdGroup>    </div>  )}

Key name inside a sentence

A single Kbd used inline in help text to name the key to press.

key-name-inside-a-sentence.tsx
import { Kbd } from "@/components/ui/kbd"export function EscapeHint() {  return (    <p className="text-sm">      Press <Kbd>Esc</Kbd> to close the dialog.    </p>  )}

Keycap with an icon

An SVG icon inside Kbd is automatically sized to 12px by the built-in arrangement selector.

keycap-with-an-icon.tsx
import { ArrowUp } from "lucide-react"import { Kbd } from "@/components/ui/kbd"export function ShiftHint() {  return (    <Kbd>      <ArrowUp />      <span>Shift</span>    </Kbd>  )}

API reference

PropTypeDefaultDescription
classNamestring—Additional Tailwind classes merged onto the base keycap styles via cn(). Applies to Kbd.
childrenReact.ReactNode—Key label or icon content rendered inside the kbd element. Applies to Kbd.
...propsReact.ComponentProps<"kbd">—All other native kbd attributes (id, title, aria-label, onClick, etc.) are spread onto the element. Applies to Kbd.
classNamestring—Additional Tailwind classes merged onto the group container via cn(). Applies to KbdGroup.
childrenReact.ReactNode—Kbd elements or other content placed in the group. Applies to KbdGroup.
...propsReact.ComponentProps<"span">—All other native span attributes are spread onto the group wrapper. Applies to KbdGroup.

Accessibility

  • Kbd renders a semantic kbd element, which screen readers recognize as keyboard input text.
  • Because the component is pointer-events-none and select-none, it cannot be focused or selected; it is purely presentational and needs no keyboard handling.
  • Keycap labels such as ⌘ or ⇧ may be read awkwardly by some screen readers; add an aria-label on Kbd (for example aria-label="Command") when the symbol alone is ambiguous.
  • Do not rely on color alone to convey a shortcut; the text label inside the keycap carries the meaning.
  • When a shortcut is shown in a menu or tooltip, pair it with the action's accessible name so users know what the combination triggers.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Kbd" component (seamui/kbd) from its shadcn registry.1. Install it with: npx shadcn@latest add @seamui/kbd2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: className, children, ...props, className, children, ...props.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { Kbd, KbdGroup } from "@/components/ui/kbd"<KbdGroup>  <Kbd>⌘</Kbd>  <Kbd>K</Kbd></KbdGroup>```

Files & dependencies

  • registry/seam/ui/kbd.tsx→ components/ui/kbd.tsx
registryDependencieshttps://seamui.dev/r/utils.json

Looks similar, elsewhere