nook
Browse the docs

Components

Shortcut dialog

Built on Base UI

A searchable, grouped reference for application keyboard shortcuts.

See the prompt

Installation

npx nook-ui@latest add shortcut-dialog

Prompt

Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.

Short. For assistants that can run commands in your project.

Plain text
Add the Nook "Shortcut dialog" component to this project, exactly as Nook ships it.

A searchable, grouped reference for application keyboard shortcuts.

Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add shortcut-dialog`. It writes `components/ui/shortcut-dialog.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/shortcut-dialog.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:

```tsx
import { ShortcutDialog } from "@/components/ui/shortcut-dialog";
export default function Example() {
  return (
    <ShortcutDialog
      items={[
        {
          id: "search",
          label: "Search the workspace",
          keys: "mod+k",
          group: "Navigation",
        },
        {
          id: "home",
          label: "Go to projects",
          keys: "alt+p",
          group: "Navigation",
        },
        { id: "new", label: "Create a task", keys: "n", group: "Tasks" },
        { id: "save", label: "Save changes", keys: "mod+s", group: "Editing" },
        {
          id: "undo",
          label: "Undo last change",
          keys: "mod+z",
          group: "Editing",
        },
        {
          id: "help",
          label: "Show keyboard shortcuts",
          keys: "shift+/",
          group: "Help",
        },
      ]}
    />
  );
}
```

API
- `ShortcutDialog`: A searchable, grouped reference for application keyboard shortcuts.
  - `items` (`ShortcutEntry[]`): IDs, action labels, keys and optional groups.
  - `open / defaultOpen` (`boolean`): Controlled or initial visibility.
  - `onOpenChange` (`(open: boolean) => void`): Visibility changes.
  - `triggerLabel` (`string`, default Keyboard shortcuts): Trigger button label.

Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Base UI traps and returns focus; actions use description-list semantics and Shortcut key labels.

Done when the component renders like the example in light and dark mode and the project type-checks.

Usage

import { ShortcutDialog } from "@/components/ui/shortcut-dialog";
export default function Example() {
  return (
    <ShortcutDialog
      items={[
        {
          id: "search",
          label: "Search the workspace",
          keys: "mod+k",
          group: "Navigation",
        },
        {
          id: "home",
          label: "Go to projects",
          keys: "alt+p",
          group: "Navigation",
        },
        { id: "new", label: "Create a task", keys: "n", group: "Tasks" },
        { id: "save", label: "Save changes", keys: "mod+s", group: "Editing" },
        {
          id: "undo",
          label: "Undo last change",
          keys: "mod+z",
          group: "Editing",
        },
        {
          id: "help",
          label: "Show keyboard shortcuts",
          keys: "shift+/",
          group: "Help",
        },
      ]}
    />
  );
}

Examples

Grouped shortcuts

Open on load

Props

ShortcutDialog

A searchable, grouped reference for application keyboard shortcuts.

PropTypeDefaultDescription
itemsShortcutEntry[]–IDs, action labels, keys and optional groups.
open / defaultOpenboolean–Controlled or initial visibility.
onOpenChange(open: boolean) => void–Visibility changes.
triggerLabelstringKeyboard shortcutsTrigger button label.

Accessibility

Base UI traps and returns focus; actions use description-list semantics and Shortcut key labels.

Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.