Kbd
Shows a keyboard key or shortcut.
When to use
- Show a keyboard shortcut in text, a tooltip or a menu.
- Show the keys of a combination, grouped with
KbdGroup.
When not to use
- A status or a tag: use Badge.
- Code or a value to copy: use inline
code.
Install
npx shadcn@latest add @clinia/kbdCommandKorCtrlK
Press Esc to close the panel.
Clinia rules
- Name keys the way the keyboard prints them:
⌘,Ctrl,Esc,Enter. Show both the Mac and the Windows keys when they differ. - Kbd is
text-xsonbg-muted, and switches to a translucentbackgroundsurface inside a Tooltip.
Do and don't
Press CtrlK to search records.
Patient intake Draft
Accessibility
Built in
KbdGroupwraps the keys in an outerkbd, the HTML pattern for a key combination.
Your responsibility
- Screen readers read symbols like
⌘inconsistently. Addsr-onlytext such asCommand, or write the key name. - Kbd only describes a shortcut. Build the shortcut itself, and don't take over keys that screen readers or browsers use.
How to test
- With a screen reader, the shortcut is read as keys you could press.
- Press the shortcut: it does what the text says.
API
Every prop comes from the native kbd element.
Related