---
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 window 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 window 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>/meadow-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 { useState } from 'react';
import { CommandGroup, CommandItem, CommandSeparator } from '@/components/ui/goop/command';
import {
  CommandPalette,
  CommandPaletteContent,
  CommandPaletteTrigger,
} from '@/components/ui/goop/command-palette';
import { IconButton, IconButtonIcon } from '@/components/ui/goop/icon-button';

function QuickOpen() {
  const [place, setPlace] = useState('Inbox');
  return (
    <div className="flex items-center gap-2">
      <CommandPalette>
        <CommandPaletteTrigger asChild>
          <IconButton aria-label="Search or run a command">
            <IconButtonIcon icon="search" />
          </IconButton>
        </CommandPaletteTrigger>
        <CommandPaletteContent
          aria-label="Commands"
          searchPlaceholder="Search or run a command..."
          hint={['⌘', 'K']}
          empty="No command found"
        >
          <CommandGroup heading="Go to">
            {['Inbox', 'Calendar', 'Archive'].map((name) => (
              <CommandItem key={name} icon={name === 'Inbox' ? 'inbox' : 'folder'} onSelect={() => setPlace(name)}>
                {name}
              </CommandItem>
            ))}
          </CommandGroup>
          <CommandSeparator />
          <CommandGroup heading="Create">
            <CommandItem icon="file-text">New note</CommandItem>
          </CommandGroup>
        </CommandPaletteContent>
      </CommandPalette>
      <span className="text-sm text-muted-foreground">In {place}</span>
    </div>
  );
}
```

- Fits: frame: sidebar-search; frame: sidebar-head.
- Also known as: CommandDialog.
- width, padding, gap, corner, background, text: 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)

### Parts

- `CommandPaletteTrigger` — The button that opens the palette; wrap your own button in it with asChild, or use it bare; takes asChild
- `CommandPaletteContent` — The window (a modal `dialog`, name it with `aria-label`; `aria-modal` while its root is modal), centred over the scrim; 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-content, command-palette-input-shortcut, command-palette-trigger

## Keyboard

- ⌘K / Ctrl+K: open the palette from anywhere on the page, a text field too; again, close it
- typing: narrow the rows to those that match, the first of them lit
- ArrowDown / ArrowUp: move the active row, skipping a disabled one
- Enter: run the active row and close the palette
- Escape: close the palette; the focus goes back to what had it
- Tab / Shift+Tab: stay on the search field: the palette is modal and the field its one tab stop

## Accessibility

- The part itself answers the keys above.

## 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

- [Command](/themes/meadow/components/command): A list of actions or options narrowed by typing.
- [Icon button](/themes/meadow/components/icon-button): A button whose one visible label is a pack icon, for toolbars, rows and headers, with a spoken name.
- [Toast](/themes/meadow/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/meadow/components/notification-center): A bell button with an unread count that opens a panel of notifications.
