A dropdown control that lets users choose multiple options from a list. — <cs-multiselect>
Note: Options are set via the
optionsJavaScript property. See usage below.
<cs-multiselect placeholder="Choose options"></cs-multiselect>
<script>
const multiselect = document.querySelector('cs-multiselect');
multiselect.options = [
{ label: 'Option 1', value: '1' },
{ label: 'Option 2', value: '2' },
{ label: 'Option 3', value: '3' },
];
multiselect.selectedOptions = [
{ label: 'Option 1', value: '1' },
];
</script>
aria-labelstring
default: nullAdds aria-label to the select element.
Use this if you don't have a visible label for this control.
aria-requiredbooleanAdds aria-required to the native input element.
auto-focusbooleanAutomatically focuses the trigger when component is mounted.
control-idstringSpecifies the ID for the trigger component. It uses an automatically generated ID by default.
deselect-aria-labelMultiselectProps.DeselectAriaLabelFunctionSpecifies an aria-label for the token deselection button.
disabledbooleanDetermines whether the whole select component is disabled.
enable-select-allbooleanEnables users to select and deselect all options with a special extra checkbox which is displayed at the start of the dropdown.
expand-to-viewportbooleanBy default, the dropdown height is constrained to fit inside the height of its next scrollable container element. Enabling this property will allow the dropdown to extend beyond that container by using fixed positioning and React Portals.
Set this property if the dropdown would otherwise be constrained by a scrollable container, for example inside table and split view layouts.
We recommend you use discretion, and don't enable this property unless necessary because fixed positioning results in a slight, visible lag when scrolling complex pages.
filtering-aria-labelstringAdds an aria-label on the built-in filtering input if filtering is enabled.
filtering-clear-aria-labelstringAdds an aria-label to the clear button inside the search input.
filtering-placeholderstring
default: ''Specifies the placeholder to display in the filtering input if filtering is enabled.
filtering-results-text(matchesCount: number, totalCount: number) => stringSpecifies the text to display with the number of matches at the bottom of the dropdown menu while filtering.
filtering-typeOptionsFilteringType
default: 'none'Determines how filtering is applied to the list of options:
auto - The component will automatically filter options based on user input.manual - You will set up onChange or onLoadItems event listeners and filter options on your side or request
them from server.By default the component will filter the provided options based on the value of the filtering input field.
Only options that have a value, label, description or labelTag that contains the input value as a substring
are displayed in the list of options.
If you set this property to manual, this default filtering mechanism is disabled and all provided options are
displayed in the dropdown list. In that case make sure that you use the onChange or onLoadItems events in order
to set the options property to the options that are relevant for the user, given the filtering input value.
Note: Manual filtering doesn't disable match highlighting.
hide-tokensboolean
default: falseHides the tokens displayed underneath the component. Only use this if the selected options are displayed elsewhere on the page.
i18n-stringsMultiselectProps.I18nStringsAn object containing all the localized strings required by the component.
selectAllText (string) - Specifies the text to be displayed next to the checkbox that selects or deselects all options.tokenLimitShowFewer (string) - Specifies the text to be displayed in the "Show fewer" button for the token group control.tokenLimitShowMore (string) - Specifies the text to be displayed in the "Show more" button for the token group control. This string should not contain the number of hidden tokens
because this will be added by the component automatically.inline-label-textstringSpecifies an inline label that appears next to the multiselect trigger.
inline-tokensbooleanShows tokens inside the trigger instead of below it.
keep-openboolean
default: falseDetermines whether the dropdown list stays open after the user selects an item.
namestringoptionsSelectProps.Options
default: []Specifies an array of options that are displayed to the user as a dropdown list.
The options can be grouped using OptionGroup objects.
value (string) - The returned value of the option when selected.value (string) - Used to locate option group in test utils.options (Option[]) - (Optional) The options under this group.label (string) - (Optional) Option or group text displayed to the user.lang (string) - (Optional) The language of the option or group, provided as a BCP 47 language tag.description (string) - (Optional) Further information about the option or group that appears below the label.disabled (boolean) - (Optional) Determines whether the option or group is disabled.disabledReason (string) - (Optional) Displays tooltip near the item when disabled. Use to provide additional context.labelTag (string) - (Optional) A label tag that provides additional guidance, shown next to the label.tags [string[]] - (Optional) A list of tags giving further guidance about the option or group.filteringTags [string[]] - (Optional) A list of additional tags used for automatic filtering.iconName (string) - (Optional) Specifies the name of an icon to display in the option or group.iconAriaLabel (string) - (Optional) Specifies alternate text for the icon. We recommend that you provide this for accessibility.iconAlt (string) - (Optional) Deprecated, replaced by `iconAriaLabel`. Specifies alternate text for a custom icon, for use with iconUrl.iconUrl (string) - (Optional) URL of a custom icon.iconSvg (unknown) - (Optional) Custom SVG icon. Equivalent to the svg slot of the icon component.Note: Only one level of option nesting is supported.
If you want to use the built-in filtering capabilities of this component, provide a list of all valid options here and they will be automatically filtered based on the user's filtering input.
Alternatively, you can listen to the onChange or onLoadItems event and set new options
on your own.
placeholderstring
default: ''Specifies the hint text that's displayed in the field when no option has been selected.
read-onlybooleanSpecifies if the control is read-only, which prevents the user from both modifying the value and opening the dropdown. A read-only control is still focusable.
render-highlighted-aria-liveSelectProps.ContainingOptionAndGroupStringOverrides the element that is announced to screen readers
when the highlighted option changes. By default, this announces
the option's name and properties, and its selected state if
the selectedAriaLabel property is defined.
The highlighted option is provided, and its group (if groups
are used and it differs from the group of the previously highlighted option).
For more information, see the accessibility guidelines.
render-optionMultiselectProps.MultiselectOptionItemRendererSpecifies a render function to render custom options in the dropdown menu.
selected-aria-labelstringSpecifies the localized string that describes an option as being selected. This is required to provide a good screen reader experience. For more information, see the accessibility guidelines.
selected-optionsReadonlyArray<MultiselectProps.Option>requiredSpecifies the currently selected options. Provide an empty array to clear the selection.
token-limitnumberSpecifies the maximum number of displayed tokens. If the property isn't set, all of the tokens are displayed.
token-limit-show-fewer-aria-labelstringAdds an aria-label to the "Show fewer" button for the token group control.
Use to assign unique labels when there are multiple token groups with the same tokenLimitShowFewer label on one page.
token-limit-show-more-aria-labelstringAdds an aria-label to the "Show more" button for the token group control.
Use to assign unique labels when there are multiple token groups with the same tokenLimitShowMore label on one page.
virtual-scrollbooleanIf you have more than 500 options, enable this flag to apply a performance optimization that makes the filtering experience smoother. We don't recommend enabling the feature if you have less than 500 options, because the improvements to performance are offset by a visible scrolling lag.
When you set this flag to true, it removes options that are not currently in view from the DOM.
If your test accesses such options, you need to first scroll the options container
to the correct offset, before performing any operations on them. Use the element returned
by the findOptionsContainer test utility for this.
noMatchDisplayed for filteringType="auto" when there are no matches for the filtering.
blurCustomEvent<void>Called when input focus is removed from the UI control.
changeCustomEvent<MultiselectProps.MultiselectChangeDetail>Called when the user selects or deselects an option.
The event detail contains the current selectedOptions.
focusCustomEvent<void>Called when input focus is set onto the UI control.
loadItemsCustomEvent<OptionsLoadItemsDetail>Use this event to implement the asynchronous behavior for the component.
The event is called in the following situations:
statusType is set to pending.The detail object contains the following properties:
filteringText - The value that you need to use to fetch options.firstPage - Indicates that you should fetch the first page of options that match the filteringText.samePage - Indicates that you should fetch the same page that you have previously fetched (for example, when the user clicks on the recovery button).