Docs
Multi Select

Multi Select

Allows selecting multiple items from a dropdown list.

Installation

Usage

import { MultiSelect } from "@/components/ui/multi-select";
const options = [
  { value: "react", label: "React" },
  { value: "vue", label: "Vue" },
  { value: "angular", label: "Angular" },
  { value: "svelte", label: "Svelte" },
];
 
const [selected, setSelected] = useState<string[]>([]);
 
const handleChange = (value: string, remove: boolean) => {
  if (remove) {
    setSelected(selected.filter((item) => item !== value));
  } else {
    setSelected([...selected, value]);
  }
};
 
<MultiSelect
  options={options}
  selected={selected}
  onChange={handleChange}
  placeholder="Select frameworks..."
  label="Frameworks"
/>;

Props

PropTypeDefaultDescription
options{ value: string, label: string }[]-Array of options to display in the dropdown list.
selectedstring[]-Array of selected option values.
partiallySelectedstring[][]Array of partially selected option values.
onChange(value: string, remove: boolean)=>void-Function called when an option is selected/deselected
onCreateOption(value: string)=>void-Optional function to create a new option.
placeholderstring"Add tags..."Placeholder text for the input field.
classNamestring-The class name to apply to the component.
disabledbooleanfalseWhether the select is disabled.
labelReactNode"Custom tags"The label for the select.