npx shadcn@4.23.1 add @goop/trail-commandCommand
FreeA list of actions or options narrowed by typing, for React and Tailwind CSS. Free, MIT.
What an agent sees
- CommandPopoverThe popover a filterable list opens in
- CommandPopoverAnchorWhat the panel is placed against when the opener is no trigger of its own, such as a select's trigger
- CommandPopoverTriggerThe trigger
- CommandPopoverContentThe panel, a dialog named by its aria-label, under its trigger at its start
- CommandInputThe search field that filters the rows, shown by default
- CommandListThe scrolling list of rows
- CommandEmptyThe words shown while no row matches
- CommandGroupA group of rows under its heading
- CommandSeparatorA hairline between groups, hidden while searching
- CommandShortcutA row's key hint at its end
- CommandItemOne row
import {
CommandPopover, CommandPopoverAnchor, CommandPopoverTrigger, CommandPopoverContent, Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandSeparator, CommandShortcut, CommandItem,
} from '@/components/ui/goop/command';
<Command>
<CommandInput placeholder="Type a command" aria-label="Commands" />
<CommandList>
<CommandEmpty>No results</CommandEmpty>
<CommandItem onSelect={openSettings}>Open settings</CommandItem>
</CommandList>
</Command>Type to filter the commands (“tick”, “sort”, “clear”), move with the arrows and run one with Enter or a click: the kit list beside it changes at once. The lower group ticks or unticks one item. The list lives in the page; the items added are our own sample.
When to use
- A list of actions or options narrowed by typing.
When not to use
- For a short menu with no search use DropdownMenu, and to pick a form value use Select.
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 on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.
npx shadcn@4.23.1 add @goop/trail-commandAdd the Goop Command to this project. The install steps are at https://goop.so/docs/install.mdUsage
import {
CommandPopover, CommandPopoverAnchor, CommandPopoverTrigger, CommandPopoverContent, Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandSeparator, CommandShortcut, CommandItem,
} from '@/components/ui/goop/command';
<Command>
<CommandInput placeholder="Type a command" aria-label="Commands" />
<CommandList>
<CommandEmpty>No results</CommandEmpty>
<CommandItem onSelect={openSettings}>Open settings</CommandItem>
</CommandList>
</Command>- Fits: board, inbox, list, states (their recipes).
- height, width, padding, border, background, text, motion: add no class for these.
API reference
| Option | Type | What it does |
|---|---|---|
| value? | string | |
| onValueChange? | (value: string) => void | |
| shouldFilter? | boolean |
- State: value (value / onValueChange); drawn by data-focus-visible, data-state=closed, data-selected=true, data-disabled=true
| Part | What it is |
|---|---|
| CommandPopover | The popover a filterable list opens in; also takes open?: boolean; defaultOpen?: boolean = false; onOpenChange?: (open: boolean) => void; modal?: boolean = true |
| CommandPopoverAnchor | What the panel is placed against when the opener is no trigger of its own, such as a select's trigger; also takes asChild?: boolean |
| CommandPopoverTrigger | The trigger; also takes asChild?: boolean |
| CommandPopoverContent | The panel, a dialog named by its aria-label, under its trigger at its start; container?: HTMLElement | null — Where the layer is portalled; the end of <body> when left out; closeOnSelect?: boolean = true — Whether a pick closes the popover; true by default |
| CommandInput | The search field that filters the rows, shown by default; name it with aria-label (a placeholder is no name); visible?: boolean = true — Shows the search field (the default), as a select's list does; false hides it from the eye alone (a menu that filters as it is typed into); also takes value?: string; onValueChange?: (search: string) => void; placeholder?: string |
| CommandList | The scrolling list of rows |
| CommandEmpty | The words shown while no row matches |
| CommandGroup | A group of rows under its heading |
| CommandSeparator | A hairline between groups, hidden while searching |
| CommandShortcut | A row's key hint at its end |
| CommandItem | One row; picking it calls onSelect and closes the popover; its props: command--item.md |
CommandItem
One row; picking it calls onSelect and closes the popover.
import { CommandItem } from '@/components/ui/goop/command';Options
- submenu?: boolean = false — A row that opens more: the caret at its end.
- icon?: IconName — The row's icon before its words, a pack icon by name, as a menu row's
icon. - mark?: ReactNode — The caller's own element before the words, in place of
icon(an avatar, a status's mark). - checked?: boolean — In a choice, whether this row is the chosen one (a check mark); left out, the row is no choice.
- Also takes: value?: string; onSelect?: (value: string) => void; disabled?: boolean; keywords?: string[]
Accessibility
- The behaviour layer under the part answers keys, focus and dismissal: never write your own.
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| focus-visible | the attribute data-focus-visible |
| checked | the attribute aria-checked=true |
| expanded | the attribute data-state=closed |
| open | the attribute data-state=closed |
| highlighted | the attribute data-selected=true |
| disabled | the attribute data-disabled=true |
Motion
- The part sets its own motion: add no transition or animation of your own.
- How the theme moves, and how to move your own parts the same way: Motion.
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.