Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Kbd examples · Sizes

Small Kbd for React

Small ⌘ and K key caps, 16 pixels tall with 10-pixel text.

Framework
UI library

Tooltips, dense sidebars and status bars don't always have room for a full-size key cap. This React example shrinks both keys of a ⌘K KbdGroup with h-4 min-w-4 text-[10px]: 16 pixels tall, at least as wide, with 10-pixel type. Kbd has no size prop, so the classes on each cap set its size.

Preview

Preview width
⌘K

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 use small key caps?

Where space is tight and the shortcut is a secondary hint: a compact tooltip, a sidebar listing many shortcuts, a status bar, a table cell. Keep the default size anywhere people need to read the shortcut to use it.

What font size works for small key caps?

10 pixels, as here, is about the smallest that stays legible for a single character. Below that, letters like K and symbols like ⌘ start to blur, especially on low-density screens.

Why h-4 and min-w-4?

h-4 sets the cap to 16 pixels tall and min-w-4 to at least 16 pixels wide, so a single character sits in a square. A longer label such as Ctrl still widens the cap to fit.

How much padding should small key caps have?

The Kbd's own small horizontal padding is enough for one character. For a word at this size, keep the padding small, such as px-1, so the cap doesn't grow taller than the text around it.

Are small key caps accessible?

The text is still real text, so screen readers read it and browser zoom enlarges it. 10-pixel type is hard to read for many people, though, so don't put a shortcut only in small caps if it's the only way to learn it; show it at the default size somewhere too.

Do symbols like ⌘ stay clear at this size?

Mostly, since ⌘ is a simple shape. ⌥ and ⌃ get harder to tell apart at 10 pixels; if a shortcut uses them, consider the default size or a word such as Option.