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
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Key label text |
sx | StyleXStyles | — | StyleX style override |
Kbd.Group
| Prop | Type | Default | Description |
|---|---|---|---|
keys | string[] | — | Array of key labels to display |
separator | string | '+' | Character or string shown between keys |
label | string | — | Spoken name of the chord, for example "Command K" |
sx | StyleXStyles | — | 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.Grouprenders each key as a separate<kbd>with the separator as plain text between them.- Do not rely solely on
Kbdto communicate shortcuts — also document them in menus, tooltips, or help text.
This is an RSC-safe component — it ships no JavaScript to the browser.