---
title: "Command"
description: "A search field over a list of commands. People type a few letters to find an action or a page, as in a command palette or a quick switcher."
url: https://gelatinui.com/components/command
markdown_url: https://gelatinui.com/components/command.md
access: free
install: "npx shadcn@latest add @gelatin-ui/command"
registry_item: https://gelatinui.com/r/command.json
version: "2026-11-08"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Command

> A search field over a list of commands. People type a few letters to find an action or a page, as in a command palette or a quick switcher.

Page: https://gelatinui.com/components/command

## When to use it

Best for: A search field over a list of commands, for a palette or a quick switcher.

- Use `CommandDialog` for a palette over the page.
- Use `size="lg"` for a Spotlight look.
- Pass `items` for the data pattern.

## When not to use it

- For a value in a form, use a [Combobox](https://gelatinui.com/components/combobox.md).
- For a list that opens from a button, use a [Menu](https://gelatinui.com/components/menu.md).

## Notes for agents

- It is built on Base UI Autocomplete, not on `cmdk`.
- The first match is always lit, so Enter runs it.
- Parts keep the shadcn names, so copied code keeps its structure.

## Anatomy

```text
Command
├─ CommandDialog (0..n)
├─ CommandInput (0..n)
├─ CommandList (0..n)
├─ CommandEmpty (0..n)
├─ CommandGroup (0..n)
├─ CommandCollection (0..n)
├─ CommandItem (0..n)
├─ CommandShortcut (0..n)
├─ CommandSeparator (0..n)
└─ CommandFooter (0..n)
```

## API reference

### Command

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` | `readonly ItemValue[]` |  | The data to filter: a flat array, or groups (`{ value, items }`). Nullish entries are not allowed. |
| `size` | `"default" \| "lg"` | "default" | `default`, or `lg` for a Spotlight-style palette: a 44px search row with a 20px icon, 36px rows with 8px padding and gaps, a 6px list inset, and a 36px footer. Text stays 14px. The parts read it from the root (`data-size`). |

Also takes every prop of Base UI `Combobox.Root`: https://base-ui.com/react/components/combobox

### CommandDialog

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `showCloseButton` | `boolean` | false | Show the corner close button. Default `false`: Escape closes the palette. |
| `closeLabel` | `string` | "Close" | The accessible name of the close button. Translate it with the page. |
| `container` | `union` |  | The element the dialog portals into (Base UI `Dialog.Portal` `container`). |
| `children` | `ReactNode` |  |  |

Also takes every prop of Base UI `Dialog.Root`: https://base-ui.com/react/components/dialog

### CommandInput

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `showClear` | `boolean` | true | Show the clear button while the field has text. Default `true`. |
| `clearLabel` | `string` | "Clear search" | The accessible name of the clear button. Translate it with the page. |

Also takes every prop of Base UI `Combobox.Input`: https://base-ui.com/react/components/combobox

### CommandList

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

Also takes every prop of Base UI `Combobox.List`: https://base-ui.com/react/components/combobox

### CommandEmpty

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### CommandGroup

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `heading` | `ReactNode` |  | The group name (the shadcn `heading`): the shared popup group label, 12/16 weight 500 muted. |

Also takes every prop of Base UI `Combobox.Group`: https://base-ui.com/react/components/combobox

### CommandCollection

Also takes every prop of Base UI `Combobox.Collection`: https://base-ui.com/react/components/combobox

### CommandItem

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

Also takes every prop of Base UI `Autocomplete.Item`: https://base-ui.com/react/components/autocomplete

### CommandShortcut

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### CommandSeparator

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

Also takes every prop of Base UI `Autocomplete.Separator`: https://base-ui.com/react/components/autocomplete

### CommandFooter

No props of its own: `className`, `children`, and every other prop go to the element it renders.

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| Command | `command` |  |  |  |
| CommandDialog | `command-dialog` |  |  |  |
| CommandInput | `command-input` | `data-part`, `data-size` |  |  |
| CommandList | `command-list` | `data-empty`, `data-size` |  |  |
| CommandEmpty | `command-empty` |  |  |  |
| CommandGroup | `command-group` | `data-size` |  |  |
| CommandCollection | `command-collection` |  |  |  |
| CommandItem | `command-item` | `data-size` |  |  |
| CommandShortcut | `command-shortcut` |  |  |  |
| CommandSeparator | `command-separator` |  |  |  |
| CommandFooter | `command-footer` | `data-size` |  |  |

## Usage

Compose the search and the list.

```tsx title="palette.tsx"
import {
  Command,
  CommandEmpty,
  CommandInput,
  CommandItem,
  CommandList,
} from "@/components/ui/command";

const ITEMS = ["New file", "Open settings"];

export function Palette() {
  return (
    <Command items={ITEMS}>
      <CommandInput placeholder="Search" />
      <CommandEmpty>No results.</CommandEmpty>
      <CommandList>
        {(item: string) => {
          return (
            <CommandItem key={item} value={item}>
              {item}
            </CommandItem>
          );
        }}
      </CommandList>
    </Command>
  );
}
```

## Compose

Build it with:

- [Kbd](https://gelatinui.com/components/kbd.md): Shows the shortcut that opens it.
- [Empty](https://gelatinui.com/components/empty.md): Shows when no result matches.

Rules:

- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.
- Steady text weight (`steady-weight`): Never change the font weight on hover, focus, selected, active, or open; change the color or the fill, so the text does not jump.
- Sheets on phones (`phone-sheets`): Show a dialog or a large popover as a bottom sheet on a small screen.
- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.

Patterns: `gelatin://patterns/command-search`

## Add it

```bash
npx shadcn@latest add @gelatin-ui/command
```

It adds 42 registry items: 39 files, 7714 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Autocomplete](https://gelatinui.com/components/autocomplete.md)
- [Dialog](https://gelatinui.com/components/dialog.md)
- [Menu](https://gelatinui.com/components/menu.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Animated Close Icon](https://gelatinui.com/components/animated-close-icon.md)
- [Autocomplete](https://gelatinui.com/components/autocomplete.md): Pick Autocomplete for a text field in a form that suggests values while people type.
- [Dialog](https://gelatinui.com/components/dialog.md)
- [Menu](https://gelatinui.com/components/menu.md): Pick Menu for a short list of actions that opens from a button, with no search field.
- [Combobox](https://gelatinui.com/components/combobox.md): Pick Combobox for a value in a form that must be one item from the list.
- [Search Field](https://gelatinui.com/components/search-field.md): Pick Search Field for a plain search query in one line that filters a page, with no list of commands.

## Keyboard

| Keys | Action |
| --- | --- |
| Up, Down | Moves the lit row. |
| Enter | Runs the lit row. |
| Escape | Closes the dialog. |
