shadcn.io is not affiliated with official shadcn/ui
Kbd examples · With Icons
Enter with Icon Kbd for React
An Enter key with a return arrow icon before its label.
The Enter key's return arrow is as recognizable as its name. This React example puts Lucide's CornerDownLeft icon, hidden from screen readers, before the word Enter inside one Kbd cap. The Kbd lines up the icon and text with a small gap and sizes the icon to the text.
Preview
Installation
FAQ
Why add an icon when the word is clear?
The return arrow is printed on many keys, so people find it faster on the keyboard. It also makes the hint easy to spot at the bottom of a command palette or a chat input.
Do screen readers read the icon?
No, it has aria-hidden, so screen readers read only Enter. Hide decorative icons like this one, and add text whenever the icon is all there is.
How are icons sized inside a Kbd?
The Kbd sizes any icon without its own size class to 12 pixels and spaces it from the text with a small gap. Give the icon a size class, like size-4, to override it.
Should I use an icon or the ↵ character?
The ↵ character needs no import and takes the cap's font, as in the Unicode Symbols example. The icon has a consistent stroke that matches other icons in your interface.
Related
- Delete with Icon KbdA Del key with a delete icon before its
- Unicode Symbols KbdEnter, Delete and Tab keys with a Unicode
- Special Keys KbdThe Esc, Tab and Enter keys in a row
- Command Palette Shortcut KbdThe ⌘K shortcut that opens a command
- Arrow Keys with Icons KbdUp, down, left and right arrow keys drawn
- Command with Icon KbdA Command K shortcut with the Command key