npx shadcn@4.23.1 add @goop/meadow-shortcut-keyShortcut key
FreeOne keyboard key drawn as a small bordered cap inline in hint text, naming a chord with its neighbours, for React and Tailwind CSS. Free, MIT.
What an agent sees
- ShortcutKeyGroupOne key combination — a chord such as Command and K, or a choice of chords with a
ShortcutKeySeparatorbetween them — said to a reader as one group (akbdofkbds, HTML's own markup for a key combination) - ShortcutKeySeparatorThe faint joiner between two chords in a
ShortcutKeyGroup— a comma by default, or your own word ("or", "then")
import { ShortcutKey, ShortcutKeyGroup, ShortcutKeySeparator } from '@/components/ui/goop/shortcut-key';
function NewTaskHint() {
return (
<p className="flex items-center gap-1 text-base text-muted-foreground">
Press
<ShortcutKey>Ctrl</ShortcutKey>
<ShortcutKey>N</ShortcutKey>
to add a task
</p>
);
}
function FieldNoteShortcut() {
return (
<div className="flex items-center justify-between py-3">
<span className="text-lg font-medium">Open a field note</span>
<ShortcutKeyGroup size="lg" aria-label="Command J or Command K">
<ShortcutKey>⌘</ShortcutKey>
<ShortcutKey>J</ShortcutKey>
<ShortcutKeySeparator />
<ShortcutKey>⌘</ShortcutKey>
<ShortcutKey>K</ShortcutKey>
</ShortcutKeyGroup>
</div>
);
}Pick one key or a pair, or type keys of your own, a space or + between two: the keys sit in the sentence that names them. Pressing the keys does nothing here: the shortcut key only shows them.
When to use
- One keyboard key drawn as a small bordered cap inline in hint text, naming a chord with its neighbours.
- Also called: kbd or keyboard key.
Installation
Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Shortcut key on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.
npx shadcn@4.23.1 add @goop/meadow-shortcut-keyAdd the Goop Shortcut key to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { ShortcutKey, ShortcutKeyGroup, ShortcutKeySeparator } from '@/components/ui/goop/shortcut-key';
function NewTaskHint() {
return (
<p className="flex items-center gap-1 text-base text-muted-foreground">
Press
<ShortcutKey>Ctrl</ShortcutKey>
<ShortcutKey>N</ShortcutKey>
to add a task
</p>
);
}
function FieldNoteShortcut() {
return (
<div className="flex items-center justify-between py-3">
<span className="text-lg font-medium">Open a field note</span>
<ShortcutKeyGroup size="lg" aria-label="Command J or Command K">
<ShortcutKey>⌘</ShortcutKey>
<ShortcutKey>J</ShortcutKey>
<ShortcutKeySeparator />
<ShortcutKey>⌘</ShortcutKey>
<ShortcutKey>K</ShortcutKey>
</ShortcutKeyGroup>
</div>
);
}- Fits: settings, states: body.
- Also known as: Kbd.
- height, width, padding, gap, corner, background, text, motion: add no class for these.
API reference
| Option | Type | What it does |
|---|---|---|
| size | md | lg = md | |
| asChild? | boolean = false | Render the key's look on the one child element instead of a kbd. |
| Part | What it is |
|---|---|
| ShortcutKeyGroup | One key combination — a chord such as Command and K, or a choice of chords with a ShortcutKeySeparator between them — said to a reader as one group (a kbd of kbds, HTML's own markup for a key combination); size?: 'md' | 'lg' = 'md' — The size of the keys and the joiner inside the group: md (the default) or lg |
| ShortcutKeySeparator | The faint joiner between two chords in a ShortcutKeyGroup — a comma by default, or your own word ("or", "then") |
- Class recipes (cva): shortcutKeyVariants (ShortcutKey)
- data-slot values (to select a part by): shortcut-key, shortcut-key-group, shortcut-key-separator
Motion
- The part sets its own motion: add no transition or animation of your own.
Notes for AI
Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.