Kbd
Keyboard keys drawn for the platform, with sequences and keys that light up as you press them.
Press CtrlEnter to send the invoice
Try it: the keys light up as you press them.
Installation
npx shadcn@latest add @quireui/kbdUsage
<Kbd shortcut="mod+k" /> {/* ⌘ K on a Mac, Ctrl K elsewhere */}
<Kbd shortcut="g i" /> {/* G then I */}
<Kbd>Esc</Kbd>Shortcuts use the same format as Button's shortcut and the command palette: mod is Cmd on Apple devices and Ctrl everywhere else, joined with +. Each key gets its own cap, in the order people press them. A space makes a sequence, read as "then".
Live
live lights each key while it is held. In a sequence, finished steps stay lit until the last one lands, or until a second passes without the next key. Use it where someone is learning a shortcut: onboarding, an empty state, a shortcuts list.
- New invoiceC
- Go to invoicesGthenI
- Go to customersGthenC
- SendCtrlEnter
- ArchiveShiftE
- Show all shortcutsShift/
The keys sink instantly, with no animation, like everything that answers the keyboard.
Sizing
Keys are sized in em, so they follow the text around them: a sentence, a menu, a tooltip.
Press Esc to close the dialog, or CtrlS to save a draft first.
In a larger paragraph the keys grow with the text: CtrlShiftP.
And shrink in small print, like this GthenI.
Accessibility
Keys are nested kbd elements, the HTML way to write a key combination, and are read by name; symbols like ⌘ are read as "command". A sequence is read as "G then I".
Kbd shows keys; it does not bind them. To make a shortcut work, use Button's shortcut prop or the useShortcut hook, with the same string, so what is shown and what works can never disagree.
Kbd or something else?
- A shortcut on a button: Button's
shortcutprop shows the keys quietly inside the button. - A shortcut in a menu:
DropdownMenuShortcut, plain text at the end of the item.
API reference
Kbd
Keyboard keys. Shortcuts are drawn for the platform: "mod+k" is ⌘ K on a Mac and Ctrl K elsewhere. Sequences read "G then I".
Prop
Type
Also takes every <kbd> attribute. Style it with [data-slot="kbd"].