Skip to content
Harness Design System Harness Design System Harness Design System

MultiSelect

beta

The MultiSelect component allows users to select multiple options from a dropdown list. It is useful for scenarios where multiple selections are needed.

Usage

import { MultiSelect, MultiSelectOption } from "@harnessio/ui/components";
import { useState } from "react";
// Basic usage with controlled component
const MyComponent = () => {
const [selected, setSelected] = useState<MultiSelectOption[]>([]);
return (
<MultiSelect
label="Select frameworks"
placeholder="Select options..."
options={[{ key: "react" }, { key: "vue" }, { key: "angular" }]}
value={selected}
onChange={setSelected}
/>
);
};

Disallow Creation

The MultiSelect component accepts an optional disallowCreation prop. When set to true, it disables the ability to add new items that are not part of the existing options list.

Form Integration

The MultiSelect component integrates seamlessly with form elements like labels, captions, and validation messages.

Orientation

The MultiSelect component accepts an optional orientation prop, which defines the layout direction of the input and its label. Available options are horizontal and vertical (default).

MultiSelectOption Type

interface MultiSelectOption {
id: string | number; // Required - the unique identifier for the option
key: string; // Required - the main identifier for the option
value?: string; // Optional - used for key-value pairs
disable?: boolean; // Optional - disables the option in the dropdown
onReset?: () => void; // Optional - custom reset handler for the option
}

API Reference

Prop
Required
Default
Type
labelfalsestring
captionfalsestring
valuefalseMultiSelectOption[]
defaultValuefalseMultiSelectOption[]
optionsfalseMultiSelectOption[]
placeholderfalsestring
searchQueryfalsestring | null
setSearchQueryfalse(query: string | null) => void
onChangefalse(options: MultiSelectOption[]) => void
maxSelectedfalsenumber
onMaxSelectedfalse(maxLimit: number) => void
disabledfalseboolean
classNamefalsestring
disallowCreationfalseboolean
isLoadingfalseboolean
optionalfalsefalseboolean
themefalse'default''default' | 'danger' | 'warning'
captionfalsestring
errorfalsestring
warningfalsestring
rootClassNamefalsestring
orientationfalse'vertical''vertical' | 'horizontal'