Vivid Logo Vivid

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';

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

Property Type Default Description
appearance 'fieldset' | 'ghost' Sets the appearance of the Searchable Select element.
clearable boolean Adds a clear button to the input field that clears the selected values.
deselectAllText string Overrides the default "Deselect All" text.
disabled boolean Sets the element's disabled state. A disabled element will not be included during form submission.
enableSelectAll boolean Adds a "Select All" option at the top of the options list.
errorText string Provides a custom error message. Any current error state will be overridden.
externalTags boolean
fixedDropdown boolean
helperText string Provides additional information to help the user enter the correct information. To add HTML to the helper text, use the helper-text slot instead.
icon IconId A decorative icon the custom element should have. See the [Vivid Icon Gallery](/icons/icons-gallery/) for available icons and `icon-name`s See the Vivid Icon Gallery for available icons: https://icons.vivid.vonage.com/
iconTrailing boolean Indicates the icon affix alignment.
initialValue string The default value of the element. This value sets the `value` property only when the `value` property has not been explicitly set.
initialValues string[] List of initially selected option's values. Used in case of form reset.
label string The label for the form element.
loading boolean Whether the component is in a loading state.
maxLines number
maxSelected number
multiple boolean
name string The name of the element. This element's value will be surfaced during form submission under the provided name.
open boolean
optionFilter ((option: @vonage/vivid#VwcOptionElement, searchText: string) => boolean) Function to filter the options to display.
placeholder string
required boolean Require the field to be completed prior to form submission.
scale 'condensed' | 'normal' Sets the display size of the Searchable Select element.
selectAllText string Overrides the default "Select All" text.
selectedIndex number
shape 'rounded' | 'pill' Sets the shape of the Searchable Select element.
successText string Provides a custom success message. Any current error state will be overridden.
value
(modelValue)
string The current value of the element.
values
(values)
string[] List of selected option's values in the order that they have been selected in.
Property Type Default Description
appearance 'fieldset' | 'ghost' Sets the appearance of the Searchable Select element.
clearable boolean Adds a clear button to the input field that clears the selected values.
deselect-all-text string Overrides the default "Deselect All" text.
disabled boolean Sets the element's disabled state. A disabled element will not be included during form submission.
enable-select-all boolean Adds a "Select All" option at the top of the options list.
error-text string Provides a custom error message. Any current error state will be overridden.
external-tags boolean
fixed-dropdown boolean
helper-text string Provides additional information to help the user enter the correct information. To add HTML to the helper text, use the helper-text slot instead.
icon IconId A decorative icon the custom element should have. See the [Vivid Icon Gallery](/icons/icons-gallery/) for available icons and `icon-name`s See the Vivid Icon Gallery for available icons: https://icons.vivid.vonage.com/
icon-trailing boolean Indicates the icon affix alignment.
value string The 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.
label string The label for the form element.
loading boolean Whether the component is in a loading state.
max-lines number
max-selected number
multiple boolean
name string The name of the element. This element's value will be surfaced during form submission under the provided name.
open boolean
optionFilter
(property only)
((option: @vonage/vivid#VwcOptionElement, searchText: string) => boolean) Function to filter the options to display.
placeholder string
required boolean Require the field to be completed prior to form submission.
scale 'condensed' | 'normal' Sets the display size of the Searchable Select element.
select-all-text string Overrides the default "Select All" text.
selectedIndex
(property only)
number
shape 'rounded' | 'pill' Sets the shape of the Searchable Select element.
success-text string Provides a custom success message. Any current error state will be overridden.
current-value string The 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

Name Description
contextual-help Slot for the contextual-help component, displayed next to the label.
default Holds the available options.
helper-text Describes how to use the component. Alternative to the `helper-text` attribute.
icon The preferred way to add an icon to the control.
loading-options Message that appears there are no options to display and the component is in a loading state.
meta Slot to add meta content to the control.
no-matches Message that appears when no options match the search query.
no-options Message that appears when no options are available.
Name Description
contextual-help Slot for the contextual-help component, displayed next to the label.
default Holds the available options.
helper-text Describes how to use the component. Alternative to the `helper-text` attribute.
icon The preferred way to add an icon to the control.
loading-options Message that appears there are no options to display and the component is in a loading state.
meta Slot to add meta content to the control.
no-matches Message that appears when no options match the search query.
no-options Message that appears when no options are available.

Events

Event Type Description
change CustomEvent<undefined> Fired when the selected options change
input CustomEvent<undefined> Fired when the selected options change
search-text-change CustomEvent<undefined> Fired when the search text changes
update:modelValue string Fires when the modelValue value changes
update:values string[] Fires when the values value changes
Name Type Description
change CustomEvent<undefined> Fired when the selected options change
input CustomEvent<undefined> Fired when the selected options change
search-text-change CustomEvent<undefined> Fired when the search text changes

Methods

Name Params Returns Description
checkValidity boolean Return the current validity of the element.
reportValidity boolean Return the current validity of the element. If false, fires an invalid event at the element.

option

Properties

Property Type Default Description
checked false | true The 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
defaultSelected boolean Sets the option's initial selected state (mirrors the native `selected` attribute)
disabled boolean The disabled state of the option.
icon IconId A decorative icon the custom element should have. See the [Vivid Icon Gallery](/icons/icons-gallery/) for available icons and `icon-name`s See the Vivid Icon Gallery for available icons: https://icons.vivid.vonage.com/
iconTrailing boolean Indicates the icon affix alignment.
label string
matchedText string Text to highlighted as matching a search query
selected boolean Indicates whether the option is currently selected
selectedAttribute boolean
tagConnotation 'accent' | 'cta' When displayed as a tag, the connotation of the tag
text string
textSecondary string Secondary text displayed below or next to the primary text
value string The value of the option.
Property Type Default Description
checked false | true The 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
selected boolean Sets the option's initial selected state (mirrors the native `selected` attribute)
disabled boolean The disabled state of the option.
icon IconId A decorative icon the custom element should have. See the [Vivid Icon Gallery](/icons/icons-gallery/) for available icons and `icon-name`s See the Vivid Icon Gallery for available icons: https://icons.vivid.vonage.com/
icon-trailing boolean Indicates the icon affix alignment.
label string
matched-text string Text to highlighted as matching a search query
current-selected boolean Indicates whether the option is currently selected
selectedAttribute
(property only)
boolean
tag-connotation 'accent' | 'cta' When displayed as a tag, the connotation of the tag
text string
text-secondary string Secondary text displayed below or next to the primary text
value string The value of the option.

Slots

Name Description
icon The preferred way to add an icon to the component.
tag-icon Icon to be displayed in the tag when selected inside of Searchable Select.
trailing-meta For additional elements at the end of the Option.
Name Description
icon The preferred way to add an icon to the component.
tag-icon Icon to be displayed in the tag when selected inside of Searchable Select.
trailing-meta For additional elements at the end of the Option.