Keyboard
Display keyboard keys with platform-specific styling for Windows and macOS.
The Keyboard component automatically renders platform-appropriate key symbols for macOS and Windows. It's perfect for documenting keyboard shortcuts in your application.
Usage
Basic Usage
Simply use the Kbd component with a show prop:
Renders as: ⌘ + C
Automatic Symbol Rendering
The component automatically renders appropriate symbols based on the platform:
Renders as:
- Windows: Ctrl + V
- Mac: ⌘ + V
Custom Content
For custom key labels, provide children:
Renders as: custom
Arrow Key
Render as: ↑ ↓ ← →
Props
Supported Keys
The component includes special handling for common keys:
Best Practices
- Be Consistent: Stick to one platform style within the same context
- Use Type Wisely:
- Use
type="mac"for Mac-specific documentation - Use
type="window"(default) for Windows/Linux
- Use
- Accessibility: The component uses semantic
<kbd>HTML for better accessibility
Notes
- The component automatically capitalizes single letters (e.g., 'a' becomes 'A')
- Unrecognized keys are displayed as-is
- Dark mode is automatically supported through Tailwind's dark mode classes
Last updated May 5, 2026