Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Kbd examples · With Icons

Enter with Icon Kbd for React

An Enter key with a return arrow icon before its label.

Framework
UI library

The Enter key's return arrow is as recognizable as its name. This React example puts Lucide's CornerDownLeft icon, hidden from screen readers, before the word Enter inside one Kbd cap. The Kbd lines up the icon and text with a small gap and sizes the icon to the 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 add an icon when the word is clear?

The return arrow is printed on many keys, so people find it faster on the keyboard. It also makes the hint easy to spot at the bottom of a command palette or a chat input.

Do screen readers read the icon?

No, it has aria-hidden, so screen readers read only Enter. Hide decorative icons like this one, and add text whenever the icon is all there is.

How are icons sized inside a Kbd?

The Kbd sizes any icon without its own size class to 12 pixels and spaces it from the text with a small gap. Give the icon a size class, like size-4, to override it.

Should I use an icon or the ↵ character?

The ↵ character needs no import and takes the cap's font, as in the Unicode Symbols example. The icon has a consistent stroke that matches other icons in your interface.

Should the icon go before or after the word?

Before, as here, so the shape is seen first. Keep one order for every key with an icon in your app.

When should a form show the Enter hint?

When Enter does something people might not expect: sends a message, adds a tag, picks a search result. In a regular form, Enter submits and needs no hint.