Kbd

A styled keyboard key indicator for shortcuts and commands.

Import

import { Kbd } from '@matix/components/kbd';

Usage

Ctrl + Cto copyCtrl + Vto paste

Key Group

Use Kbd.Group to display keyboard chords and shortcuts.

<Kbd.Group keys={['Ctrl', 'S']} />
<Kbd.Group keys={['Cmd', 'Shift', 'P']} />
<Kbd.Group keys={['Alt', 'F4']} />

Spoken Name

Screen readers read symbol keys badly: ⌘ is "place of interest sign". Set label to give the chord a spoken name. The keys are then hidden from screen readers.

<Kbd.Group keys={['⌘', 'K']} label="Command K" />

Custom Separator

<Kbd.Group keys={['Ctrl', 'C']} separator="+" />
<Kbd.Group keys={['Ctrl', 'C']} separator=" then " />

Custom Styles

import * as stylex from '@stylexjs/stylex';

const custom = stylex.create({
  large: { fontSize: '1rem', padding: '4px 8px' },
});

<Kbd sx={custom.large}>Enter</Kbd>;

API Reference

Kbd

PropTypeDefaultDescription
childrenReactNode—Key label text
sxStyleXStyles—StyleX style override

Kbd.Group

PropTypeDefaultDescription
keysstring[]—Array of key labels to display
separatorstring'+'Character or string shown between keys
labelstring—Spoken name of the chord, for example "Command K"
sxStyleXStyles—StyleX style override

All other HTML attributes, such as id and aria-*, go to the root element.

Accessibility

  • Each key renders a <kbd> HTML element, which screen readers recognize as keyboard input.
  • Kbd.Group renders each key as a separate <kbd> with the separator as plain text between them.
  • Do not rely solely on Kbd to communicate shortcuts — also document them in menus, tooltips, or help text.

This is an RSC-safe component — it ships no JavaScript to the browser.