Dropdown
Command Menu
NewA search field that opens a ⌘K command palette with grouped commands, shortcuts and nested pages.
npx motionsnack add command-menuCustomize
<CommandMenu />Props
19 properties
| Property | Type | Default | Description |
|---|---|---|---|
| groups | { heading: string; items: { id: string; label: string; description?: string; icon?: string; shortcut?: string[]; keywords?: string[]; children?: Item[] }[] }[] | Pages, Actions, Settings demo | Groups of items. An item with children opens a nested page instead of running. |
| onSelect | (item) => void | - | Called with the item the visitor runs. |
| open | boolean | - | Open state (controlled). |
| defaultOpen | boolean | false | Open state at first render (uncontrolled). |
| onOpenChange | (open: boolean) => void | - | Called whenever the palette opens or closes. |
| query | string | - | Search text (controlled). |
| defaultQuery | string | '' | Search text at first render (uncontrolled). |
| onQueryChange | (query: string) => void | - | Called on every keystroke. |
| loading | boolean | false | Remote results are loading: spinner after 500ms, list dimmed. |
| hotkey | string | 'mod+k' (from shortcut) | Global key that toggles the palette; mod = ⌘ on Mac, Ctrl elsewhere. |
| className | string | '' | Extra classes on the wrapper. |
| placeholder | string | 'Search or jump to…' | Text in the trigger. |
| searchPlaceholder | string | 'Type a command or search…' | Hint in the search box of the palette. |
| emptyText | string | 'No results for "{query}"' | Text shown when nothing matches. {query} is the typed text. |
| shortcut | string | 'K' | Letter of the ⌘ / Ctrl shortcut that opens the palette. Empty turns it off and hides the hint. |
| showFooter | boolean | true | Show the row of key hints at the bottom of the palette. |
| disabled | boolean | false | Disables the trigger and the shortcut. |
| height | number | 48 | Height of the trigger. |
| radius | number | 12 | Corner radius of the trigger. |
About Command Menu
Command Menu gives a site or an app one place to jump anywhere and do anything. The trigger looks like the library's search field with a ⌘K hint, and the shortcut opens the palette from anywhere on the page: the page behind softly blurs and a panel comes in from a blur at the top of the screen. Commands sit in groups with small headings, each with an icon, an optional second line and its own keyboard shortcut, and they appear one after another as the palette opens. Typing narrows the list word by word and shows the matching letters in full contrast; a command with children opens a nested page in place, shown as a chip in the search row, and Backspace or Escape steps back. Arrow keys, Home, End and Enter drive it all, focus stays inside the dialog and returns to the trigger when it closes, and the page underneath does not scroll meanwhile.
What's included
- ⌘K / Ctrl+K from anywhere, platform-aware hint
- Panel and backdrop that blur in and out
- Groups, icons, descriptions and shortcut keys
- Word-by-word search with highlighted matches
- Nested pages with a breadcrumb chip and Backspace to go back
- Full keyboard control, focus trap and focus return
- Light and dark look
- Type
- Animated React dropdown component
- Library
- Components · Dropdown
- Stack
- Next.js, React, Tailwind CSS