Display
Kbd
Keyboard keys and shortcuts.
Keys and combinations
A key cap in the mono face with a border and a thin lip underneath. KbdGroup joins keys into a combination; plus draws a “+” between them.
EscEnterTab⌘KCtrlShiftP
⌘S⌘S⌘S
When to use
- Show a shortcut next to the action it triggers: menu items, command palette, buttons.
- Name a key inside instructions: “Press Esc to close”.
Not for: code or file names (use inline code), or buttons that can be clicked (use a button).
In context
Small keys fit inline text and menu rows; keep one size per list.
- New project⌘N
- Search files⌘P
- Toggle sidebar⌘B
Press Esc to close the panel, or Enter to confirm.
API
Kbd
| Prop | Type | Default | Description |
|---|---|---|---|
| size | 'sm' | 'md' | 'lg' | 'md' | 20 / 24 / 28px tall. |
| ...props | HTMLAttributes<HTMLElement> | — | Forwarded to <kbd>, including ref and className. |
KbdGroup
| Prop | Type | Default | Description |
|---|---|---|---|
| plus | boolean | false | Draw a “+” between the keys. |
| ...props | HTMLAttributes<HTMLSpanElement> | — | Forwarded to the wrapper. |
Accessibility
- Renders the semantic <kbd> element; screen readers read the text of each key.
- The “+” between keys is generated content with empty alt text, so it is not announced; for symbol-only keys add an aria-label to the group (“Shortcut: Command K”).
- Key text meets 4.5:1 on its fill in light and dark.
Motion
- None. A key cap is static.