Default
Show the codeHide the code
Default, code
<Kbd>K</Kbd>One keyboard key, in running text or menus.
These are the real React components. Use them with a mouse, touch or keyboard, and switch the theme and density for every example at once.
Default, code
<Kbd>K</Kbd>Press Ctrl + K to search.
Chord, code
<p className="text-body-md text-fg">Press <Kbd>Ctrl</Kbd> + <Kbd>K</Kbd> to search.</p>The 5 design tokens Kbd reads, with the value each has in the theme and density chosen above. Change a token and the component follows, in Figma and in code.
| Token | Value now | CSS variable |
|---|---|---|
| color.bg.raised | … | --sd-color-bg-raised |
| color.border.default | … | --sd-color-border-default |
| color.text.default | … | --sd-color-text-default |
| font.family.sans | … | --sd-font-family-sans |
| radius.sm | … | --sd-radius-sm |
The npm package isn’t published yet. When it is, this is the install line; until then, this page runs the same build of the package (from commit fa3abf8).
Install
npm i @superduperui/react @superduperui/tokensImport
import { Kbd } from "@superduperui/react"Kbd also takes the props of the React Aria component it’s built on.
| Prop | Type | What it does |
|---|---|---|
childrenrequired | string | The key as printed on the keyboard: "Ctrl", "Enter", "K". Combine several Kbd for chords. |
Screen readers announce Read as its text ("Ctrl").
WCAG 2.2 AAA criteria the component meets in Comfortable density: 1.4.6, 1.4.9, 2.3.2.
Not interactive: density changes spacing only.
| axe-core (WCAG A, AA, AAA and best practice) | 60 runs across every story, theme, density and width: 0 violations |
|---|---|
| Rendered text contrast | 180 text runs: 0 below 7:1, lowest 10.58:1 |
| Target size | 0 targets: 0 under 44px in Comfortable |
| Focus appearance (2.4.13) | 0 focus stops in 0 browser engines: all pass |
Manual passes with VoiceOver and NVDA haven’t been done yet.
The Figma component is Kbd. The Figma library isn’t published yet.
Figma to code: Key → children.