Foundations
Key Hint
Keyboard shortcut hints that adapt to the platform — Cmd on Mac, Ctrl elsewhere.
2 variantsMIT
Preview
Installation
Copies the component into components/ui and installs its dependencies and theme tokens.
pnpm dlx shadcn@latest add https://ui.tmih06.com/r/key-hint.jsonUsage
Pass your own data and wire the callbacks to your agent runtime.
import { Kbd, KeyCombo } from "@/components/ui/key-hint";
<KeyCombo keys="mod+k" /> // ⌘ K on Mac, Ctrl K elsewhere
<KeyCombo keys="shift+enter" />
<Kbd>Esc</Kbd>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| keys* | string | — | KeyCombo: keys joined by "+". mod, shift, alt, ctrl, enter, esc, arrows and letters are mapped per platform. |
| size | "sm" | "md" | "sm" | Chip size for Kbd and KeyCombo. |
| children | ReactNode | — | Kbd: the key label. |
| labels | Partial<KeyHintLabels> | — | KeyCombo: spoken key names (Command, Shift, Up…), for translating. The chips stay left to right under `dir="rtl"`. |
function formatKeys(combo: string, onMac: boolean): string[];
function useIsMac(): boolean; // false during prerender, real value after mount