Skip to content

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

Free

Function Keys Row Kbd for Ark UI

The function keys F1 through F12 as twelve caps in one row, rendered from a fixed list of key names.

A static list maps F1 through F12 into twelve caps with a small gap. The row is a reference. It is not a set of listeners.

Use the full row on a keyboard reference. In the product, show only the keys you handle. One key beside a Button is easier to learn. In React, Ark UI does not bind the function 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.
Use email insteadNo credit card

Anatomy

Kbd anatomy: kbd, group

Usage

<div className="rounded-md border bg-background p-4">
  <div className="flex gap-1">
    {FUNCTION_KEYS.map((key) => (
      <Kbd key={key}>{key}</Kbd>
    ))}
  </div>
</div>

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.

API Reference

Kbd

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