Command

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

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.

PropTypeDefaultDescription
openboolean-Whether the dialog is open.
onOpenChange(open: boolean) => void-Handler called when the dialog opens or closes.
itemsItem[] | { items: Item[] }[]-Items filtered by the internal autocomplete.
itemToStringValue(item: Item) => string-Converts object items to searchable text.
filterBase UI filter function-Optional custom filter. Prefer the internal filter by default.
filteredItemsItem[] | { items: Item[] }[]-Controlled filtered result set.
titlestring"Command Palette"Accessible dialog title rendered in an sr-only header.
descriptionstring"Search for a command to run..."Accessible dialog description.
classNamestring-Classes applied to the dialog content.

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.

PropTypeDefaultDescription
placeholderstring-Placeholder text for the command input.
variant"default" | "flat""default"Bordered field or full-width header with a bottom divider.
classNamestring-Classes for the styled field container.

The former search and clear props are removed.

CommandList

The scrollable command result list. Extends AutocompleteList.

CommandCollection

Renders filtered command items from CommandDialog.

PropTypeDefaultDescription
children(item, index) => ReactNode-Renderer for each filtered item.

CommandGroup

Groups related command items.

PropTypeDefaultDescription
headingReact.ReactNode-Optional group heading.
itemsItem[]-Group items for grouped root data.

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

CommandItem

A single command row. Extends AutocompleteItem.

PropTypeDefaultDescription
valueItem-The command value selected by Base UI.
labelReact.ReactNodeString(value)The main command label.
iconReact.ReactNode-An optional leading icon.
descstring-An optional description below the label.
variant"default" | "secondary" | "sidebar" | "warning" | "error""default"The visual style of the item.
shortcutReact.ReactNode-Shortcut rendered with CommandShortcut.
disabledboolean-Whether the command is disabled.
onClickReact.MouseEventHandler<HTMLElement>-Handler called when the item is clicked.

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.