Skip to main content

Common Examples

import { Listbox } from "@servicetitan/anvil2";

const ExampleComponent = () => {
  const itemsArray = [
    { id: 0, label: "First item" },
    // ... more items
  ];

  return (
    <Listbox items={itemsArray}>
      {({ items }) =>
        items.map((item) => (
          <Listbox.Option key={item.label} item={item}>
            {item.label}
          </Listbox.Option>
        ))
      }
    </Listbox>
  );
};

Listbox Components

A listbox can be created using the Listbox component and its two sub-components:
  • Listbox.Option: used to render the individual list options.
  • Listbox.OptionGroup: optionally used to group listbox options.
Last modified on January 23, 2026