Kbd

Display keyboard shortcuts and key combinations with proper styling

Primitive

Kbd renders a keyboard key or shortcut with key-cap styling. Use it in docs, tooltips, command menus, and shortcut lists to show combinations like ⌘ K or Ctrl + S. Pass keys to render a combination, and it converts named keys to platform symbols automatically.

Preview

⌘KEscTab↵

Installation

Usage

Examples

Size Variants

Use size to set the key's height and text size.

⌘⌘⌘
SizeDescription
smCompact key for dense UI.
mdThe default key size.
lgLarger key for emphasis.

Color Variants

Use variant to set the key's color scheme.

⌘⌘⌘⌘⌘⌘
VariantDescription
defaultCard-colored key with a subtle border.
primarySolid primary-colored key.
secondarySolid secondary-colored key.
outlineBorderless, transparent key.
ghostMuted key with no border or shadow.
dangerDestructive-colored key.

Manual Key Combinations

Compose multiple Kbd elements to build a combination by hand.

⌘+K
Ctrl+Shift+P
Alt+Tab

Key Combinations with Props

Use keys to render a combination from an array, joined by separator.

⌘+k⌃+⇧+p⌥+⇥⌘ + k

Special Keys with Auto Conversion

Named keys like cmd and shift convert to symbols automatically.

⎵↵⌫⌫↑↓←→HomeEndPgUpPgDn

Platform Detection

Use platform to force mac or windows symbols, or leave it auto to detect the user's OS.

Auto:⌘+k
Mac:⌘+k
Windows:Ctrl+k

In Context

Place Kbd inline within prose to reference a shortcut.

Press ⌘ + K to open the command palette

Use ↑ ↓ to navigate and ↵ to select

Press Esc to close any dialog

Keyboard Shortcuts List

Pair labels with Kbd to document a set of shortcuts.

Open command palette⌘+k
Save document⌘+s
Copy selection⌘+c
Paste clipboard⌘+v

Live Keyboard Input Detection

Reflect the keys the user is pressing in real time.

Try typing on your keyboard to see the pressed state:

QWERTYUIOP
ASDFGHJKL
ZXCVBNM
SpaceShiftCtrl⌘

States

Use pressed and disabled to show active or unavailable keys.

Normal:⌘
Pressed:⌘
Disabled:⌘

API Reference

Kbd is a custom styled kbd element. All props are custom or standard kbd attributes passed through.

Props

Kbd

Keyboard key or shortcut with key-cap styling.