Theme
Install with your agentnpx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-combobox.json --yes

Combobox

Pro

Pick one value from a long list by typing, for React and Tailwind CSS. Part of Goop Pro.

In the fields look, type to filter the owners (an email finds its person too), pick with the arrows and Enter, clear with the cross (an owner is required: the field is refused while empty). Search a city: the list loads for a moment after each word, then shows what the server found. Type a topic the list lacks: it is offered first and kept as a new one. The beside look sets a city combobox over a select. The chips look is a create dialog’s row of property chips: Tab to one, Enter or a letter opens it round its own search, Enter picks and the focus comes back to the chip; the assignee may be none, the reviewer shows their avatar alone, and a label no row holds is created. Each look’s line under it names the list that is open. The city search is a timer over twenty names of our own; a new topic or label lives in the page only.

When to use

  • Pick one value from a long list by typing.
  • Use Combobox for one value from a long list known by name (a country, a person), or from results fetched as they type; a short list to browse is a Select, actions a Command. Its value is always one of its rows, unless allowCustomValue keeps a person's own words (never where the value is an id).
  • Also called: autocomplete or typeahead.

When not to use

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 Combobox 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.

Terminal
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-combobox.json --yes
PROMPT
Add the Goop Combobox to this project. The install steps are at https://goop.so/docs/install.md

Usage

TSX
import { Combobox, ComboboxInput, ComboboxContent, ComboboxItem, ComboboxGroup } from '@/components/ui/goop/combobox';
import { useState } from 'react';
import { Field } from '@/components/ui/goop/field';

function NewProjectFields() {
  const members = [
    { id: 'u1', name: 'Ngozi Ilori', email: 'ngozi@fieldwork.test' },
    { id: 'u2', name: 'Yuto Sakamaki', email: 'yuto@fieldwork.test' },
  ];
  const countries = ['Belgium', 'Netherlands', 'Norway', 'Portugal'];
  const [found, setFound] = useState(countries);
  const [searching, setSearching] = useState(false);
  const search = (words: string) => {
    setSearching(true);
    // your request here; a timer stands in for it
    setTimeout(() => {
      setFound(countries.filter((name) => name.toLowerCase().includes(words.toLowerCase())));
      setSearching(false);
    }, 300);
  };
  return (
    <div className="flex flex-col gap-4">
      <Field label="Owner" orientation="vertical" className="w-full">
        <Combobox defaultValue="u1" name="owner">
          <ComboboxInput placeholder="Choose a member" />
          <ComboboxContent empty="No member found">
            {members.map((member) => (
              <ComboboxItem key={member.id} value={member.id} keywords={[member.email]}>
                {member.name}
              </ComboboxItem>
            ))}
          </ComboboxContent>
        </Combobox>
      </Field>
      <Field label="Country" orientation="vertical" className="w-full">
        <Combobox filter={false} loading={searching} onInputValueChange={search}>
          <ComboboxInput placeholder="Search countries" />
          <ComboboxContent empty="No country found">
            {found.map((name) => (
              <ComboboxItem key={name} value={name}>
                {name}
              </ComboboxItem>
            ))}
          </ComboboxContent>
        </Combobox>
      </Field>
    </div>
  );
}
  • Fits: flow, settings, record: field.
  • Also known as: Autocomplete, Typeahead, SearchableSelect, Autosuggest.
  • height, width, padding, gap, border, background, text, motion: add no class for these.

API reference

  • Each option with its sentence: combobox--options.md
  • State: value (value / defaultValue / onValueChange); inputValue (inputValue / defaultInputValue / onInputValueChange); open (open / defaultOpen / onOpenChange); drawn by data-focus-visible, data-state=open, data-disabled
Parts
PartWhat it is
ComboboxInputThe field a person types into
ComboboxContentThe open list
ComboboxItemOne row of the list
ComboboxGroupA group of the list's rows under its heading (12 px words at 500 in the grey); the heading is cut at the list's width and never widens it

ComboboxContent

The open list.

TSX
import { ComboboxContent } from '@/components/ui/goop/combobox';

Options

  • searchPlaceholder?: string — The chip's search field's placeholder words (shape="chip").
  • searchLabel?: string — The chip's search field's name; the combobox's label by default, else searchPlaceholder.
  • empty?: ReactNode = 'No results' — The words shown while no row matches; null for none.
  • loadingLabel?: string = 'Loading' — The words of the loading row, said as it appears.
  • customLabel?: (words: string) => string — The row offering the words typed (allowCustomValue); Use “<words>” by default.
  • noneRowLabel?: string — The row that sets an optional combobox back to none; "No <label>", else "Clear", by default.
  • createLabel?: (words: string) => string — The row offering to create the words searched for (onCreate); Create “<words>” by default.
  • creatingLabel?: (words: string) => string — The loading row while a create's promise waits; Creating “<words>” by default.
  • Also takes: container?: HTMLElement | null

ComboboxGroup

A group of the list's rows under its heading (12 px words at 500 in the grey); the heading is cut at the list's width and never widens it.

TSX
import { ComboboxGroup } from '@/components/ui/goop/combobox';

Options

ComboboxInput

The field a person types into.

TSX
import { ComboboxInput } from '@/components/ui/goop/combobox';

Options

  • clearable?: boolean = true — Shows the clear button while the field holds words or a chosen value.
  • clearLabel?: string — The clear button's name; "Clear" and the field's own name by default.
  • readOnly?: boolean — Shows the value without letting it change: focusable and copyable, with no clear button or chevron, and nothing opens the list.
  • Also takes: name?: string; required?: boolean; disabled?: boolean; form?: string

ComboboxItem

One row of the list.

TSX
import { ComboboxItem } from '@/components/ui/goop/combobox';

Options

  • value: string — The value it picks.
  • keywords?: readonly string[] — More words the row is found by; its own words always are.
  • Also takes: onSelect?: (value: string) => void; disabled?: boolean; icon?: IconName; mark?: ReactNode

Combobox: every option

TSX
import { Combobox } from '@/components/ui/goop/combobox';

Options

  • value?: string — The chosen row's value, '' for none (controlled).
  • defaultValue?: string = '' — The value chosen at first (uncontrolled).
  • onValueChange?: (value: string) => void — Called with a row's value when it is picked, '' when the field is cleared.
  • inputValue?: string — The words in the field (controlled): what a person types, or the chosen row's words.
  • defaultInputValue?: string — The words in the field at first (uncontrolled); the chosen row's words by default.
  • onInputValueChange?: (words: string) => void — Called with the field's words as a person types (fetch your results here).
  • open?: boolean — Whether the list is open (controlled).
  • defaultOpen?: boolean = false — Whether the list is open at first (uncontrolled).
  • onOpenChange?: (open: boolean) => void — Called when the list opens or closes.
  • filter?: boolean = true — Whether the list keeps only the rows whose words or keywords hold the words typed; false when your code supplies the matching rows (a search on your server).
  • loading?: boolean = false — Shows the loading row while your results are on their way.
  • disabled?: boolean = false — Disables the field.
  • name?: string — The name a form sends the value under (a hidden field); none by default.
  • form?: string — The form the hidden field belongs to, by id, where the combobox is outside it.
  • valueLabel?: string — The chosen value's words where no row holds them (fetched results without it).
  • allowCustomValue?: boolean = false — Lets a person keep words no row says as the value (a tag, a new category).
  • aria-invalid?: boolean | 'true' | 'false' — Marks the field invalid (a FieldInvalid sets it): its edge in the danger colour.
  • shape?: 'field' | 'chip' = 'field'
  • label?: string — The chip's property, Assignee: its words while empty, the start of its name ("Assignee: Ngozi Ilori") and the search field's name.
  • icon?: IconName — The chip's icon while empty, by the pack's name (phosphor-fill:user-circle-dashed).
  • iconOnly?: boolean | 'narrow' = false — A chip as its icon alone: true always; 'narrow' while its row, which must carry the class @container/chip-row (a create dialog's does), is under 641 px.
  • noneLabel?: string = 'none' — The word the chip's name says while nothing is chosen ("Assignee: none").
  • optional?: boolean = false — The value may be none: the list opens with a row ("No assignee", noneRowLabel) that sets it back to ''.
  • onCreate?: (words: string) => string | undefined | PromiseLike<string | undefined> — Makes a row from the words searched for when no row matches: the list offers "Create “…”" (createLabel), and Enter or a click calls this with the words, trimmed.
  • State: value (value / defaultValue / onValueChange); inputValue (inputValue / defaultInputValue / onInputValueChange); open (open / defaultOpen / onOpenChange); drawn by data-focus-visible, data-state=open, data-disabled

Keyboard

KeyWhat it does
TypingOpen the list and filter its rows by their words, the first match active
ArrowDownOpen the list with the chosen row active (else the first); on an open list, the next row
Alt+ArrowDownOpen the list with no row active
ArrowUpThe row before; Alt+ArrowUp closes the list
Home EndMove the caret in the field
EnterPick the active row, show its words and close the list; on a closed field, send the form (with allowCustomValue, words typed are kept first)
EscapeClose the list, putting the chosen row's words back; on a closed field, empty it and its value
TabLeave the field picking nothing, its chosen words back (with allowCustomValue, the words typed kept); then the clear button

Accessibility

  • The native element answers the keyboard.

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.

goop.so/themes/trail/components/combobox.md · the page as Markdown
Theme
Install with your agentnpx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-combobox.json --yes

Where would you like to start?

Free · now

The Goop plugin

A design system for your AI coding agent, so screen ten matches screen one.

/plugin marketplace add goop-so/skillsthen /plugin install goop@goopCodex, Cursor, ChatGPT, the Claude app and more: Connect Goop
FreePro

The components

Every part live, with its props, its keys and what an agent sees. Whole page and app templates, working with sample data.