Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Kbd examples · Arrow Keys

Arrow Keys Horizontal Kbd for React

Left and right arrow keys grouped side by side.

Framework
UI library

Many controls only move one way: carousels, slides, image galleries, pagination. This React example shows ← and → in a KbdGroup, which spaces the two caps evenly and keeps them together as one hint, without the up and down keys that don't apply.

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

When should I show only the left and right arrows?

When the control only moves sideways: a carousel, a slideshow, a timeline, previous and next pages. Showing up and down there suggests keys that do nothing.

What does KbdGroup do for the arrows?

It lays the two Kbd caps out in a row with a small gap and keeps them on one line. Unlike a chord such as ⌘K, the arrows here are alternatives, so make that clear in the text around them, for example Use ← → to move.

Should left come before right?

Yes, as on the keyboard, with left first. In right-to-left interfaces a carousel usually moves the other way, so check which key goes forward and label the hint to match.

Should pagination use arrows or page labels?

Both: keep visible Previous and Next buttons with clear labels, and show the arrow hint for people who prefer the keyboard. Arrows alone don't say where they lead.

Are the arrow hints accessible?

The characters ← and → aren't always read as key names, so add visually hidden text like Left arrow and Right arrow inside the caps when the hint matters.