Forms

Combobox.

Find an option by typing its name.

LIVE PREVIEWTry it. It works.

Install the source

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/combobox.json

Registry setup · Examples · API and behavior · Open the playground

COMPLETE EXAMPLES

Use it in context.

Each example includes its imports, data and state. The preview runs that same source. Include the stylesheet once in your application.

Search rich options and submit IDs

Search labels, descriptions or aliases without using display text as the selected value.

Keyboard

  • Type to filter labels, descriptions and search terms.
  • ArrowDown highlights a result; Enter commits its ID.
  • Escape closes the list without discarding the committed selection.

States covered

  • controlled value
  • stable IDs
  • grouped results
  • search aliases
  • custom row
  • native form
  • blur binding

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-combobox-canonical-options.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import { useState } from 'react';
import { MapPin } from 'lucide-react';
import { Button, Combobox, type Option } from '@bld8/ui';
const offices: Option[] = [
  { value: 'mel-studio', label: 'Melbourne studio', group: 'Australia', icon: MapPin, description: 'City centre workspace.', searchTerms: ['victoria', 'collingwood'] },
  { value: 'syd-studio', label: 'Sydney studio', group: 'Australia', icon: MapPin, description: 'Harbour workspace.', searchTerms: ['nsw'] },
  { value: 'wlg-studio', label: 'Wellington studio', group: 'New Zealand', icon: MapPin, description: 'Waterfront workspace.', searchTerms: ['aotearoa'] }
];
export default function CanonicalComboboxExample() {
  const [value, setValue] = useState<string | null>('mel-studio');
  const [submitted, setSubmitted] = useState('Not submitted');
  const [touched, setTouched] = useState(false);
  return <form aria-label="Office search example" onSubmit={event => {
    event.preventDefault(); setSubmitted(String(new FormData(event.currentTarget).get('office') ?? ''));
  }} style={{ display: 'grid', gap: 16, maxWidth: 440 }}>
    <Combobox label="Office location" name="office" options={offices} value={value} onValueChange={setValue} clearable
      onBlur={() => setTouched(true)} hint="Try searching for victoria or waterfront."
      renderOption={option => <strong style={{ fontWeight: 500 }}>{option.label}</strong>} />
    <Button type="submit">Read office ID</Button>
    <output aria-label="Office form value">{submitted}</output>
    <p>Office field touched: {touched ? 'yes' : 'no'}</p>
  </form>;
}

Simple strings, empty and disabled states

Existing string items keep working alongside canonical-ID options.

Keyboard

  • The legacy field retains standard filtering and keyboard selection.
  • No-match feedback stays visible for an empty source.
  • Disabled fields keep their display value without accepting edits.

States covered

  • legacy items
  • uncontrolled popup
  • empty options
  • invalid
  • disabled

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-combobox-legacy-states.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import { useState } from 'react';
import { Button, Combobox } from '@bld8/ui';
export default function LegacyComboboxExample() {
  const [city, setCity] = useState<string | null>('Lisbon');
  const [submitted, setSubmitted] = useState('Not submitted');
  return <form aria-label="Legacy city selection example" onSubmit={event => {
    event.preventDefault(); setSubmitted(String(new FormData(event.currentTarget).get('city') ?? ''));
  }} style={{ display: 'grid', gap: 16, maxWidth: 440 }}>
    <Combobox label="Legacy city strings" name="city" items={['Lisbon', 'Oslo', 'Tallinn']} value={city} onValueChange={setCity} clearable />
    <Combobox label="Unavailable office" options={[]} error="No offices are configured." emptyMessage="No office choices are available." />
    <Combobox label="Managed office" options={[{ value: 'managed-office', label: 'Assigned office' }]} defaultValue="managed-office" disabled />
    <Button type="submit">Read legacy city</Button><output aria-label="Legacy city form value">{submitted}</output>
  </form>;
}

Keyboard focus and popup completion

Keep typing focus, scroll long results and close options before a parent dialog.

Keyboard

  • ArrowDown highlights an option while focus remains in the search input.
  • Tab and Shift+Tab leave the search naturally; Escape restores the committed label.
  • Inside the dialog, Escape closes options first and the dialog second.

States covered

  • controlled popup
  • completion callbacks
  • interrupted motion
  • long results
  • dialog ownership
  • native focus

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-combobox-focus-lifecycle.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import { useRef, useState } from 'react';
import { Button, Combobox, Dialog, DialogClose, UIProvider, type Option } from '@bld8/ui';
import '@bld8/ui/styles.css';
const rooms: Option[] = Array.from({ length: 36 }, (_, index) => ({ value: 'room-' + (index + 1), label: 'Review room ' + String(index + 1).padStart(2, '0') }));
export default function ComboboxFocusLifecycleExample() {
  const [value, setValue] = useState<string | null>('room-1');
  const [open, setOpen] = useState(false);
  const [completed, setCompleted] = useState<string[]>([]);
  const [outside, setOutside] = useState(0);
  const input = useRef<HTMLInputElement>(null);
  return <UIProvider><div style={{ display: 'grid', gap: 16, maxWidth: 440 }}>
    <Button variant="secondary">Before room search</Button>
    <Combobox label="Room search lifecycle" options={rooms} value={value} onValueChange={setValue} inputRef={input} open={open} onOpenChange={setOpen}
      onOpenChangeComplete={next => setCompleted(previous => [...previous, next ? 'open' : 'closed'])} clearable />
    <Button variant="secondary" onClick={() => setOutside(count => count + 1)}>After room search</Button>
    <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}><Button onClick={() => { input.current?.focus(); setOpen(true); }}>Open room choices</Button><Button variant="secondary" onClick={() => setOpen(false)}>Close room choices</Button><Button variant="ghost" onClick={() => setCompleted([])}>Clear room completions</Button></div>
    <output aria-label="Room popup completions">{completed.join(', ')}</output>
    <output aria-label="Room outside actions">{outside}</output>
    <Dialog trigger={<Button variant="secondary">Open room dialog</Button>} title="Review room dialog" description="The search belongs to this dialog.">
      <div style={{ display: 'grid', gap: 16 }}><Combobox label="Dialog review room" options={rooms} defaultValue="room-1" /><DialogClose>Finish room selection</DialogClose></div>
    </Dialog>
  </div></UIProvider>;
}

Quick reference

React / TypeScript
<Combobox label="Framework" items={["React", "Angular", "Vue"]} />

In the workspace or ZIP starter, import components from @bld8/ui and include @bld8/ui/styles.css once. Registry installations use your local bld8/ source path. Wrap overlays in UIProvider.

API & behaviour

Built on Base UI Combobox. Existing string items stay supported. Optional rich options use stable IDs independently of labels and take precedence over items. Descriptions, icons, groups and search terms share the local Option model. Controlled/default value and popup state, names/forms, required, disabled, hints/errors, visible-input ref, blur, search and empty feedback are supported. Remote paging belongs to AsyncCombobox.

Combobox

Combobox public properties
PropTypeDefault
labelRequiredstring—
clearableboolean | undefinedfalse
defaultOpenboolean | undefinedfalse
defaultValuestring | null | undefinednull
density"compact" | "comfortable" | undefined'comfortable'
disabledboolean | undefined—
emptyMessagestring | undefined—
errorstring | undefined—
formstring | undefined—
hintstring | undefined—
inputRefRef<HTMLInputElement> | undefined—
itemsreadonly string[] | undefined

Legacy local strings remain both their labels and submitted values.

noStringItems
labelVisibility"hidden" | "visible" | undefined'visible'
namestring | undefined—
onBlurFocusEventHandler<HTMLInputElement> | undefined—
onOpenChange((open: boolean) => void) | undefined—
onOpenChangeComplete((open: boolean) => void) | undefined—
onValueChange((value: string | null) => void) | undefined—
openboolean | undefined—
optionsreadonly Option[] | undefined

Stable-ID options take precedence over legacy items when supplied.

—
placeholderstring | undefined—
renderOption((option: Option) => ReactNode) | undefined

A presentational row body; do not add nested interactive elements.

—
requiredboolean | undefined—
valuestring | null | undefined—

Tables come from the public TypeScript declarations. Related types and function parameters are shown alongside their component. A dash means no default is declared at the public function boundary.

Related controls

Notes to self

Test this component with real content, keyboard input and both themes. The example is a starting point; labels, error handling and behaviour still need to fit the application.