Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Arrow Keys Cross Pattern Kbd for React

Four arrow caps in an inverted T on a three-column grid, matching the arrow cluster on a keyboard.

Up sits in the middle of the first row. Left, down, and right fill the second row. Empty cells flank the up arrow. The symbols are text, and they do not move anything.

Use the cross for map, canvas, or game help. For left and right only, a flat pair is clearer. A Button should do the same move on click. In React, Base UI does not handle the arrow keys.

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.

Anatomy

Kbd anatomy: kbd, group

Usage

<div className="rounded-md border bg-background p-4">
  <div className="grid w-fit grid-cols-3 gap-1">
    <div />
    <Kbd>↑</Kbd>
    <div />
    <Kbd>←</Kbd>
    <Kbd>↓</Kbd>
    <Kbd>→</Kbd>
  </div>
</div>

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.

API Reference

Kbd

No extra props in this demo. The rest is on the Kbd page.