Web Overlay

MultiSelect

A dropdown component for selecting multiple options.

MultiSelect is a dropdown component for selecting multiple values at once. Selected values are shown as removable tags in the trigger button.

import { MultiSelect } from "@/components/multi-select";

<Field name="Checks" description="Visibility filters">
  <MultiSelect
    value={
      [data.team_check && "team", data.dead_check && "dead"].filter(
        Boolean,
      ) as string[]
    }
    onChange={(checks) =>
      set({
        ...data,
        team_check: checks.includes("team"),
        dead_check: checks.includes("dead"),
      })
    }
    options={[
      { value: "team", label: "Team Check" },
      { value: "dead", label: "Dead Check" },
    ]}
    placeholder="Select checks..."
  />
</Field>;

Props

PropTypeDefaultDescription
valuestring[]Controlled array of selected values
onChange(value: string[]) => voidCalled with the full updated array when a value is toggled
optionsMultiSelectOption[]List of options to display
placeholderstring"Select..."Text shown when nothing is selected
disabledbooleanfalseDisables the dropdown
maxDisplaynumber2Max number of tags to show before collapsing into +N more

MultiSelectOption

FieldTypeDescription
valuestringThe value included in the selected array
labelstringThe text displayed in the dropdown and as the tag label

Mapping to Boolean Fields

Since the C++ config uses individual boolean fields rather than an array, you need to map between the two when using MultiSelect. Convert your booleans to an array for value and convert the array back to booleans in onChange:

value={
  [data.team_check && "team", data.dead_check && "dead"].filter(
    Boolean,
  ) as string[]
}
onChange={(checks) =>
  set({
    ...data,
    team_check: checks.includes("team"),
    dead_check: checks.includes("dead"),
  })
}

On this page