Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Layout & primitives

Kbd

Free10.8 KB gzipped

A 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

tsx
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.

ControlShiftAltEnterEscapeUp ArrowK
tsx
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

tsx
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.

tsx
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

tsx
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

ControlShiftAltEnterEscapeالسهم لأعلىK
tsx
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

Kbd props
PropTypeDefault
size

Key cap size.

"sm""md""lg"—
variant

Visual style. outline is a light key with a strong edge, soft a tinted key, solid a dark key.

"outline""soft""solid"—
keyName

A platform-aware key token ("mod", "shift", "enter", "up", ...). When set, the key shows the platform symbol and screen readers hear the full name (e.g. "Command" instead of "place of interest sign"). Takes precedence over children. Unknown strings render as-is.

KbdKeyToken | (string & {})—
platform

Force a platform instead of detecting it. Only affects keyName.

"mac""windows""linux"—
children

Key label. Use keyName instead for modifier and special keys.

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").

KbdShortcut props
PropTypeDefault
keysRequired

Keys in order. Accepts platform tokens ("mod", "alt", "shift", "enter", arrows, ...) or literal labels ("K", "/").

Array<KbdKeyToken | (string & {})>—
separator

"+" for keys pressed together (default), "then" for a sequence pressed one after another.

"+""then"—
thenLabel

Word shown between keys when separator="then". Override to localize.

string—
size

Key cap size, applied to every key.

"sm""md""lg"—
variant

Visual style, applied to every key.

"outline""soft""solid"—
platform

Force 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)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 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

Roles and states
ElementRoleStates and properties
<kbd>none (generic)—
Key symbol (⌘, ⇧, ↑)nonearia-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.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery 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)
FocusFocus 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 readersNames, 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)
ColorMeaning 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 reflowAt 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 targetsClick 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)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)