Loading component…
Loading component…
A key chip for shortcuts
To reuse this local React demo, copy all files from the Code tab into the same folder, then import Kbd from ./kbd.
import { Kbd } from "@/components/ui/kbd";
export function SearchHint() {
return (
<span>
Search runs and files <Kbd keys={["mod", "K"]} />
</span>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| keys | string \| string[] | One key or a combo, drawn in one chip. Named keys: mod (⌘ on a Mac, Ctrl elsewhere), cmd, ctrl, alt (⌥ / Alt), shift, enter, esc, tab, space, backspace, delete, up, down, left, right, pageup, pagedown, home, end – any other key is shown as it is, single letters as capitals | |
| children | ReactNode | Shown as one plain key when keys is left out. With neither, nothing renders | |
| size | "sm" \| "md" | "sm" | 18px high with 11px text (menus, hints), or 22px with 12px (lists, help sheets) |
| platform | "mac" \| "other" | Draws ⌘ ⌥ ⇧ ↵ for a Mac or Ctrl, Alt, Shift, Enter for Windows and Linux. Found out from the browser when left out – "other" on the server, so hydration matches | |
| ...kbd props | ComponentProps<"kbd"> | className, title, ref and the rest go to the <kbd> |
Never wraps: a combo stays in one chip
Tabular figures, so a column of shortcuts lines up
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"
@import "tailwindcss"; in your main CSS file.