What it does
Render a portal dialog with a search input, grouped items, separators, and an empty state.
Filtering, active-item tracking, and keyboard navigation are handled internally.
Composition and API
Compose Command with CommandTrigger, CommandContent, CommandInput, CommandList, CommandGroup, CommandItem, CommandSeparator, CommandEmpty, and CommandFooter. Use appearance and size variants for visual tone, and the hotkey prop for a global shortcut.
Common use cases
- Global Cmd+K navigation across pages and resources.
- Quick action launchers in dashboards and developer tools.
- Searchable menus that combine navigation and commands.
- Keyboard-driven workflows for power users.
Accessibility
The palette renders role=dialog with aria-modal, traps focus while open, restores focus on close, and exposes the input as a combobox with role=option items. Provide a label for the dialog.
Next.js integration notes
Use Command inside client components since it manages open state and key handlers in the browser. The base entry stays free of framer-motion; import CommandContentAnimated only where you want motion.
FAQ
Does Command support a global Cmd+K shortcut?
Yes. Set the hotkey prop (defaults to k) and the palette binds meta/ctrl + key to toggle open from anywhere.
How does keyboard navigation work?
Arrow Up and Down move the active item, Enter selects it and fires onSelect, and Escape closes the palette. Typing filters items by value and keywords.
Is there an animated command palette?
Yes. Import CommandContentAnimated from the animated entrypoint to spring the palette in; it falls back to a fade when reduced motion is preferred.