Components/Data Display
Keyboard keys and shortcuts that glow when pressed.
Hold ⌘ and press K. The keys light up as you type.
Installation#
npx shadcn@latest add https://get-neonkit.vercel.app/r/kbd.jsonUsage#
import { Kbd, KbdCombo } from "@/components/ui/kbd"
<KbdCombo keys={["⌘", "K"]} listen />
<Kbd listen="Shift">Shift</Kbd>Examples#
Shortcut sheet
separator accepts any node, or null for keys side by side.
| Action | Shortcut |
|---|---|
| Open command menu | CommandK |
| Toggle sidebar | CommandB |
| Copy component source | CommandShiftC |
| Next example | J |
| Previous example | K |
| Go to settings | GthenS |
| Close dialog | Esc |
Listening keys
listen takes a KeyboardEvent.key value and matches it case-insensitively.
Press Shift, any modifier or the space bar.
Sizes and pressed state
pressed forces the lit state, for tutorials and game controls.
API reference#
Kbd
Renders a kbd element and accepts every native attribute.
| Prop | Type | Default |
|---|---|---|
size | "sm" | "md" | "lg"20, 24 or 32px tall. | "md" |
pressed | booleanForces the lit, pushed-down state. | false |
listen | stringKeyboardEvent.key to watch, like "k", "Shift", "Meta" or "Enter". Lights up while held. | — |
color | NeonColorPalette name or hex. Falls back to --neon-accent, then cyan. | inherited |
KbdCombo
A kbd that wraps one Kbd per key, as HTML recommends for key combinations.
| Prop | Type | Default |
|---|---|---|
keys | string[]Key labels in order. ⌘ ⌥ ⇧ ⌃ ↵ and arrows get spoken names. | — |
listen | booleanEach key listens for itself. ⌘ maps to Meta, ⌥ to Alt, ⇧ to Shift, ⌃ to Control, ↵ to Enter, Esc to Escape. | false |
separator | ReactNodeRendered between keys. Pass null for none. | "+" |
size | "sm" | "md" | "lg"Size of every key. | "md" |
color | NeonColorColor of every key. | inherited |
Accessibility#
- Kbd is display only. listen never prevents default or triggers anything, so wire the real shortcut yourself.
- Symbol keys in KbdCombo carry a screen reader label, so ⌘ is read as "Command".
- Held keys clear when the window loses focus, and releasing ⌘ clears the rest because macOS drops their keyup events.