---
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/"
---

# Combobox

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

Pro. Its export: `Combobox`.

## Try it

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

- For a short list 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 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.

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

```text
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

### Parts

- `ComboboxInput` — The field a person types into
- `ComboboxContent` — The open list
- `ComboboxItem` — One row of the list
- `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

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

- Typing: open the list and filter its rows by their words, the first match active
- ArrowDown: open the list with the chosen row active (else the first); on an open list, the next row
- Alt+ArrowDown: open the list with no row active
- ArrowUp: the row before; Alt+ArrowUp closes the list
- Home / End: move the caret in the field
- Enter: pick the active row, show its words and close the list; on a closed field, send the form (with allowCustomValue, words typed are kept first)
- Escape: close the list, putting the chosen row's words back; on a closed field, empty it and its value
- Tab: leave 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.

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

Shortened to fit: the data-slot values, how each state is put on.

## Related

- [Select](/themes/trail/components/select): One option from a short closed list.
- [Field](/themes/trail/components/field): A form row that ties one control to its label, its description and its error line, as a settings row or a stacked form field.
- [Multi select](/themes/trail/components/multi-select): A field holding several values picked from a fixed list.
- [Person select](/themes/trail/components/person-select): A person picker for an assignee, an owner or reviewers, each person shown with their avatar beside their name.
