Layout & primitives
Kbd
Free10.8 KB gzippedA single keyboard key, rendered as a native <kbd> styled like a physical key cap. Labels use the display font (--font-display) for the brand's bold, athletic look; tabular numerals keep digits aligned.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · No keyboard interaction of its own · Full report
Import
import { Kbd, KbdShortcut } from "@vjdesigns/vjdesigns-ui";
Importing only Kbd adds about 10.8 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Keys
keyName tokens show the right symbol for the platform (⌘ on a Mac, Ctrl elsewhere) and read out the full key name.
import { Flex, Kbd } from "@vjdesigns/vjdesigns-ui";
export function Keys() {
return (
<Flex gap={2} wrap="wrap" justify="center">
<Kbd keyName="mod" />
<Kbd keyName="shift" />
<Kbd keyName="alt" />
<Kbd keyName="enter" />
<Kbd keyName="esc" />
<Kbd keyName="up" />
<Kbd>K</Kbd>
</Flex>
);
}
Shortcuts
KbdShortcut writes a combination, or a sequence with separator="then".
Search: Control+K
Command menu: Shift+Control+P
Go to inbox: G then I
import { KbdShortcut, Stack, Text } from "@vjdesigns/vjdesigns-ui";
export function Shortcuts() {
return (
<Stack gap={3}>
<Text>
Search: <KbdShortcut keys={["mod", "K"]} />
</Text>
<Text>
Command menu: <KbdShortcut keys={["shift", "mod", "P"]} variant="soft" />
</Text>
<Text>
Go to inbox: <KbdShortcut keys={["G", "I"]} separator="then" size="sm" />
</Text>
</Stack>
);
}
Accessibility
With keyName, a key shows the platform's symbol but screen readers hear its full name: "Command", not "place of interest sign". KbdShortcut builds whole shortcuts from the same tokens.
Open the command menu with Control+Shift+P.
Press Enter to send.
import { Kbd, KbdShortcut, Stack, Text } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
return (
<Stack gap={3}>
<Text>
Open the command menu with <KbdShortcut keys={["mod", "shift", "P"]} />.
</Text>
<Text>
Press <Kbd keyName="enter" /> to send.
</Text>
</Stack>
);
}
Translated
Spoken key names and the word between sequential keys ("dann") come from the locale (German here).
Suche öffnen: Steuerung+K
Zum Dashboard: G dann D
import {
KbdShortcut,
Stack,
Text,
LocaleProvider,
} from "@vjdesigns/vjdesigns-ui";
import de from "@vjdesigns/vjdesigns-ui/locales/de";
export function Translated() {
return (
<LocaleProvider locale="de" messages={de}>
<Stack gap={3}>
<Text>
Suche öffnen: <KbdShortcut keys={["mod", "K"]} />
</Text>
<Text>
Zum Dashboard: <KbdShortcut keys={["G", "D"]} separator="then" />
</Text>
</Stack>
</LocaleProvider>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
Keys
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// Keys is the "Keys" example above.
<LocaleProvider locale="ar" messages={ar}>
<Keys />
</LocaleProvider>
API reference
Kbd
| Prop | Type | Default |
|---|---|---|
sizeKey cap size. | "sm""md""lg" | — |
variantVisual style. | "outline""soft""solid" | — |
keyNameA platform-aware key token ( | KbdKeyToken | (string & {}) | — |
platformForce a platform instead of detecting it. Only affects | "mac""windows""linux" | — |
childrenKey label. Use | ReactNode | — |
Also accepts native <kbd> attributes, plus className, style and ref.
KbdShortcut
A key combination or sequence. Follows the HTML spec pattern for key combos: an outer <kbd> wrapping one nested <kbd> per key, with the separator as text between them (read as "plus" or "then").
| Prop | Type | Default |
|---|---|---|
keysRequiredKeys in order. Accepts platform tokens ( | Array<KbdKeyToken | (string & {})> | — |
separator
| "+""then" | — |
thenLabelWord shown between keys when | string | — |
sizeKey cap size, applied to every key. | "sm""md""lg" | — |
variantVisual style, applied to every key. | "outline""soft""solid" | — |
platformForce a platform instead of detecting it. | "mac""windows""linux" | — |
Also accepts native <kbd> attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Kbd targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
Not focusable, so there's no keyboard interaction of its own.
Roles and states
| Element | Role | States and properties |
|---|---|---|
<kbd> | none (generic) | — |
| Key symbol (⌘, ⇧, ↑) | none | aria-hidden="true", with the spoken key name ("Command") next to it |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |