Command Menu
⌘K-style filterable, keyboard-navigable command palette.
Basic
Type to filter; items with a group are listed under its heading. Choosing one runs its onSelect and closes the palette.
- Each item takes id, label and onSelect, plus optional group, icon, shortcut (display only - bind the key yourself) and searchText for extra search terms
- open and onOpenChange are optional: omit them and the palette keeps its own state, starting from defaultOpen. It renders no trigger and binds no shortcut, so a palette opened from a button or ⌘K stays controlled, as here
Trigger with a shortcut hint
Kbd renders a single keyboard key/shortcut token - pair it with a visible trigger so the ⌘K chord is discoverable, not the only way in.
- items also accept a shortcut string, rendered next to each command's label inside the palette
When to use
- App-wide quick navigation or actions triggered by a keyboard shortcut (⌘K) - jumping to pages, running commands, switching context.
- A searchable list long enough that scanning isn't practical - filtering narrows it as the user types.
When not to use
- A short, fixed action list tied to one trigger - a plain Dropdown Menu is lighter.
- Primary navigation that should always be visible - this is a supplementary, opt-in shortcut, not a nav replacement.
Keyboard
Mobile behavior
- Opens the same way as desktop (via the trigger button; the ⌘K shortcut itself is a desktop-keyboard convenience), and the on-screen keyboard opens immediately since the input is focused on open.
- The panel is width-clamped and vertically scrollable so a long, filtered result list doesn't overflow a short viewport.
Accessibility notes
- Composed from Dialog under the hood, so it inherits focus trap, Escape-to-close, and focus-return-to-trigger for free.
- Items are grouped visually by the group field; each group is exposed as its own labeled region for screen reader users.
Common mistakes
- Wiring the ⌘K shortcut listener but forgetting to also expose a visible trigger button - keyboard-shortcut-only entry points are undiscoverable and inaccessible to users who can't use that chord.
- Putting hundreds of items in one flat group - use group to organize a long list instead of one long unbroken scroll.
Known limitations
- No built-in async/remote data loading - items must already be in memory; filter debouncing for a remote source is left to the consumer.
Related components
API reference
Everything searchable. Filtering happens here, not in the consumer.
Uncontrolled initial open state. Default false. Lets a demo or a ⌘K-only palette skip carrying its own `useState`.
Key toggling the palette with ⌘ or Ctrl (`"k"` = ⌘K/Ctrl+K, no UA sniffing). Off by default. Skips keydowns already `preventDefault()`ed and blocks the browser's own binding.
Called whenever the palette opens or closes, including via ⌘K and Escape.
Controlled open state. Omit to let the component own it.
Text in the search input while it is empty.
Coding agents read this reference, with its examples, from the version your project has installed, through the Fuji UI MCP server. Set up your agent
