Components · Navigation
Command Palette
StableAdded v0.0.1
A searchable command menu in a modal dialog (cmdk), with nested pages, recents and an optional Cmd+K shortcut.
import { CommandPalette } from '@nexub/react';Usage
Use it for
Power users jumping to pages or running actions by name
A global Cmd+K entry point in an app
Use something else for
Filtering a single list on the page: use `SearchInput` or `Combobox`
The only way to reach an action: keep it in the visible UI too
Playground
Props
scrollLock
<CommandPalette.Root open={open} onOpenChange={setOpen}>…</CommandPalette.Root>Examples
Default
Nested pages
States
defaultloading
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| open / onOpenChange | boolean / (open: boolean) => void | — | Controlled open state. |
| defaultOpen | boolean | — | Uncontrolled initial open state. |
| shortcut | string | — | A letter that toggles the palette with Cmd (macOS) or Ctrl anywhere on the page, e.g. 'k'. |
| label | string | 'Command palette' | Accessible name of the dialog. Defaults to the localised "Command palette". |
| shouldFilter | boolean | true | Set false when the items are already filtered, e.g. async search results. |
| loading | boolean | — | Shows a loading row and hides Empty. |
| pages | string[] | — | The open page stack (ids of CommandPalette.Page), deepest last. Empty = the root page. |
| defaultPages | string[] | — | The open page stack (ids of CommandPalette.Page), deepest last. Empty = the root page. |
| onPagesChange | ((pages: string[]) => void) | — | The open page stack (ids of CommandPalette.Page), deepest last. Empty = the root page. |
| recentKey | string | — | Opt-in recents: the last picks on the root page are kept in localStorage under this key and shown while the query is empty. |
| recentLimit | number | 5 | Opt-in recents: the last picks on the root page are kept in localStorage under this key and shown while the query is empty. |
| scrollLock | 'style' | 'class' | 'class' | 'class' (strict-CSP safe) or Radix's style-tag lock. |
| CommandPalette.Input / List / Empty / Group / Separator | compound | — | Search field, results list, no-results row, a headed group (heading), and a decorative divider. |
| CommandPaletteItem page | string | — | Opens the CommandPalette.Page with this id when selected. Other props are cmdk Command.Item props (onSelect, value, keywords, disabled). |
| CommandPalettePage id / title | string | — | Content shown only while this page is on top. No id = the root page; title shows in the input breadcrumb. Backspace on an empty query goes back. |
| className | string | — | |
| sheet | false | true | 'auto' | 'auto' (pass `sheet={false}` to keep a popover on small screens) | true: bottom sheet. 'auto': bottom sheet below the md breakpoint, centred above. |
Accessibility
ARIA roles
dialogcomboboxlistboxoption
Keyboard
- Cmd/Ctrl + shortcut
Toggles the palette when `shortcut` is set.
- Arrow Up / Down
Moves through items (wraps).
- Enter
Runs the highlighted item.
- Backspace
On an empty query, goes back a page.
- Escape
Closes the palette.
Focus
Focus moves to the input on open and returns to the previously focused element on close.
On iOS & Android
Web only
Command Palette has no @nexub/react-native twin. On phones, follow the platform pattern instead, or compose it from the native components listed on the React Native page.