---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Command palette

A layer of commands under a search field, opened over the app by a key chord such as Cmd K, to run an action by typing its name, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `CommandPalette`.

## Try it

Open the palette from its button or with ⌘K / Ctrl+K from anywhere on the page, type to filter, move with the arrows and run a command with Enter or a click: make a note, go to a place, switch the compact view. What you type is read back under it. Escape or the chord again closes it, the focus back where it was.

The places and notes are words in the page; nothing is saved.

## When to use

- A layer of commands under a search field, opened over the app by a key chord such as Cmd K, to run an action by typing its name.
- Also called: command menu, ⌘K menu or quick switcher.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Command palette on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-command-palette.json --yes
```

```text
Add the Goop Command palette to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { CommandPalette, CommandPaletteTrigger, CommandPaletteContent } from '@/components/ui/goop/command-palette';
import { IconButton, IconButtonIcon } from '@/components/ui/goop/icon-button';
import { CommandGroup, CommandItem } from '@/components/ui/goop/command';

<CommandPalette>
  <CommandPaletteTrigger asChild>
    <IconButton variant="ghost" aria-label="Search everything">
      <IconButtonIcon icon="search" />
    </IconButton>
  </CommandPaletteTrigger>
  <CommandPaletteContent aria-label="Search everything" searchPlaceholder="Search or run a command" empty="No results">
    <CommandGroup heading="Go to">
      <CommandItem onSelect={openSettings}>Settings</CommandItem>
      <CommandItem>Inbox</CommandItem>
    </CommandGroup>
  </CommandPaletteContent>
</CommandPalette>
```

- Fits: frame: sidebar-search; frame: sidebar-head.
- Also known as: CommandDialog.
- height, width, padding, gap, border, background, text, motion: add no class for these.

## API reference

### Options

- `shortcut?: `mod+${string}` | false = 'mod+k'` — The chord that opens and closes it, `mod+<key>` (mod: ⌘ on a Mac, Ctrl elsewhere); `false` turns it off.
- `open?: boolean`
- `defaultOpen?: boolean = false`
- `onOpenChange?: (open: boolean) => void`
- `modal?: boolean = true`

- Takes every prop of CommandPopover (its page: command.md)
- State: open (open / defaultOpen / onOpenChange); drawn by data-focus-visible, data-disabled

### Parts

- `CommandPaletteTrigger` — The button that opens the palette; wrap your own button in it with asChild, or use it bare; takes asChild
- `CommandPaletteContent` — The panel (a modal `dialog`, name it with `aria-label`; `aria-modal` while its root is modal); searchPlaceholder?: string — The search field's placeholder words, which also name it; hint?: ReactNode | readonly ReactNode[] — The key hint at the field's end: one key's words, or several keys'; searchLabel?: string — The search field's spoken name: its placeholder words when left out, else "Search"; empty?: ReactNode = 'No results' — The words shown while no row matches; `null` for none; filter?: (value: string, search: string, keywords?: string[]) => number — Scores a row against the typed words, 0 to 1 (0 hides it, the highest first); a fuzzy match when left out; shouldFilter?: boolean — `false` turns the matching off: the list shows the rows you render (match them on `inputValue`); inputValue?: string — The search field's typed words, when you hold them; onInputValueChange?: (words: string) => void — Called with the typed words as they change; also takes container?: HTMLElement | null; closeOnSelect?: boolean = true

- data-slot values (to select a part by): command-palette-input-group, command-palette-input-row, command-palette-input-shortcut, command-palette-trigger

## Accessibility

- focus-visible: the attribute data-focus-visible
- disabled: the attribute data-disabled

## Motion

- The part sets its own motion: add no transition or animation of your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Icon button](/themes/trail/components/icon-button): A button whose only visible label is one icon, for toolbars, rows and headers.
- [Command](/themes/trail/components/command): A list of actions or options narrowed by typing.
- [Toast](/themes/trail/components/toast): A short notice at a corner of the app that confirms an action and goes by itself, with an optional action such as Undo.
- [Notification center](/themes/trail/components/notification-center): The bell at the end of the top bar, and its panel of notifications.
