General · astro-ui · Kbd
Kbd
Keyboard key cap for documenting shortcuts.
Kbd renders an inline semantic <kbd> styled as a key cap. Optional raised shadow gives physical depth. Use inside prose; describe sequences with an accessible label on a wrapper.
Features
- Semantic <kbd>
- 3 variants incl. borderless muted
- Raised key-cap shadow
- 3 sizes, mono font
Usage
---
import { Kbd } from "astro-ui";
---
<p>Press <Kbd>Ctrl</Kbd> + <Kbd>K</Kbd> to search.</p>Demos
Basic
Press Ctrl + K to search.
Enter to submit.
<p>Press <Kbd>Ctrl</Kbd> + <Kbd>K</Kbd> to search.</p>
<p><Kbd variant="outline" raised>Enter</Kbd> to submit.</p>API
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "outline" | "muted" | "default" | Visual style. |
size | "sm" | "md" | "lg" | "md" | Key cap scale. |
raised | boolean | false | Raised key-cap shadow. |
class | string | — | Merged via cn(); Tailwind classes welcome. |
id | string | — | Element id. |
ariaLabel | string | — | Accessible name. |
Accessibility
Implemented accessibility features — semantics, ARIA wiring, and keyboard behavior that ship with the component.
- Semantic
<kbd>elements — key sequences are announced as keyboard input
Changelog
Version history mentioning Kbd.
v0.1.0 — 2026-11-11
added
- General (7): Button, ButtonGroup, Command, Carousel, Clipboard, Kbd, Link.