Kbd
A key or a shortcut, shown the way it appears on the keyboard.
- Create issue
- C
- Search
- ⌘K
- Toggle sidebar
- ⌘B
- Send comment
- ⌘↵
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:
1pnpm dlx shadcn@latest add https://jzbui.com/r/kbd.jsonA complete example. Change the values to fit your product:
123456789import { Kbd, KbdGroup } from "@/components/ui/kbd"
<KbdGroup> <Kbd>⌘</Kbd> <Kbd>K</Kbd></KbdGroup>
// Plain keys for dense menus and lists<Kbd variant="plain">⌘K</Kbd>The full source is yours to edit once installed: