Skip to content

Combobox

Advanced combobox with single and multi-select support

Single

Usage

tsx
import { Combobox } from '@tryvienna/ui'

<div className="w-64">
  <Combobox
    options={fruitOptions}
    value={value}
    onValueChange={setValue}
    placeholder="Select a fruit..."
    searchPlaceholder="Search fruits..."
  />
  <p className="mt-4 text-xs text-muted-foreground">
    Selected: &quot;{value || '(none)'}&quot;
  </p>
</div>

Examples

Single

Single
tsx
<div className="w-64">
  <Combobox
    options={fruitOptions}
    value={value}
    onValueChange={setValue}
    placeholder="Select a fruit..."
    searchPlaceholder="Search fruits..."
  />
  <p className="mt-4 text-xs text-muted-foreground">
    Selected: &quot;{value || '(none)'}&quot;
  </p>
</div>

Multi

Multi
tsx
<div className="w-72">
  <Combobox
    options={tagOptions}
    value={values}
    onValueChange={setValues}
    multiple
    placeholder="Select tags..."
    searchPlaceholder="Search tags..."
  />
  <p className="mt-4 text-xs text-muted-foreground">
    Selected: {values.length > 0 ? values.join(', ') : '(none)'}
  </p>
</div>

Creatable

Creatable
tsx
<div className="w-72">
  <Combobox
    options={options}
    value={values}
    onValueChange={setValues}
    multiple
    placeholder="Select frameworks..."
    searchPlaceholder="Search or create..."
    onCreateOption={handleCreate}
  />
  <p className="mt-4 text-xs text-muted-foreground">
    Selected: {values.length > 0 ? values.join(', ') : '(none)'}
  </p>
  <p className="mt-1 text-xs text-muted-foreground">
    Type a new name and select &quot;Create&quot; to add it.
  </p>
</div>

API Reference

Combobox

PropTypeDefaultDescription
optionsComboboxOption[] | ComboboxGroup[]-
valuestring | string[]-
onValueChange((value: string) =&gt; void) | ((value: string[]) =&gt; void)-
multiplebooleanfalse
placeholderstringSelect...
searchPlaceholderstringSearch...
emptyTextstringNo results found.
disabledbooleanfalse
onCreateOption((inputValue: string) =&gt; void) | undefined-

Data Attributes

Componentdata-slot
Combobox"combobox"