Shortcut
Renders keyboard shortcut combinations as styled kbd elements with platform-aware modifier keys.
Examples
EscapeEnterTabCtrl+S
import { Shortcut } from "@g4rcez/components/display/shortcut";
function SimpleShortcuts() {
return (
<div className="flex flex-wrap gap-4">
<Shortcut value="Escape" />
<Shortcut value="Enter" />
<Shortcut value="Tab" />
<Shortcut value="Ctrl+S" />
</div>
);
}Ctrl+KCtrl+Shift+PAlt+F4
import { Shortcut } from "@g4rcez/components/display/shortcut";
function PlatformAdaptive() {
return (
<div className="flex flex-wrap gap-4">
<Shortcut value="Mod+K" />
<Shortcut value="Mod+Shift+P" />
<Shortcut value="Alt+F4" />
</div>
);
}- Open command paletteCtrl+K
- Save documentCtrl+S
- Find in fileCtrl+F
- Close tabCtrl+W
import { Shortcut } from "@g4rcez/components/display/shortcut";
function ShortcutsInContext() {
const commands = [
{ label: "Open command palette", shortcut: "Mod+K" },
{ label: "Save document", shortcut: "Mod+S" },
{ label: "Find in file", shortcut: "Mod+F" },
{ label: "Close tab", shortcut: "Mod+W" },
];
return (
<ul className="flex flex-col divide-y divide-card-border">
{commands.map((cmd) => (
<li key={cmd.shortcut} className="flex items-center justify-between py-2">
<span>{cmd.label}</span>
<Shortcut value={cmd.shortcut} />
</li>
))}
</ul>
);
}When to use Shortcut
Use when
You need the documented Shortcut interaction or presentation in a product workflow.
Avoid when
A native HTML element already provides the Shortcut behavior you need.
Accessibility
Keep the Shortcut labeled and use its documented keyboard interaction. The component preserves visible focus and communicates state without relying on color alone.
- Keep keyboard focus visible and follow the documented key commands.
- Provide an accessible name and connect descriptions or errors to the control.