Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Kbd examples · Arrow Keys

Arrow Keys Cross Pattern Kbd for React

Four arrow keys in the inverted T of a keyboard, laid out on a three-column grid.

Framework
UI library

Arrow keys are easiest to recognize in the shape they have on a keyboard. This React example places ↑ above ←, ↓ and → on a three-column grid, with an empty cell on either side of the up arrow, so the four Kbd caps form the familiar inverted T. Use it for game controls, map and canvas navigation, and keyboard help panels.

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 the inverted T?

Most keyboards have placed the arrow keys this way since the 1980s, so people recognize the shape before reading the arrows. It also shows that up and down share a column.

Should arrow keys show symbols or words?

Symbols: ↑ ↓ ← → are shorter than Up or Left and read in any language. Add the key's name as visually hidden text if screen readers need it, since the arrow characters aren't always read as key names.

How much space should be between the arrow keys?

A small gap, gap-1 here, keeps the four keys reading as one cluster while separating the caps. Larger gaps break the T apart.

How does the grid make the inverted T?

grid grid-cols-3 makes three columns, and the six children fill them in order: an empty div, ↑, an empty div on the first row, then ←, ↓, → on the second. w-fit keeps the grid as narrow as the keys.

When should I show arrow keys instead of WASD?

Arrow keys for navigating interfaces, lists, maps and slides; WASD for games where the other hand is on the mouse. Many games accept both, and the WASD Gaming Keys example uses the same layout.

Do screen readers understand the arrow keys?

They read the characters, which some screen readers say as arrow names and others skip. The empty cells are silent. For a help panel, add visually hidden names like Up arrow inside each Kbd.