Kbd
Faux keycap rendered as a native <kbd> with auto-swapped glyphs for modifier keys, arrows, return, and backspace.
Uses the native <kbd> element so keyboard input is announced distinctly; swapped-in glyph icons are aria-hidden so the keycap text remains the spoken label.
import { Kbd } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<span>
<Kbd>Cmd</Kbd> + <Kbd>K</Kbd>
</span>
);
}
Three sizes — sm, md (default), and lg — scale padding, font-size, and icon glyphs together so a keycap sits cleanly next to body text of the matching size.
import { Kbd } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '0.75rem', alignItems: 'center' }}>
<Kbd size="sm">Esc</Kbd>
<Kbd size="md">Esc</Kbd>
<Kbd size="lg">Esc</Kbd>
</div>
);
}
Modifier glyphs
Section titled “Modifier glyphs”Pass macOS-style glyphs (⌘, ⇧, ⌥, ⌃, ⌫, ↵, arrows) and Kbd auto-swaps them for rendered Lucide icons inside the keycap — never a bare Unicode character.
import { Kbd } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '0.5rem', alignItems: 'center' }}>
<Kbd>⌘</Kbd>
<Kbd>⇧</Kbd>
<Kbd>⌥</Kbd>
<Kbd>⌃</Kbd>
<Kbd>⌫</Kbd>
<Kbd>↵</Kbd>
<Kbd>↑</Kbd>
<Kbd>↓</Kbd>
<Kbd>←</Kbd>
<Kbd>→</Kbd>
</div>
);
}
Shortcut combinations
Section titled “Shortcut combinations”Compose multi-key shortcuts by chaining <Kbd> elements with a literal + separator so the combination reads naturally when styling is unavailable.
import { Kbd } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.5rem' }}>
<span>
<Kbd>⌘</Kbd> + <Kbd>K</Kbd>
</span>
<span>
<Kbd>⌘</Kbd> + <Kbd>⇧</Kbd> + <Kbd>P</Kbd>
</span>
<span>
<Kbd>Ctrl</Kbd> + <Kbd>Alt</Kbd> + <Kbd>Del</Kbd>
</span>
</div>
);
}
Inline in prose
Section titled “Inline in prose”Kbd slots into a Text paragraph for shortcut hints in onboarding or help copy.
import { Kbd, Text } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<Text>
Press <Kbd size="sm">⌘</Kbd> <Kbd size="sm">K</Kbd> to open the command palette, or{' '}
<Kbd size="sm">Esc</Kbd> to dismiss it.
</Text>
);
}
Accessibility
Section titled “Accessibility”- Renders the semantic
<kbd>element so keyboard input is announced distinctly from surrounding prose. - Swapped-in glyph icons (
⌘,⇧, arrows, etc.) are markedaria-hidden— the keycap’s text content is what assistive tech reads, so prefer including a readable label like<Kbd>Cmd</Kbd>over<Kbd>⌘</Kbd>when the audience may use a non-Mac keyboard. - Use the casing the user sees on their keyboard so the rendered hint matches the physical key.
- Pair shortcut hints with the action they trigger; never rely on the keycap alone to convey the available command.
Recipes
Section titled “Recipes”- Pair with
Textfor inline hints:Press <Kbd>Esc</Kbd> to close. - Group
Kbdelements inside command menus and tooltips to teach shortcuts contextually. - Use
size="sm"next to aText size="sm"line so keycaps don’t dominate dense rows. - Keep keycap content short — single keys or modifier names work best; combinations should be split across multiple
<Kbd>elements.