Import
Usage
Anatomy
Kbd- Single keyboard key displayKbd.Group- Container for multiple keys in a sequence
Props
Kbd
Controls the key size and text:
xs- Height 4 (16px), text 10px, min-width 4sm- Height 5 (20px), text 11px, min-width 5md- Height 5 (20px), text xs, min-width 5lg- Height 6 (24px), text sm, min-width 6xl- Height 7 (28px), text sm, min-width 7
Additional CSS classes to apply.
Kbd.Group
Controls the size for all child Kbd components.
The separator to display between keys.
Additional CSS classes.
Examples
Single key
Key combination
Custom separator
Different sizes
In tooltips
Kbd automatically adjusts styling when inside tooltips:With icons
Combine with icons for visual representation:Platform-specific shortcuts
Arrow keys
Function keys
Data Attributes
[data-size]- Reflects the current size[data-slot]- Value is “kbd” or “kbd-group”
Accessibility
- Uses semantic
<kbd>element - Proper font and spacing for readability
- Sufficient color contrast
- SVG icons automatically sized and non-interactive
- Screen readers announce key combinations naturally
Styling Context
The Kbd component adapts its appearance in different contexts:- Default: Muted background with muted foreground text
- In tooltips: Semi-transparent background adapting to tooltip theme