Skip to main content

Common Examples

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

function ExampleComponent() {
  return (
    <SelectTrigger
      multiple
      selectedItems={selectedItems}
      itemToString={(item: Item | null) => item?.label ?? ""}
      onClick={() => setOpenDialog(true)}
      onChange={(items: Item[] | null) => setSelectedItems(items ?? [])}
    />
  );
}

Complex selections

The SelectTrigger can be used in complex selection cases where the Combobox would be insufficient. Instead of using the Combobox, the SelectTrigger can be paired with Dialog to handle use cases like secondary actions and tabbed options. (See our usage guidelines for Combobox.)Note that the SelectTrigger can modify the selected items on it’s own with the “X” button on both individual Chips and on the input itself, so the state setter will need to be used in both the SelectTrigger’s onChange and in the form controls inside the Dialog.

Selected item customization

SelectTriggers with multiple select can customize the selected state of an item using the selectedItemProps prop. This prop accepts a function that will pass the selected item as an parameter to allow for things like customizing the display color:
Last modified on January 23, 2026