Combobox

A select you can type in, for long option lists. Passed through from shadcn (Base UI Combobox) until Pilar restyles it.

Usage

import { Combobox, ComboboxInput, ComboboxContent, ComboboxList, ComboboxItem } from '@pilar-amoda/ui/combobox';

Searchable select

items is the full option list; typing filters it. showClear adds the × to empty the value.

'use client';

import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxList,
} from '@pilar-amoda/ui/combobox';

const brands = ['Adhimix', 'Davinci', 'JBS Stainless', 'Nippon Paint', 'Panasonic'];

export const ComboboxBasic = () => (
  <Combobox items={brands}>
    <ComboboxInput placeholder="Cari merek" showClear data-testid="ddlBrand_Combobox" />
    <ComboboxContent>
      <ComboboxEmpty>Tidak ada hasil</ComboboxEmpty>
      <ComboboxList>
        {(brand: string) => (
          <ComboboxItem key={brand} value={brand}>
            {brand}
          </ComboboxItem>
        )}
      </ComboboxList>
    </ComboboxContent>
  </Combobox>
);

Do and don't

Do: use it when there are too many options to scroll (brands, vendors, categories).
Don't: use it for a handful of fixed options; use Select.