⌘
⌫
P
The Kbd component renders keyboard keys and shortcuts with realistic styling, perfect for documentation, tutorials, and UI instructions that need to show keyboard interactions
Installation
1npx shadcn@latest add "https://ace-ui-six.vercel.app/r/kbd.json"
Usage
1import { Kbd } from "@/components/ui/kbd";23export default function Example() {4return (5 <div className="flex items-center gap-3">6 <Kbd size="md" keys={["command", "delete", "p"]} />7 </div>8);9}
Variants
1// Outline variant2<Kbd keys={["shift", "enter"]} variant="outline" />34// Ghost variant5<Kbd keys={["escape"]} variant="ghost" />67// Different sizes8<Kbd keys={["tab"]} size="sm" />9<Kbd keys={["space"]} size="md" />10<Kbd keys={["command", "k"]} size="lg" />1112// Single keys13<Kbd keys={["enter"]} />14<Kbd keys={["delete"]} />15<Kbd keys={["escape"]} />1617// Multiple key combinations18<Kbd keys={["command", "shift", "p"]} />19<Kbd keys={["ctrl", "alt", "delete"]} />2021// Arrow keys22<Kbd keys={["up"]} />23<Kbd keys={["down", "right"]} />2425// Custom text keys26<Kbd keys={["F1"]} />27<Kbd keys={["a", "b", "c"]} />
Features
- Realistic keyboard key styling with gradients and shadows
- Support for special keys with proper Unicode symbols
- Multiple sizes:
sm,md,lg - Three variants:
default,outline,ghost - Supports key combinations and sequences
- TypeScript support with predefined key types
Props
| Prop | Type | Default | Description |
|---|---|---|---|
keys | KbdKey[] | ["command", "delete", "p"] | Array of keyboard keys to display |
variant | 'default' | 'outline' | 'ghost' | 'default' | Visual style variant of the kbd component |
size | 'sm' | 'md' | 'lg' | 'md' | Size of the keyboard keys |
className | string | — | Additional CSS classes |
Available Keys
The component supports the following predefined keys with special symbols:
1// Special modifier keys2"command" → ⌘3"shift" → ⇧4"ctrl" → ⌃5"option" → ⌥6"alt" → ⎇7"fn" → fn8"win" → ⊞910// Action keys11"enter" → ⏎12"delete" → ⌫13"escape" → ⎋14"tab" → ⇥15"capslock" → ⇪16"space" → ␣1718// Arrow keys19"up" → ↑20"down" → ↓21"left" → ←22"right" → →2324// Navigation keys25"pageup" → ⇞26"pagedown" → ⇟27"home" → ⇱28"end" → ⇲29"help" → ?