Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Kbd examples · Sizes

Default Kbd for React

A ⌘K shortcut at the key cap's default size.

Framework
UI library

Most shortcut hints need a key cap that reads clearly without taking over the line. This React example groups ⌘ and K in a KbdGroup with no size classes, so both caps keep the Kbd's own size: about as tall as a line of small text, with extra-small type and a muted fill. Start here for menus, tooltips, settings pages and docs, and reach for the small or large examples only when the context calls for it.

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

What is the default size of a Kbd?

Kbd has no size prop. Its classes make it 20 to 22 pixels tall depending on the style, with a matching minimum width so single characters stay square, extra-small medium-weight type and small horizontal padding. The cap grows wider to fit a word such as Ctrl.

When should I use the default size instead of custom sizing?

Almost always. The default fits menu items, tooltips, buttons, inputs and running text. Use smaller caps only where space is tight, like a dense status bar, and larger ones where the shortcut is the subject, like a hero or a tutorial.

Is the default size readable for everyone?

For a short hint next to a control, yes: the text is the same extra-small size used for labels across the components. If the shortcut is the main content of a page, or people will read it from a distance, use a larger size.

How do I change the default size across my app?

Edit the classes in your copy of the Kbd component, since it lives in your project. Changing them once updates every key cap, which is better than adding size classes at every use.

Should the Kbd font size match the surrounding text?

Kbd uses extra-small type so it sits inside small text, menu items and tooltips without pushing the line apart. Next to larger body text it reads a little smaller, which helps it look like a key rather than a word.

What spacing works between default-size keys?

KbdGroup puts a small gap between the keys of one shortcut, as here. Leave a wider gap, or a word like then, between separate shortcuts so they don't read as one chord.