Skip to Content
Notion UI

Command

A dialog-only command palette built on the autocomplete primitive.

Command Dialog

<>
  <Button size="sm" onClick={() => setOpen(true)}>
    Open command
  </Button>
  <CommandDialog
    open={open}
    onOpenChange={setOpen}
    items={actions}
    itemToStringValue={(action) => action.label}
    title="Workspace command palette"
  >
    <CommandInput placeholder="Search actions..." />
    <CommandList>
      <CommandGroup heading="Actions">
        <CommandCollection>
          {(action) => (
            <CommandItem
              key={action.value}
              value={action}
              label={action.label}
              icon={action.icon}
              onClick={() => setOpen(false)}
            >
              <MenuItemAction className="flex items-center gap-2 text-xs text-muted">
                <span>{action.section}</span>
                <span>{action.shortcut}</span>
              </MenuItemAction>
            </CommandItem>
          )}
        </CommandCollection>
      </CommandGroup>
      <CommandEmpty>No commands found.</CommandEmpty>
    </CommandList>
  </CommandDialog>
</>

Installation

pnpm add @notion-kit/ui

Anatomy

<CommandDialog>
  <CommandInput />
  <CommandList>
    <CommandGroup>
      <CommandCollection>
        <CommandItem />
      </CommandCollection>
    </CommandGroup>
    <CommandEmpty />
  </CommandList>
</CommandDialog>

API Reference

CommandDialog

The dialog-only command palette root. It wraps Dialog and an always-open inline Autocomplete.

Use CommandDialog for command palettes. Use Autocomplete directly for popover menus.

Prop

Type

CommandInput

The command search input extends AutocompleteInput, including its built-in search icon and native clear button.

default renders a bordered field with inset spacing. flat renders a full-width header with a bottom divider. Both styles include the search icon and native clear button.

Prop

Type

The former search and clear props are removed.

CommandList

The scrollable command result list. Extends AutocompleteList.

CommandCollection

Renders filtered command items from CommandDialog.

Prop

Type

CommandGroup

Groups related command items.

Prop

Type

For flat command palettes, do not pass items to CommandGroup; let CommandCollection read from CommandDialog.

CommandItem

A single command row. Extends AutocompleteItem.

Prop

Type

Use MenuItemAction as trailing content for metadata or multi-part shortcuts.

CommandEmpty

Content shown only when the filtered command result set is empty.

CommandSeparator

A visual divider between command groups.

CommandShortcut

Displays a keyboard shortcut hint aligned to the right of a command item.

On this page