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.
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
Installation
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.
Related
- Arrow Keys Horizontal KbdLeft and right arrow keys grouped side by
- WASD Gaming Keys KbdThe W, A, S and D movement keys in an
- Vim Navigation Keys KbdThe H, J, K and L keys in one row, the
- Arrow Keys with Icons KbdUp, down, left and right arrow keys drawn
- Editing Keys KbdThe Home, End, PgUp and PgDn editing keys
- F1 Help Key KbdA single F1 key, the usual shortcut for