Vivid API

Searchable Select

Searchable Select allows users to select one or multiple items from a list of options. It provides a search input field to filter the options.

Usage

import { registerSearchableSelect } from '@vonage/vivid-api';
registerSearchableSelect('your-prefix');

Controlling the Value

Single Select

For a single select, you can control the selected value by setting the value attribute.

Multiple Select

For multiple select, you can control the selected values by setting the values property.

Web components (as with all HTML elements) can only accept strings as their attributes. values requires an array, so it has to be set programmatically.

Fixed Dropdown

Add the fixed-dropdown attribute to change the dropdown to use a fixed position strategy. This is useful for cases in which the dropdown is obstructed by other elements.

Open

The open attribute allows the Searchable Select to be opened programmatically.

Search Text

You can access the current search text through the searchText property and listen for changes through the search-text-change event.

Option Filtering

You can control option filtering by setting optionFilter to a custom function. For example, always returning true will disable filtering by always showing all options.

Slots

Default

Holds the available options as Option elements.

You can use the Option’s tag-icon slot to display an icon next to the selected option’s tag.

Hidden Options

Setting hidden on an Option will hide it from the dropdown while still allowing it to be a selected value.

Icon

Set the icon slot to show an icon at the start of the input. If set, the icon(deprecated) attribute is ignored.

Meta

Use the meta slot to show meta information at the end of the input field.

Helper Text

The helper-text slot allows you to use rich content as the helper text.

Contextual Help

The contextual-help slot allows you to add the Contextual Help component next to the label.

Custom Width

You can specify width on the Searchable Select to control the width of the component. The default width is 300px.

The dropdown has min-width of its content.

CSS Variables

Height

Use --searchable-select-height to set the max-height of the dropdown. The default value is 408px.

API Reference

searchable-select

Properties

PropertyTypeDefaultDescription
appearance'fieldset' | 'ghost'Sets the appearance of the Searchable Select element.
clearablebooleanAdds a clear button to the input field that clears the selected values.
deselectAllTextstringOverrides the default "Deselect All" text.
disabledbooleanSets the element's disabled state. A disabled element will not be included during form submission.
enableSelectAllbooleanAdds a "Select All" option at the top of the options list.
errorTextstringProvides a custom error message. Any current error state will be overridden.
externalTagsboolean
fixedDropdownboolean
helperTextstringProvides additional information to help the user enter the correct information. To add HTML to the helper text, use the helper-text slot instead.
iconTrailingbooleanIndicates the icon affix alignment.
initialValuestringThe default value of the element. This value sets the `value` property only when the `value` property has not been explicitly set.
initialValuesstring[]List of initially selected option's values. Used in case of form reset.
labelstringThe label for the form element.
loadingbooleanWhether the component is in a loading state.
maxLinesnumber
maxSelectednumber
multipleboolean
namestringThe name of the element. This element's value will be surfaced during form submission under the provided name.
openboolean
optionFilter((option: @vonage/vivid-api#VwcOptionElement, searchText: string) => boolean)Function to filter the options to display.
placeholderstring
requiredbooleanRequire the field to be completed prior to form submission.
scale'condensed' | 'normal'Sets the display size of the Searchable Select element.
selectAllTextstringOverrides the default "Select All" text.
selectedIndexnumber
shape'rounded' | 'pill'Sets the shape of the Searchable Select element.
successTextstringProvides a custom success message. Any current error state will be overridden.
value
(modelValue)
stringThe current value of the element.
values
(values)
string[]List of selected option's values in the order that they have been selected in.
PropertyTypeDefaultDescription
appearance'fieldset' | 'ghost'Sets the appearance of the Searchable Select element.
clearablebooleanAdds a clear button to the input field that clears the selected values.
deselect-all-textstringOverrides the default "Deselect All" text.
disabledbooleanSets the element's disabled state. A disabled element will not be included during form submission.
enable-select-allbooleanAdds a "Select All" option at the top of the options list.
error-textstringProvides a custom error message. Any current error state will be overridden.
external-tagsboolean
fixed-dropdownboolean
helper-textstringProvides additional information to help the user enter the correct information. To add HTML to the helper text, use the helper-text slot instead.
icon-trailingbooleanIndicates the icon affix alignment.
valuestringThe default value of the element. This value sets the `value` property only when the `value` property has not been explicitly set.
initialValues
(property only)
string[]List of initially selected option's values. Used in case of form reset.
labelstringThe label for the form element.
loadingbooleanWhether the component is in a loading state.
max-linesnumber
max-selectednumber
multipleboolean
namestringThe name of the element. This element's value will be surfaced during form submission under the provided name.
openboolean
optionFilter
(property only)
((option: @vonage/vivid-api#VwcOptionElement, searchText: string) => boolean)Function to filter the options to display.
placeholderstring
requiredbooleanRequire the field to be completed prior to form submission.
scale'condensed' | 'normal'Sets the display size of the Searchable Select element.
select-all-textstringOverrides the default "Select All" text.
selectedIndex
(property only)
number
shape'rounded' | 'pill'Sets the shape of the Searchable Select element.
success-textstringProvides a custom success message. Any current error state will be overridden.
current-valuestringThe current value of the element.
values
(property only)
string[]List of selected option's values in the order that they have been selected in.

Slots

NameDescription
contextual-helpSlot for the contextual-help component, displayed next to the label.
defaultHolds the available options.
helper-textDescribes how to use the component. Alternative to the `helper-text` attribute.
iconThe preferred way to add an icon to the control.
loading-optionsMessage that appears there are no options to display and the component is in a loading state.
metaSlot to add meta content to the control.
no-matchesMessage that appears when no options match the search query.
no-optionsMessage that appears when no options are available.
NameDescription
contextual-helpSlot for the contextual-help component, displayed next to the label.
defaultHolds the available options.
helper-textDescribes how to use the component. Alternative to the `helper-text` attribute.
iconThe preferred way to add an icon to the control.
loading-optionsMessage that appears there are no options to display and the component is in a loading state.
metaSlot to add meta content to the control.
no-matchesMessage that appears when no options match the search query.
no-optionsMessage that appears when no options are available.

Events

NameTypeDescription
changeCustomEvent<undefined>Fired when the selected options change
inputCustomEvent<undefined>Fired when the selected options change
search-text-changeCustomEvent<undefined>Fired when the search text changes
NameTypeDescription
changeCustomEvent<undefined>Fired when the selected options change
inputCustomEvent<undefined>Fired when the selected options change
search-text-changeCustomEvent<undefined>Fired when the search text changes

Methods

NameParamsReturnsDescription
checkValiditybooleanReturn the current validity of the element.
reportValiditybooleanReturn the current validity of the element. If false, fires an invalid event at the element.

option

Properties

PropertyTypeDefaultDescription
checkedfalse | trueThe checked state is used when the parent listbox is in multiple selection mode. To avoid accessibility conflicts, the checked state should not be present in single selection mode.
connotation'accent' | 'cta'Sets the connotation that appears when selected
defaultSelectedbooleanSets the option's initial selected state (mirrors the native `selected` attribute)
disabledbooleanThe disabled state of the option.
iconTrailingbooleanIndicates the icon affix alignment.
_labelstring
matchedTextstringText to highlighted as matching a search query
selectedbooleanIndicates whether the option is currently selected
selectedAttributeboolean
tagConnotation'accent' | 'cta'When displayed as a tag, the connotation of the tag
_textstring
textSecondarystringSecondary text displayed below or next to the primary text
valuestringThe value of the option.
PropertyTypeDefaultDescription
checkedfalse | trueThe checked state is used when the parent listbox is in multiple selection mode. To avoid accessibility conflicts, the checked state should not be present in single selection mode.
connotation'accent' | 'cta'Sets the connotation that appears when selected
selectedbooleanSets the option's initial selected state (mirrors the native `selected` attribute)
disabledbooleanThe disabled state of the option.
icon-trailingbooleanIndicates the icon affix alignment.
labelstring
matched-textstringText to highlighted as matching a search query
current-selectedbooleanIndicates whether the option is currently selected
selectedAttribute
(property only)
boolean
tag-connotation'accent' | 'cta'When displayed as a tag, the connotation of the tag
textstring
text-secondarystringSecondary text displayed below or next to the primary text
valuestringThe value of the option.

Slots

NameDescription
iconThe preferred way to add an icon to the component.
tag-iconIcon to be displayed in the tag when selected inside of Searchable Select.
trailing-metaFor additional elements at the end of the Option.
NameDescription
iconThe preferred way to add an icon to the component.
tag-iconIcon to be displayed in the tag when selected inside of Searchable Select.
trailing-metaFor additional elements at the end of the Option.