// preview in
saved for every page

Kbd

Shows a key or a keyboard shortcut, like Ctrl K, in the text, a menu or a tooltip. It only displays the keys; you wire the shortcut yourself.

Pattern HTML kbdServer componentSource ↗

Installation

Set up Camaleo once (Installation), then import what you need. It renders on the server.

import { Kbd } from "@camaleo/react";

Anatomy

One <kbd> per key. A combination is several Kbd side by side, not one.

Examples

Every example is a real file you can copy. They all wear the skin, mode and brand from the bar above.

minimal · light · #3fa34d
Open search⌘K
Copy
Ctrl+C
Paste
Ctrl+V
Find in all files
Ctrl+Shift+F

Key combinations

One Kbd per key, so people see at a glance how many keys to press and which ones.

  • Command
  • Option
  • Shift
  • Return

Mac symbols

⌘ and ⌥ mean nothing to a screen reader. Hide the glyph with aria-hidden and add the key's name with VisuallyHidden.

Windows and Linux
CtrlShiftZ
macOS
CommandShiftZ

Windows and Mac

The same action uses Ctrl on Windows and ⌘ on a Mac. When you don't know the system, show both, each with its name.

Go to inboxGthenI

Go to draftsGthenD

One key, then another

For shortcuts pressed one after the other, write "then" between the keys. Without it, people press them together.

In a menu

Open the menu. Shortcuts sit at the end of each item, so people learn them while they click. aria-keyshortcuts tells screen readers the keys.

In a tooltip

Hover or focus the button. The tooltip teaches the shortcut at the moment people use the action.

Command palette:CtrlShiftP

Change a shortcut

Click "Change shortcut" and press new keys. Tab and Escape are never recorded: Tab moves on, Escape cancels, so keyboard users can always leave.

In context

Shortcuts show up where people act. These are whole pieces of UI you can copy, in the skin you picked.

Keyboard shortcuts

Command palette
Ctrl+K
Show this list?
Go to dashboard
GthenD
Shortcut listCard · Kbd
Search field with a shortcutSearchInput · Kbd
Saved 2 minutes ago
1,420 words
⌘S
Editor status barKbd

Guidelines

Save fileCtrl+S
DoOne Kbd per key.

Separate caps show how many keys there are, and each one reads as a key.

Save fileCtrl + S
Don’tThe whole shortcut in one cap.

"Ctrl + S" in one box looks like a single key with a strange name.

Open the command paletteCommandK

DoGive symbols a name.

Screen readers skip ⌘ or read it as "place of interest". Add "Command" as hidden text.

Press ctrl and k to search

Don’tShortcuts lost in a sentence.

"Press ctrl and k" blends into the text, and people skimming the page miss it.

Props

PropTypeDefaultDescription

Kbd has no props of its own. It renders a <kbd> and takes its attributes, like className and style.

Styling hooks

Restyle it without forking: target the slot, or set the tokens on a parent, a skin or the key itself.

Tokens it reads

Color

--cml-border--cml-fg--cml-fg-secondary--cml-surface-raised

Shape & size

--cml-border-width--cml-radius-control-sm

Type & motion

--cml-font-control--cml-font-weight-control

This component only

--cml-corner-shape

Accessibility

—Kbd only shows keys and never takes focus. The control it belongs to does.
Was this page helpful? · Edit this page on GitHub