Shortcuts Dialog React component for Tailwind CSS v4
v1.0.0Added in 1.0.0
A React keyboard shortcuts dialog, the "?" overlay of keyboard-friendly apps: every shortcut grouped and searchable, in the device's notation.
Press ? anywhere (not while typing) and the dialog springs in with every shortcut grouped in two columns; press it again to close. Keys show as ⌘ ⇧ glyphs on a Mac and Ctrl / Shift words elsewhere, alternatives read "⌘ K or /" and sequences "G then I". With a mouse or trackpad the search takes focus at once: type a word, a key ("ctrl", "shift", "⌘") or a group name and the rows narrow instantly with the matching letters underlined, groups without matches disappear and an empty state fades in when nothing is left; the card keeps its height while you search, so nothing jumps. Esc clears the search first, then closes; Tab moves between the search, the clear button and the close button. On a phone it is a tall bottom sheet in one column with the search pinned under the title (it keeps its height while you filter), opened from a trigger such as a help menu entry; swipe it down or tap outside to close, and the keyboard only appears when you tap the search.
Shortcuts Dialog is a Pro React component in the React overlay components category, written in TypeScript for React 19 and Tailwind CSS v4. It installs as source with npx wingo-ui@latest add shortcuts-dialog, together with UIProvider, Dialog, Input, Kbd, useControllableState and 4 more and the npm packages motion and lucide-react.
Add to a project
Requirements: React 19 and Tailwind CSS v4, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup
npx wingo-ui@latest add shortcuts-dialogShortcuts Dialog is part of Pro, with 298 more Pro items: $8 a month or $150 once. 14-day refund before you download any Pro item. See plans
Usage
Import ShortcutsDialog from @/components/ui/shortcuts-dialog.
import { Keyboard } from "lucide-react"
import { Button } from "@/components/ui/button"
import { Kbd } from "@/components/ui/kbd"
import { ShortcutsDialog, type ShortcutGroup } from "@/components/ui/shortcuts-dialog"
const groups: ShortcutGroup[] = [
{
label: "General",
items: [
{ label: "Search", shortcut: ["mod+k", "/"] },
{ label: "Shortcuts", shortcut: "?" },
{ label: "Toggle sidebar", shortcut: "mod+b" },
],
},
{
label: "Navigation",
items: [
{ label: "Go to Inbox", shortcut: ["g", "i"], sequence: true },
{ label: "Go to Clients", shortcut: ["g", "c"], sequence: true },
],
},
{
label: "Invoices",
items: [
{ label: "New invoice", shortcut: "f", keywords: ["issue"] },
{ label: "Send by email", shortcut: "mod+enter" },
{ label: "Download PDF", shortcut: "shift+mod+d" },
],
},
]
export function HelpShortcuts() {
return (
<ShortcutsDialog
groups={groups}
title="Keyboard shortcuts"
hint={
<span className="inline-flex items-center gap-1.5">
Press <Kbd shortcut="?" size="sm" /> any time to open the list
</span>
}
trigger={
<Button variant="soft" size="sm" leftIcon={<Keyboard />}>
Shortcuts
</Button>
}
/>
)
}Props
groupsdefault"[]"ShortcutGroup[]{ id?, label?: ReactNode, textValue?, items: ShortcutEntry[] }. An entry is { id?, label: ReactNode, shortcut: string | string[], description?: ReactNode, sequence?: boolean, keywords?: string[], textValue?: string }. Shortcuts use mod+k notation; an array is alternatives ("mod+k" or "/"), or the keys of a sequence when sequence is true (["g", "i"]). An unparseable shortcut shows its raw text in one cap. Empty groups are hidden.
titledefault"Keyboard shortcuts"ReactNodeThe dialog title. "" keeps it for screen readers only.
descriptiondefault""ReactNodeA muted line under the title.
searchPlaceholderdefault"Search shortcuts"stringThe search field's placeholder and accessible name.
emptyTextdefault"No shortcuts found"ReactNodeShown when nothing matches the search.
thenLabeldefault"then"stringBetween the keys of a sequence ("G then I"). Screen readers read it too.
orLabeldefault"or"stringBetween alternatives ("⌘ K or /").
closeLabeldefault"Close"stringaria-label of the close button.
clearLabeldefault"Clear"stringaria-label of the search's clear button.
hintReactNodeThe footer line. Default: "Press ? anytime to see this list" with the bound key as a cap, hidden on touch screens; null hides it. Pass a translated node for localized apps.
sizedefault"lg""md" | "lg" | "xl"The dialog's max width: 520 / 720 / 960px. On phones the sheet with a search is 92% tall, so filtering never resizes it; without a search it fits its content.
radiusdefault"lg""none" | "sm" | "md" | "lg"Corner shape of the card (sm 12px, md 16px, lg 24px) and of the phone sheet's top corners.
platformdefault"auto""auto" | "apple" | "other"The key notation: apple shows ⌘ ⇧ ⌥ glyphs, other Ctrl / Shift / Alt words. auto renders the other form on the server, then the device's.
kbdVariantdefault"soft""soft" | "outline" | "solid"The key cap look: the quiet gray key, a bordered key or a raised physical key.
kbdSizedefault"sm""sm" | "md"Key cap height, 16 or 20px.
columnsdefault21 | 2Groups side by side from 768px. Phones always get one column.
defaultOpendefaultfalsebooleanStarts open while uncontrolled.
openbooleanControlled open state; pair it with onOpenChange (e.g. to open it from a help menu entry).
onOpenChange(open: boolean) => voidCalled when it opens or closes (trigger, shortcut, Esc, outside click, swipe).
shortcutdefault"?"stringOpens and closes it from anywhere, in mod+k notation. Keys without a modifier never fire while typing, so "?" in the search types a "?". "" binds nothing. The showcase itself listens for ?, so the demo binds ⌘/ in its place.
searchdefaulttruebooleanA filter field above the groups. It matches labels, keywords, descriptions and the shortcut in both notations, ignoring case and diacritics; it takes focus on open only with a mouse or trackpad.
responsivedefaulttruebooleanA bottom sheet below 768px (one column, search pinned). false keeps the centered card on phones.
triggerReactNodeThe element that opens it, rendered with asChild (a single element that takes a ref); it gets aria-keyshortcuts.
containerHTMLElement | nullPortal target, document.body by default.
classNamesPartial<Record<"content" | "header" | "search" | "groups" | "group" | "groupLabel" | "row" | "label" | "description" | "keys" | "then" | "or" | "mark" | "empty" | "hint", string>>Extra classes for the inner parts.
classNamestringExtra classes for the dialog card (or the sheet), merged last. Other props (aria-*, data-*, style, onOpenAutoFocus, onEscapeKeyDown, ref) go to the same element.
Examples
Apple and other notation
platform="apple" shows ⌘ ⇧ glyphs, "other" spells Ctrl and Shift; auto picks by device.
Small cheat sheet
One column, no search, a medium dialog for a single screen's keys.
Descriptions on rows
A muted line under a label explains what the key does; a custom hint in the footer.
Phone sheet
What it becomes below 768px (a static replica of the sheet).
From a user menu
Controlled open: a menu entry opens it, the way touch-only people reach it.
Outline keys, extra large
kbdVariant="outline", kbdSize="md", size="xl", radius="md", and the Ctrl notation forced.
Dependencies
Files
- components/ui/shortcuts-dialog.tsx
FAQ
Is the React Shortcuts Dialog component free?
The preview, props and docs are free; copying the source needs a Pro plan. See plans.
How do I install Shortcuts Dialog?
Run npx wingo-ui@latest add shortcuts-dialog. It also adds the Wingo UI items it builds on (UIProvider, Dialog, Input, Kbd, useControllableState and 4 more) and the npm packages motion and lucide-react. With shadcn, add the @wingo-ui registry with your API key, then run npx shadcn@latest add @wingo-ui/shortcuts-dialog.
How does Shortcuts Dialog behave on phones?
A bottom sheet below 768px (one column, search pinned). false keeps the centered card on phones. The responsive prop controls this and is on by default.