Skip to content
nexubDesign System
v11.9.0

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';
View as Markdown

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
TSX
<CommandPalette.Root open={open} onOpenChange={setOpen}>…</CommandPalette.Root>

Examples

Default

Nested pages

States

  • default
  • loading

Props

Props
PropTypeDefaultDescription
open / onOpenChangeboolean / (open: boolean) => void—Controlled open state.
defaultOpenboolean—Uncontrolled initial open state.
shortcutstring—A letter that toggles the palette with Cmd (macOS) or Ctrl anywhere on the page, e.g. 'k'.
labelstring'Command palette'Accessible name of the dialog. Defaults to the localised "Command palette".
shouldFilterbooleantrueSet false when the items are already filtered, e.g. async search results.
loadingboolean—Shows a loading row and hides Empty.
pagesstring[]—The open page stack (ids of CommandPalette.Page), deepest last. Empty = the root page.
defaultPagesstring[]—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.
recentKeystring—Opt-in recents: the last picks on the root page are kept in localStorage under this key and shown while the query is empty.
recentLimitnumber5Opt-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 / Separatorcompound—Search field, results list, no-results row, a headed group (heading), and a decorative divider.
CommandPaletteItem pagestring—Opens the CommandPalette.Page with this id when selected. Other props are cmdk Command.Item props (onSelect, value, keywords, disabled).
CommandPalettePage id / titlestring—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.
classNamestring—
sheetfalse | 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