Command Center
NewCommand palette with nested pages, recent commands, async providers and match highlighting.
Or as an overlay: press ⌘K or
Installation
$ pnpm dlx shadcn@latest add @synccn/command-centerFirst time in this project? Connect synccn with one command.
Usage
import { CommandCenter, CommandCenterDialog } from "@/components/ui/command-center";<CommandCenterDialog open={open} onOpenChange={setOpen} providers={providers} />API reference
Generated from the component's TypeScript types, so it always matches the code.
CommandCenter
Command palette engine: grouped results from several providers (fixed or async), nested pages, recent commands, match highlighting and full keyboard control. Use it inline, or in CommandCenterDialog for a ⌘K overlay.
- providersrequired
CommandProvider[]Where commands come from.
- onSelect
(item: CommandItem) => voidCalled after any command is chosen (except opening a sub-page).
- placeholder
stringDefault
"Type a command or search…"Search box placeholder.
- recentsKey
stringRemember recently used commands under this localStorage key.
- maxRecents
numberDefault
5How many recent commands to show.
- autoFocus
booleanDefault
trueFocus the search box on mount.
- className
stringExtra classes for the root element.
CommandCenterDialog
CommandCenter in a centred overlay, with ⌘K to open, Escape to close and focus kept inside.
- openrequired
booleanControlled open state.
- onOpenChangerequired
(open: boolean) => voidCalled to open or close.
- hotkey
booleanDefault
trueOpen with ⌘K / Ctrl+K. Default true.
- providersrequired
CommandProvider[]Where commands come from.
- onSelect
(item: CommandItem) => voidCalled after any command is chosen (except opening a sub-page).
- placeholder
stringSearch box placeholder.
- recentsKey
stringRemember recently used commands under this localStorage key.
- maxRecents
numberHow many recent commands to show.
- autoFocus
booleanFocus the search box on mount.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Helpers
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for ChevronLeft, ChevronRight, Clock, Loader2, Search
Keyboard
- ↓or↑Move through results
- EnterRun a command or open its page
- BackspaceGo back a page when the search is empty
- EscGo back a page, or close the dialog
- Ctrl+Kor⌘KOpen or close the dialog
Accessibility
- The search box is a combobox that points at the active option with aria-activedescendant.
- Results are a listbox with options in labelled groups.
- The dialog traps focus, locks page scroll and returns focus when closed.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: combobox, dialog, group, listbox, option
- ARIA attributes: aria-activedescendant, aria-autocomplete, aria-controls, aria-expanded, aria-label, aria-modal, aria-selected
- Keys handled: ArrowUp, ArrowDown, Home, End, Enter, Escape, Backspace
- Keeps keyboard focus inside while open, and returns it when closed
- Stops the page behind from scrolling while open
- Shows a visible focus ring for keyboard users