npx shadcn@4.23.1 add @goop/meadow-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 field
- CommandPopoverTriggerThe trigger
- CommandPopoverContentThe panel, a dialog named by its
aria-label, under its trigger at its start, 6 px off (the menu's), shifting and flipping to stay 8 px inside the window (collisionPadding) - CommandInputThe search field that filters the rows, shown by default in its row over the list
- CommandListThe scrolling list of rows
- CommandEmptyThe words shown while no row matches
- CommandGroupA group of rows, under its
headingwhen it has one - CommandSeparatorA hairline between groups, the panel's full width, in the field hairline's faint ink, 3 px from the rows on either side
- CommandShortcutA row's key hint at its end
- CommandDescriptionA row's caption, a second line under its words
- CommandItemOne row
import { CommandPopoverAnchor, CommandSeparator, CommandShortcut, CommandDescription } from '@/components/ui/goop/command';
import { Button } from '@/components/ui/goop/button';
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandPopover,
CommandPopoverContent,
CommandPopoverTrigger,
} from '@/components/ui/goop/command';
const HABITATS = ['Grassland', 'Hedgerow', 'Wetland', 'Woodland'];
function HabitatPicker({ onPick }: { onPick: (habitat: string) => void }) {
return (
<CommandPopover>
<CommandPopoverTrigger asChild>
<Button variant="outline">Habitat</Button>
</CommandPopoverTrigger>
<CommandPopoverContent aria-label="Choose a habitat">
<Command label="Search habitats">
<CommandInput placeholder="Search habitats" />
<CommandList>
<CommandEmpty>No habitat found</CommandEmpty>
<CommandGroup heading="Habitats">
{HABITATS.map((habitat) => (
<CommandItem key={habitat} value={habitat} onSelect={() => onPick(habitat)}>
{habitat}
</CommandItem>
))}
</CommandGroup>
</CommandList>
</Command>
</CommandPopoverContent>
</CommandPopover>
);
}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, to pick a form value Combobox.
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/meadow-commandAdd the Goop Command to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { CommandPopoverAnchor, CommandSeparator, CommandShortcut, CommandDescription } from '@/components/ui/goop/command';
import { Button } from '@/components/ui/goop/button';
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandPopover,
CommandPopoverContent,
CommandPopoverTrigger,
} from '@/components/ui/goop/command';
const HABITATS = ['Grassland', 'Hedgerow', 'Wetland', 'Woodland'];
function HabitatPicker({ onPick }: { onPick: (habitat: string) => void }) {
return (
<CommandPopover>
<CommandPopoverTrigger asChild>
<Button variant="outline">Habitat</Button>
</CommandPopoverTrigger>
<CommandPopoverContent aria-label="Choose a habitat">
<Command label="Search habitats">
<CommandInput placeholder="Search habitats" />
<CommandList>
<CommandEmpty>No habitat found</CommandEmpty>
<CommandGroup heading="Habitats">
{HABITATS.map((habitat) => (
<CommandItem key={habitat} value={habitat} onSelect={() => onPick(habitat)}>
{habitat}
</CommandItem>
))}
</CommandGroup>
</CommandList>
</Command>
</CommandPopoverContent>
</CommandPopover>
);
}- height, width, padding, gap, corner, border, background, shadow, text, motion: add no class for these.
API reference
| Option | Type | What it does |
|---|---|---|
| size? | 'md' | 'lg' = 'md' | md (the default) for a popover's list; lg for a search in a dialog. |
| value? | string | |
| onValueChange? | (value: string) => void | |
| shouldFilter? | boolean |
- State: value (value / onValueChange); drawn by data-focus-visible, data-selected=true, data-state=open, 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 field; 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, 6 px off (the menu's), shifting and flipping to stay 8 px inside the window (collisionPadding); its props: command--popover-content.md |
| CommandInput | The search field that filters the rows, shown by default in its row over the list; name it with the root's label or an aria-label (a placeholder is no name); its props: command--input.md |
| CommandList | The scrolling list of rows |
| CommandEmpty | The words shown while no row matches |
| CommandGroup | A group of rows, under its heading when it has one |
| CommandSeparator | A hairline between groups, the panel's full width, in the field hairline's faint ink, 3 px from the rows on either side; hidden while searching |
| CommandShortcut | A row's key hint at its end |
| CommandDescription | A row's caption, a second line under its words |
| CommandItem | One row; picking it (Enter on the active row, or a click) calls onSelect with its value and closes the popover it is in (unless that panel says closeOnSelect={false}); its props: command--item.md |
CommandInput
The search field that filters the rows, shown by default in its row over the list; name it with the root's label or an aria-label (a placeholder is no name).
import { CommandInput } from '@/components/ui/goop/command';Options
- icon?: IconName — The field's leading icon, a pack icon by name.
- shortcut?: ReactNode — The key that opens the list, said in a cap at the field's end.
- visible?: boolean = true — Shows the search field (the default) in its row over the list;
falsehides it from the eye alone (a menu that filters as it is typed into). - Also takes: value?: string; onValueChange?: (search: string) => void; placeholder?: string
CommandItem
One row; picking it (Enter on the active row, or a click) calls onSelect with its value and closes the popover it is in (unless that panel says closeOnSelect={false}).
import { CommandItem } from '@/components/ui/goop/command';Options
- submenu?: boolean = false — A row that opens more: the pack's chevron at its end.
- icon?: IconName — The row's icon before its words, a pack icon by name.
- 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); left out, the row is no choice.
- action?: ReactNode — What Enter or a press does, at the row's end while it is the active row, with the Return key's cap.
- Also takes: value?: string; onSelect?: (value: string) => void; disabled?: boolean; keywords?: string[]
CommandPopoverContent
The panel, a dialog named by its aria-label, under its trigger at its start, 6 px off (the menu's), shifting and flipping to stay 8 px inside the window (collisionPadding).
import { CommandPopoverContent } from '@/components/ui/goop/command';Options
- 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.
Keyboard
| Key | What it does |
|---|---|
| Enter | On the trigger: open, the focus in the search field; on the active row: pick it and close, the focus back on the trigger |
| ArrowDown ArrowUp | Move the active row, past disabled rows |
| Home End | First or last row |
| Escape | Close, the focus back on the trigger |
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 |
| selected | the attribute data-selected=true |
| open | the attribute data-state=open |
| disabled | the attribute data-disabled=true |
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.