# Combobox

A controlled searchable single-selection field with native form value, accessible active-option keyboard behavior, and consumer-owned re…

Access: pro. Category: Forms. Kind: primitive.

## When to use

- Use it when a product interface needs a controlled searchable single-selection field with native form value, accessible active-option keyboard behavior, and consumer-owned results.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose select-menu instead when use the select menu for a short fixed option list that does not need text search.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Combobox

```sh
npx shadcn@latest add @tidal-pro/combobox
```

Stylesheets: `components/ui/tidal.css`, `components/ui/combobox.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/combobox.css";
import{TidalCombobox}from"./components/ui/combobox";
export default(p:Parameters<typeof TidalCombobox>[0])=><div className="tidal-scope"><TidalCombobox {...p}/></div>;
```

## Structured props

- `TidalCombobox.formValue: string`: Required form value value accepted by this exported component.
- `TidalCombobox.label: ReactNode`: Required label value accepted by this exported component.
- `TidalCombobox.name: string`: Required name value accepted by this exported component.
- `TidalCombobox.onActiveOptionChange: (optionId: string | undefined, event: TidalComboboxActiveEvent) => void`: Callback invoked when the active option change interaction is proposed.
- `TidalCombobox.onOpenChange: (open: boolean, event: TidalComboboxOpenEvent) => void`: Receives native React interaction events, or a stable deferred-pointer-blur envelope after an outside pointer activation.
- `TidalCombobox.onQueryChange: (value: string, event: ChangeEvent<HTMLInputElement>) => void`: Callback invoked when the query change interaction is proposed.
- `TidalCombobox.onSelectionChange: (option: TidalComboboxOption, event: TidalComboboxSelectionEvent) => void`: Callback invoked when the selection change interaction is proposed.
- `TidalCombobox.open: boolean`: Required open value accepted by this exported component.
- `TidalCombobox.options: ReadonlyArray<TidalComboboxOption>`: Required options value accepted by this exported component.
- `TidalCombobox.query: string`: Required query value accepted by this exported component.
- `TidalCombobox.activeOptionId?: string | undefined`: Optional active option id value accepted by this exported component.
- `TidalCombobox.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalCombobox.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalCombobox.emptyMessage?: ReactNode` (default "No options match this query."): Optional empty message value accepted by this exported component.
- `TidalCombobox.error?: ReactNode`: Optional error value accepted by this exported component.
- `TidalCombobox.form?: string | undefined`: Optional form value accepted by this exported component.
- `TidalCombobox.hiddenInputProps?: Omit<InputHTMLAttributes<HTMLInputElement>, "disabled" | "form" | "name" | "type" | "value" | "defaultValue" | "children" | "dangerouslySetInnerHTML" | "readOnly"> | undefined`: Optional hidden input props value accepted by this exported component.
- `TidalCombobox.hiddenInputRef?: Ref<HTMLInputElement> | undefined`: Optional hidden input ref value accepted by this exported component.
- `TidalCombobox.hint?: ReactNode`: Optional hint value accepted by this exported component.
- `TidalCombobox.inputProps?: Omit<InputHTMLAttributes<HTMLInputElement>, "disabled" | "type" | "value" | "defaultValue" | "role" | "aria-activedescendant" | "aria-autocomplete" | "aria-controls" | "aria-disabled" | "aria-expanded" | "aria-readonly" | "children" | "dangerouslySetInnerHTML" | "placeholder" | "readOnly"> | undefined`: Optional input props value accepted by this exported component.
- `TidalCombobox.inputRef?: Ref<HTMLInputElement> | undefined`: Optional input ref value accepted by this exported component.
- `TidalCombobox.labels?: Partial<TidalComboboxLabels> | undefined`: Optional labels value accepted by this exported component.
- `TidalCombobox.placeholder?: string | undefined`: Optional placeholder value accepted by this exported component.
- `TidalCombobox.readOnly?: boolean | undefined` (default false): Optional read only value accepted by this exported component.
- `TidalCombobox.selectedLabel?: ReactNode`: Optional selected label value accepted by this exported component.
- `TidalCombobox.selectedOptionId?: string | undefined`: Optional selected option id value accepted by this exported component.
- `TidalCombobox.toggleButtonProps?: Omit<ButtonHTMLAttributes<HTMLButtonElement>, "disabled" | "type" | "aria-controls" | "aria-disabled" | "aria-expanded" | "aria-label" | "children" | "dangerouslySetInnerHTML"> | undefined`: Optional toggle button props value accepted by this exported component.
- `TidalCombobox.toggleButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional toggle button ref value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/combobox.tsx) | [Manifest](https://tidalui.com/examples/combobox.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
"use client";

import "./components/ui/tidal.css";

import { useId, useMemo, useRef, useState } from "react";

import { TidalCombobox, type TidalComboboxOption } from "./components/ui/combobox";

import "./components/ui/combobox.css";



const tidalExampleStyles = ".tidal-scope .combobox-demo,\n.tidal-scope .combobox-demo * {\n  box-sizing: border-box;\n}\n\n.tidal-scope .combobox-demo {\n  width: 100%;\n  min-width: 0;\n  container: combobox-demo / inline-size;\n}\n\n.tidal-scope .combobox-demo-frame {\n  display: grid;\n  min-width: 0;\n  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.38fr);\n  align-items: start;\n  gap: 14px;\n  padding: 20px;\n  border: 1px solid var(--t-border);\n  border-radius: 22px;\n  background: var(--t-subtle);\n  color: var(--t-ink);\n}\n\n.tidal-scope .combobox-demo-frame form {\n  min-width: 0;\n  margin: 0;\n}\n\n.tidal-scope .combobox-demo-actions {\n  display: grid;\n  grid-template-columns: repeat(2, minmax(0, 1fr));\n  gap: 8px;\n  margin-top: 10px;\n}\n\n.tidal-scope .combobox-demo-actions button {\n  min-width: 0;\n  min-height: 44px;\n  padding: 9px 12px;\n  border: 1px solid var(--t-border);\n  border-radius: 10px;\n  background: var(--t-surface);\n  color: var(--t-ink);\n  font: inherit;\n  font-size: 11px;\n  font-weight: 670;\n  line-height: 1.35;\n  overflow-wrap: anywhere;\n  cursor: pointer;\n}\n\n.tidal-scope .combobox-demo-actions button:first-child {\n  border-color: var(--t-ink);\n  background: var(--t-ink);\n  color: var(--t-surface);\n}\n\n.tidal-scope .combobox-demo-actions button:focus-visible {\n  outline: 2px solid var(--t-accent);\n  outline-offset: 3px;\n}\n\n.tidal-scope .combobox-demo-summary {\n  min-width: 0;\n  padding: 22px;\n  border: 1px solid var(--t-border);\n  border-radius: 18px;\n  background: var(--t-ink);\n  color: var(--t-surface);\n}\n\n.tidal-scope .combobox-demo-summary > span {\n  color: color-mix(in srgb, var(--t-surface) 62%, var(--t-ink));\n  font-size: 11px;\n  font-weight: 700;\n  letter-spacing: 0.1em;\n  line-height: 1.35;\n  text-transform: uppercase;\n}\n\n.tidal-scope .combobox-demo-summary > strong {\n  display: block;\n  margin-top: 22px;\n  font-size: 22px;\n  font-weight: 570;\n  letter-spacing: -0.04em;\n  line-height: 1.1;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .combobox-demo-summary > p,\n.tidal-scope .combobox-demo-summary > small {\n  color: color-mix(in srgb, var(--t-surface) 70%, var(--t-ink));\n  font-size: 11px;\n  line-height: 1.55;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .combobox-demo-summary > p {\n  margin: 10px 0 0;\n}\n\n.tidal-scope .combobox-demo-summary dl {\n  display: grid;\n  gap: 1px;\n  margin: 18px 0;\n  overflow: hidden;\n  border: 1px solid color-mix(in srgb, var(--t-surface) 22%, var(--t-ink));\n  border-radius: 10px;\n  background: color-mix(in srgb, var(--t-surface) 22%, var(--t-ink));\n}\n\n.tidal-scope .combobox-demo-summary dl > div {\n  min-width: 0;\n  padding: 9px 10px;\n  background: var(--t-ink);\n}\n\n.tidal-scope .combobox-demo-summary dt {\n  color: color-mix(in srgb, var(--t-surface) 58%, var(--t-ink));\n  font-size: 11px;\n  line-height: 1.35;\n}\n\n.tidal-scope .combobox-demo-summary dd {\n  margin: 4px 0 0;\n  font-size: 11px;\n  line-height: 1.4;\n  overflow-wrap: anywhere;\n}\n\n@container combobox-demo (max-width: 720px) {\n  .tidal-scope .combobox-demo-frame {\n    grid-template-columns: minmax(0, 1fr);\n    padding: 10px;\n  }\n}\n\n@container combobox-demo (max-width: 390px) {\n  .tidal-scope .combobox-demo-frame {\n    gap: 9px;\n    padding: 7px;\n  }\n\n  .tidal-scope .combobox-demo-actions {\n    grid-template-columns: minmax(0, 1fr);\n  }\n\n  .tidal-scope .combobox-demo-actions button {\n    font-size: 16px;\n  }\n\n  .tidal-scope .combobox-demo-summary {\n    padding: 18px 16px;\n  }\n}\n\n@media (hover: none) and (pointer: coarse) {\n  .tidal-scope .combobox-demo-actions button {\n    font-size: 16px;\n  }\n}";

const OPTIONS: readonly TidalComboboxOption[] = [
  {
    id: "ava",
    value: "ava-stone",
    label: "Ava Stone",
    accessibleLabel: "Ava Stone, product design",
    description: "Product design",
    meta: "Available",
  },
  {
    id: "noah",
    value: "noah-park",
    label: "Noah Park",
    accessibleLabel: "Noah Park, engineering",
    description: "Engineering",
    meta: "Available",
  },
  {
    id: "mila",
    value: "mila-santos",
    label: "Mila Santos",
    accessibleLabel: "Mila Santos, research",
    description: "Research",
    meta: "Reviewing",
  },
  {
    id: "eli",
    value: "eli-brooks",
    label: "Eli Brooks",
    accessibleLabel: "Eli Brooks, editorial, unavailable",
    description: "Editorial",
    meta: "Unavailable",
    disabled: true,
  },
  {
    id: "rhea",
    value: "rhea-kim",
    label: "Rhea Kim",
    accessibleLabel: "Rhea Kim, operations",
    description: "Operations",
    meta: "Available",
  },
];

export function ComboboxDemo() {
  const generatedId = useId().replace(/:/g, "");
  const formId = `combobox-${generatedId}-form`;
  const inputRef = useRef<HTMLInputElement>(null);
  const [query, setQuery] = useState("");
  const [open, setOpen] = useState(false);
  const [activeOptionId, setActiveOptionId] = useState<string | undefined>();
  const [selectedOptionId, setSelectedOptionId] = useState<
    string | undefined
  >();
  const [message, setMessage] = useState("Choose a reviewer for this brief.");
  const normalizedQuery = query.trim().toLocaleLowerCase();
  const visibleOptions = useMemo(
    () =>
      OPTIONS.filter((option) =>
        `${String(option.label)} ${String(option.description ?? "")}`
          .toLocaleLowerCase()
          .includes(normalizedQuery),
      ),
    [normalizedQuery],
  );
  const selectedOption = OPTIONS.find(
    (option) => option.id === selectedOptionId,
  );

  function resetLocalForm() {
    setQuery("");
    setOpen(false);
    setActiveOptionId(undefined);
    setSelectedOptionId(undefined);
    setMessage("Reviewer cleared.");
  }

  return (
    <section className="combobox-demo" aria-label="Combobox preview">
      <div className="combobox-demo-frame">
        <form
          id={formId}
          onSubmit={(event) => {
            event.preventDefault();
            setMessage(
              selectedOption
                ? `Review choice: ${String(selectedOption.label)}.`
                : "Choose a reviewer before reviewing this brief.",
            );
          }}
          onReset={resetLocalForm}
        >
          <TidalCombobox
            label="Reviewer"
            description="Find the person who should review this brief."
            query={query}
            open={open}
            activeOptionId={activeOptionId}
            selectedOptionId={selectedOptionId}
            selectedLabel={selectedOption?.label}
            formValue={selectedOption?.value ?? ""}
            name="sampleReviewer"
            form={formId}
            options={visibleOptions}
            placeholder="Search people"
            inputRef={inputRef}
            onQueryChange={(value) => {
              setQuery(value);
              const nextOptions = OPTIONS.filter((option) =>
                `${String(option.label)} ${String(option.description ?? "")}`
                  .toLocaleLowerCase()
                  .includes(value.trim().toLocaleLowerCase()),
              );
              setActiveOptionId(
                nextOptions.find((option) => !option.disabled)?.id,
              );
              setMessage(
                value
                  ? `Showing reviewer matches for “${value}”.`
                  : "Showing every reviewer.",
              );
            }}
            onOpenChange={(nextOpen) => {
              setOpen(nextOpen);
              if (nextOpen && !activeOptionId) {
                setActiveOptionId(
                  visibleOptions.find((option) => !option.disabled)?.id,
                );
              }
            }}
            onActiveOptionChange={setActiveOptionId}
            onSelectionChange={(option) => {
              setSelectedOptionId(option.id);
              setQuery(String(option.label));
              setMessage(`${String(option.label)} is ready to review.`);
            }}
            hint="Arrow keys move through enabled options. Enter selects; Escape closes."
            emptyMessage="No reviewers match this search."
          />

          <div className="combobox-demo-actions">
            <button type="submit">Review choice</button>
            <button type="reset">Clear reviewer</button>
          </div>
        </form>

        <aside className="combobox-demo-summary" aria-live="polite">
          <span>Brief review</span>
          <strong>{selectedOption?.label ?? "No reviewer selected"}</strong>
          <p>{message}</p>
          <dl>
            <div>
              <dt>Reviewer key</dt>
              <dd>{selectedOption?.value ?? "Empty"}</dd>
            </div>
            <div>
              <dt>Roster</dt>
              <dd>Sample team</dd>
            </div>
          </dl>
          <small>Sample data. Changes stay in this preview.</small>
        </aside>
      </div>
    </section>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <ComboboxDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation.","Escape dismisses the open overlay where the underlying primitive supports dismissal."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

label, controlled query/open/activeOptionId/selectedOptionId, formValue, native hidden-input name, consumer-owned visible options and four controlled callbacks are required. The labelled native text input exposes combobox/listbox/expanded/active-descendant semantics and excludes conflicting controlled, default, type and ARIA state props. Arrow keys wrap through enabled options; Home/End move to boundaries, Enter requests selection, Escape closes and Tab closes without preventing focus travel. The native input, toggle and options run supplied native handlers first and suppress higher callbacks when prevented; disabled and read-only states suppress mutation. Options carry consumer-owned visible/accessibility content, disabled state, native div attributes/ref and optional metadata. The hidden native form value supports external form ownership, attributes/ref and remains submitted while read-only. Optional labels, selectedLabel, description, hint, error, empty content and native root/input/toggle attributes/refs remain consumer-owned. Active-option scrolling is confined to the listbox. Outside pointer dismissal waits for activation or a release fallback, preserving nearby native click targets. onOpenChange receives React interaction events or a documented TidalComboboxDeferredBlurEvent envelope with stable currentTarget and original native focus event after a deferred pointer blur. Consumers own filtering, querying, selection and every outcome. The component performs no request, routing, assignment, analytics, network, storage or persistence action.
