shadcn.io is not affiliated with official shadcn/ui
Kbd examples · With Icons
Arrow Keys with Icons Kbd for React
Up, down, left and right arrow keys drawn with arrow icons.
Arrow characters depend on the font; icons look the same everywhere. This React example draws the four arrow keys with Lucide's arrow icons inside Kbd caps in a KbdGroup, each icon hidden from screen readers and followed by a visually hidden name, such as Up arrow. The Kbd sizes icons to match its text.
Preview
Installation
FAQ
Why icons instead of text labels?
An arrow says which way faster than the words Up or Left and needs no translation. Icons also keep a consistent stroke and size, where arrow characters vary from font to font.
How are the icon-only keys made accessible?
Each icon has aria-hidden so screen readers skip it, and a visually hidden span with the key's name, like Left arrow, gives them the text instead. Sighted users see only the icon.
Should the arrows be in a row or a keyboard layout?
A row, as here, fits inline hints like Use the arrows to move. For a controls panel, the inverted T of the Arrow Keys Cross Pattern example reads more like the keyboard.
Should I show HJKL next to the arrows?
If your app supports them, yes, in a separate group so people don't think they're pressed together. The Vim Navigation Keys example shows them.
Related
- Arrow Keys Cross Pattern KbdFour arrow keys in the inverted T of a
- Enter with Icon KbdAn Enter key with a return arrow icon
- Unicode Symbols KbdEnter, Delete and Tab keys with a Unicode
- Editing Keys KbdThe Home, End, PgUp and PgDn editing keys
- Standard CarouselA basic carousel of five numbered slides
- Command with Icon KbdA Command K shortcut with the Command key