shadcn.io is not affiliated with official shadcn/ui
Card Inset Keyboard Shortcut CTA Block for React
A centred card-in-card call to action built around a keyboard shortcut: three key caps in a hairline frame that press down as the keys do and open a filterable command palette, which the Shine Button opens too.
Installation
Overview
Convert power users with a call to action whose picture is the shortcut, for React with Base UI. A muted shell with + marks on its corners wraps a raised panel that follows your theme, with a centred headline, a short paragraph for a notes workspace and three oversized key caps joined by plus signs inside a hairline frame of their own, then one Shine Button, "Try the shortcut". The caps are a real button: click them, or the Shine Button, and a command palette opens in a dialog with four actions you can filter by typing. Press the shortcut itself with focus inside the section and the palette opens, the caps sinking as the modifier keys go down. It's built from Guides, Frame, Kbd, Command and Shine Button, with CSS transitions for the entrance and the key presses, and your theme's tokens for every colour. For command palettes, universal search, quick switchers and any product whose speed is the pitch.
FAQ
How do I change the shortcut and the actions in the palette?
The caps come from KEYS at the top of the file, one cap each in the order the keys are pressed. The check that opens the palette is isShortcut, which wants Command or Control, Shift and K; change it and heldCaps together so the caps follow the keys you pick. The palette's rows are the ACTIONS list: an icon, a label and an optional shortcut hint. Four to six keep it the height of a real palette.
Where does the shortcut work, and why not on the whole page?
Only while focus is inside the section. The keys are read by an onKeyDown on the section's shell, never a listener on the window, so a marketing block doesn't take a shortcut away from the rest of your page or from the browser. Keys typed in the palette itself are ignored by that handler. If your app already has a global shortcut, bind it there and keep this block as the picture of it.
What do keyboard and screen reader users get?
The caps are one button with a name that spells the shortcut out, "Open the command palette. Shortcut: Command or Control, Shift and K", and aria-keyshortcuts for it; the cap glyphs themselves are hidden, since a screen reader may read ⌘ as "place of interest sign". The palette is a real dialog: focus moves into its search field, the arrow keys move through the actions, Enter runs one and Escape closes it, and focus returns to whatever opened it. The action you picked is announced in a polite status line under the button.
How do I make the actions do something?
Choosing one calls the palette's select handler, which closes the dialog and stores the label in chosen, shown under the button as "You chose Invite a teammate". Replace that with your own: route to a page, open another dialog or call a function. Nothing here talks to a server, and the status line is only there so the demo says what happened.
Each CommandItem has an onSelect; handleSelect receives the item's value, its label here.
What about Windows and Linux, where there's no Command key?
The caps show the Mac key, as most keyboard-first products do, and the line under the button says "Command on macOS, Control on Windows and Linux". The handler accepts either one (metaKey or ctrlKey). If your audience is mostly on Windows, change the first cap to Ctrl in KEYS, and the button's aria-label with it.
What moves, and what happens with reduced motion?
The card fades up once on load, the caps sink about two pixels while pressed or while their modifier key is held and the palette uses the dialog's own transition. They're all CSS, and with reduced motion on the entrance is switched off, so everything is in place from the start, and a pressed cap sinks at once instead of gliding.
Related
- Pro
Inset Announcement Badge CTA
Card in cardA card-in-card call to action for a code editor's AI completion: the headline and one sentence at the start, a linked announcement pill and a Shine Button at the end, in a muted frame with + marks on its corners.
- Pro
Inset Count Badge CTA
Card in cardA centred card-in-card hiring CTA whose Shine Button wears a pinned count of open roles, with three featured roles as links in one hairline-divided strip below it.
- Pro
Inset Code Snippet Copy CTA
Code and commandsA card-in-card call to action for a data SDK, split by a hairline: the headline, one sentence and a Shine Button at the start, and a three-line quickstart snippet with a copy button on every line and a Copy all button at the end.
- Pro
Card Inset Metric Row CTA
Figures and statsA start-aligned card-in-card CTA for an API platform: a headline, one sentence and two calls to action, with three platform figures in a closing band across the foot of the panel.
- Pro
Centered Command Palette Mockup Hero
Product windowsA showcase hero for a keyboard-first issue tracker: a centred headline and two calls to action over a command palette drawn in a hairline frame.
- Pro
Split Search Bar Hero
Interactive demosA split hero whose call to action is a large search field with a Shine Button, popular searches, and, across a solid divider, a results panel that filters as you type.