A key or a shortcut as on a keyboard: ⌘ K on a Mac, Ctrl K elsewhere, read out as words.
$ pnpm dlx shadcn@latest add https://dashral.com/r/kbd.jsonInstallation
$ pnpm dlx shadcn@latest add https://dashral.com/r/kbd.jsonAdds the component, the components it builds on, its npm packages and the theme tokens it uses. Using Dashral often? Add the registry to components.json once:
{
"registries": {
"@dashral": "https://dashral.com/r/{name}.json"
}
}Then add components by name:
$ pnpm dlx shadcn@latest add @dashral/kbdUsage
import { Kbd } from "@/components/dashral/kbd"
<Kbd keys={["mod", "K"]} />Examples
API reference
Kbd
Also takes every prop of <kbd>(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
keys | string[]A shortcut's keys, e.g. ["mod", "K"]. "mod" is ⌘ on a Mac and Ctrl elsewhere; "shift", "alt", "ctrl", "enter", "esc", "tab", "backspace", "space" and "up" / "down" / "left" / "right" show as symbols and are read out by name. | — |
children | ReactNodeA single key, as text, when keys isn't given. | — |
size | "sm" | "default"20px or 24px caps. | "default" |
className | stringExtra classes, merged with cn() so yours win. | — |
Accessibility
- A shortcut is nested <kbd> elements, read out as words ("Command K") through aria-label, not as symbols.
- Mac or not is worked out after the page loads; the first paint shows ⌘.