Kbd
Inline keyboard-key indicator rendered as a semantic kbd keycap.
Status: stable. Group: display. Markdown version: /design-system/components/kbd.md
When to use
Kbd marks keyboard input inline: a single keycap per component, composed into chords with literal separators between siblings. It is purely presentational text with correct kbd semantics, sized to sit inside prose, tooltips, and menu hints.
When not to use
The contract records no forbidden uses.
Look-alikes
- Code: Do not use for keyboard keys; that is Kbd.
Props
| Prop | Type | Default | Description | Required |
|---|---|---|---|---|
size | "sm" | "md" | "lg" | md | Size token. Defaults to "md". | No |
variant | "primary" | "secondary" | primary | Visual style. primary is a filled light-gray keycap with a bottom edge that reads like a physical key; secondary is the flatter outlined chip. Defaults to "primary". | No |
Variants
- Available variants:
primary,secondary(defaultprimary). - Available sizes:
sm,md,lg(defaultmd).
Invalid combinations
The contract records no invalid combinations.
Keyboard
The contract records no keyboard interaction.
Rules
Every item under When not to use is a MUST NOT. MUST and SHOULD follow RFC 2119.
| Level | Rule | How it is checked |
|---|---|---|
| MUST | ARIA: None; static text semantics via the kbd element. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | Required stories produce no axe violations at the configured severity. | Automated by npm run test:stories:matrix:ci. WCAG 2.5.8. |
| MUST | The accessibility tree (role, name, state) matches the committed snapshot for every required story. | Automated by npm run test:stories:matrix:ci. WCAG 1.3.1, 4.1.2. |
| MUST | The component remains legible and operable under a real browser forced-colors: active pass. | Automated by npm run test:stories:hc. |
| MUST | A human completed an end-to-end accessibility review of this component. | Manual review, last on 2026-11-04. |
| SHOULD | One key per Kbd; write chords as <Kbd>⌘</Kbd> + <Kbd>K</Kbd> so screen readers hear the separator. | Not stated in the contract. |
| SHOULD | Match size to the surrounding text scale; sm inside Tooltip and menu hints, md in prose. | Not stated in the contract. |
| SHOULD | Use platform-correct symbols (⌘/Ctrl) from your own platform detection; Kbd renders what you pass. | Not stated in the contract. |
| SHOULD | Pair every shortcut hint with a clickable way to do the same action; the hint is an accelerator, not the affordance. | Not stated in the contract. |
| SHOULD NOT | Do not make Kbd interactive; it is not a button and never receives focus. | Not stated in the contract. |
| SHOULD NOT | Do not put full words or phrases in one keycap except actual key names (Esc, Enter, Space). | Not stated in the contract. |
Install and import
- Install:
npm install @digitaltableteur/react(version 0.9.1, restricted access on npm). - Import:
import { Kbd } from "@digitaltableteur/react"; - Entry point:
@digitaltableteur/react/typographyexports it too. - Styles: import
@digitaltableteur/react/style.cssonce at the app boundary. - Also available as the custom element
<dt-kbd>; see the custom elements manifest.
Links
- Machine-readable contract (Design System Contract 1.0)
- Markdown version of this page
- Component index as JSON
- All components
- Source: The implementation lives in a private repository. This page, its Markdown twin and the contract are generated from it at build time and are the public source of truth.