Kbd

A key or a shortcut, shown the way it appears on the keyboard.

⌘KShift↵Esc⌘K
Create issue
C
Search
⌘K
Toggle sidebar
⌘B
Send comment
⌘↵
Fig. 1 Shortcuts shown as keys, alone and in combinations.

When to use it

Use Kbd to show keyboard shortcuts in menus, tooltips, and help text. Group combinations with KbdGroup so they read as one shortcut.

Write the keys for the platform people are on: ⌘ on a Mac, Ctrl elsewhere.

How it behaves

Kbd renders a native kbd element. Wrap a combination in KbdGroup, one Kbd per key, so screen readers and copy keep the keys together.

The default variant draws a small keycap on the control fill. variant="plain" shows the key as muted text for menus, settings rows, and lists with many shortcuts.

Inside TooltipContent, both variants switch to the tooltip's inverted colors automatically.

Use the platform's symbols where they are familiar (⌘, ⇧, ↵), and offer Ctrl equivalents in your own copy when shortcuts differ by platform.

Build it

Add it with the shadcn CLI:

Terminal

A complete example. Change the values to fit your product:

kbd-example.tsx

The full source is yours to edit once installed:

kbd.tsx