Skip to main content

MultiSelect

The MultiSelect component is a form component that lets users pick several options from a scrollable list.

Import

// with @dhl-official/react-library:
import { DhlMultiSelect } from "@dhl-official/react-library"
// with @dhl-official/ui-libraries/react-library:
import { DhlMultiSelect } from "@dhl-official/ui-libraries/react-library"

Code

<DhlMultiSelect options={options}></DhlMultiSelect>

The options property should be passed to the component as an array; objects within this array accept 4 values, label, value, image and disabled. The label and value properties are required. However, image and disabled are optional. Any other values that are added to this object will be ignored by default, however they can be taken into consideration when using them with custom props such as the customFilter. The select option type definition is as follows:

type DhlMultiSelectOptionType = {
label: string;
value: string;
image?: string;
disabled?: boolean;
}

Interactive Demo

Readme

Properties

PropertyAttributeDescriptionTypeDefault
allowCustomOptionsCreationallow-custom-options-creationAn optional prop to custom values creation.booleanfalse
chipsVariantchips-variantAn optional prop to set component chips design variant."inline" \| "inner" \| "outer"DHL_MULTI_SELECT.CHIPS_VARIANT.INNER
customFilter--An optional callback handler that accepts the options and input data, used for custom filtering. If this function is not passed, by default, filtering will happen on the "label" key of the item if its an object or the actual value if the item is a primitive data type(options: unknown, value: string) => DhlSelectionOptionType[]undefined
dataAriaDescribedbydata-aria-describedbyAn optional prop defining the list of reference IDs (separated by spaces), recommended when you want to an error message on your field.stringundefined
dataAriaExpandeddata-aria-expandedAn optional prop used for assistive technology support - used to mark expandable and collapsible regions.stringundefined
dataIddata-idAn optional prop. Gives a valid HTML ID attribute value for the component.stringundefined
getItemLabel--An optional prop used to read the label of an option.(option: any) => voidundefined
handleCustomOptionCreate--An optional prop used to read the label of an option.(option: DhlSelectionOptionType) => voidundefined
isDisabledis-disabledAn optional flag to define if the component is disabled.booleanfalse
namenameAn optional value to be set to the element HTML name attribute. It takes any valid value that can be used for the name attribute of an HTMLInputElement.stringundefined
openOnFocusopen-on-focusAn optional prop when set to true, the select option list will be shown on input focus.booleanfalse
options--An optional data prop to pass the list of options to be rendered.DhlSelectionOptionType[][]
requiredrequiredAn optional prop to flag the component as required within a form context.booleanundefined
rightIconright-iconAn optional prop to define right icon.stringundefined
showChipsCountshow-chips-countAn optional prop to set multi select chips counter.booleantrue
showClearButtonshow-clear-buttonAn optional prop flag to define if clear button is displayed.booleanfalse
showRightIconshow-right-iconAn optional prop flag to define if right icon is displayed.booleanfalse
validation--An optional object to set-up a custom components validation state. Required Fields: type{ type: Variants.warning \| Variants.valid \| Variants.invalid \| Variants.note; message?: string; }undefined
valuevalueAn optional prop defining the value of the component which is taken when a form is submitted.string""
variant--A optional object to set-up a custom components variant state. It can be used to set a custom label, a custom placeholder text, enable or disable label animation (via the mandatory type field).{ label?: string; placeholder?: string; type: Variants.animated \| Variants.static; }undefined

Dependencies

Depends on

Graph


Built by DHL User Interface Library Team!