Skip to content
shadcn.io

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.

Framework
UI library

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

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

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.

How do I document arrow keys for a game?

Use the inverted T layout and label what each direction does, like Jump for up. Show WASD as an alternative if the game accepts it.

What are arrow keys used for in interfaces?

Moving between items in menus, lists, tabs, radio groups and toolbars, moving a slider, scrolling, and moving between slides or images. The components already handle them where the pattern calls for it.