Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Kbd examples · Function Keys

Function Keys Row Kbd for React

The full F1 to F12 function key row, rendered from a static list.

Framework
UI library

A reference page that covers every function key reads best with the whole row in view. This React example renders F1 to F12 as twelve Kbd caps in one row, mapped from a static list of key names, with a small gap between them.

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 the whole row?

On a keyboard reference page, or when your app gives most function keys a job. If only one or two do something, show those keys next to their commands instead.

Should the row be interactive?

As a reference, no: Kbd caps are labels. If clicking a key should show what it does, render each one inside a button or a toggle and keep the caps as their content.

Should I group the keys like a keyboard does?

Physical keyboards split them into F1 to F4, F5 to F8 and F9 to F12. Splitting the list into three groups with a wider gap between them makes a long row easier to scan.

How should the row fit on a phone?

Twelve caps in one row overflow narrow screens. Let the row wrap, or switch to a grid of four or six columns at small widths. Most phones have no function keys anyway, so the row matters most on desktop.

How do I change the spacing or size?

The gap between caps is gap-1 on the row; raise it to separate them more. Size the caps with the same classes on each, such as h-8 min-w-8 text-base, as the Large Kbd example does.

Can I highlight the keys that do something?

Yes. Keep a list of the active keys and give their caps a stronger style, like the primary fill in the Active State example, and fade the rest. Say in text which keys do what, since color alone doesn't reach everyone.