Components / Display
Kbd14
A keyboard key with a thick bottom edge, for shortcuts in help text, menus and tooltips.
Esc
<Kbd>Esc</Kbd>Usage
import { Kbd } from "plonk-ui";
export function Hint() {
return (
<p>
Press <Kbd>⌘</Kbd> <Kbd>K</Kbd> to search.
</p>
);
}One Kbd is one key. For a combination, put the keys next to each other.
Shortcut list
- Search
- ⌘K
- New project
- ⌘ShiftN
- Close panel
- Esc
import { Kbd } from "plonk-ui";
const SHORTCUTS = [
{ action: "Search", keys: ["⌘", "K"] },
{ action: "New project", keys: ["⌘", "Shift", "N"] },
{ action: "Close panel", keys: ["Esc"] },
];
export default function Shortcuts() {
return (
<dl className="grid w-full max-w-xs grid-cols-[1fr_auto] gap-x-6 gap-y-3">
{SHORTCUTS.map(({ action, keys }) => (
<div key={action} className="contents">
<dt className="font-bold">{action}</dt>
<dd className="flex gap-1">
{keys.map((key) => (
<Kbd key={key}>{key}</Kbd>
))}
</dd>
</div>
))}
</dl>
);
}In text
Keys sit on the text's baseline and keep the line readable. Give the line a little more height if keys appear often.
Press ⌘ K to open the command palette, then ↵ to run the highlighted command.
import { Kbd } from "plonk-ui";
export default function Inline() {
return (
<p className="max-w-xs leading-8">
Press <Kbd>⌘</Kbd> <Kbd>K</Kbd> to open the command palette, then{" "}
<Kbd>↵</Kbd> to run the highlighted command.
</p>
);
}Personalities
The key takes the personality's mono font, border and corners, with a doubled bottom edge so it reads as a key you can press. In Arcade it sits light on the dark screen.
Accessibility
Kbdrenders a native<kbd>, which marks the text as keyboard input.- Screen readers read symbols like ⌘ and ⇧ inconsistently. When the shortcut
matters, spell it out nearby ("Command K") or write the key name (
Ctrl). - Shortcuts are help text, not the only way in: every action should also be reachable without them.
API
Kbd has no props of its own. Every <kbd> prop is passed through, and
className is merged with Tailwind Merge.