Vivid API

Select

Select lets users choose one option from an options menu. Consider using select when you have 4 or more options to choose from.

Usage

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

Custom Width

By default, the Select’s width is fit-content and the same goes for the listbox containing the options.

You can specify the width of the Select using CSS.

Fixed Dropdown

The fixed-dropdown attribute is useful for cases in which the dropdown is obstructed by other elements.

In the example below, if fixed-dropdown was not set on the Select, the select dropdown would be cut off where the Dialog ends. Also, see the Grid Select example).

Open

The open attribute allows the Select to be opened programmatically.

Document elements display precedence is formed by the imaginary z-axis stacking context, commonly by order of which elements are rendered and special properties (e.g. z-index).

Select component is a low level element, unaware of its document context, but is, in most cases, required to overlay on top of all elements. If needed a z-index value can be set on the host.

Slots

Default Slot

This is where you place the Option components to provide the option list.

Meta Slot

Set the meta slot to show meta information after the selected option label.

Icon Slot

Set the icon slot to show an icon before the selected option text. If set, the icon attribute is ignored.

Helper Text Slot

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

Contextual Help Slot

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

CSS Variables

Use --select-height to customize the max-height of the dropdown.

API Reference

select

Properties

PropertyTypeDefaultDescription
appearance'fieldset' | 'ghost'Sets the element's appearance
clearablebooleanAdds a clear button to the select that clears the selected value(s).
disabledbooleanSets the element's disabled state. A disabled element will not be included during form submission.
errorTextstringProvides a custom error message. Any current error state will be overridden.
fixedDropdownbooleanSets the position strategy of the dropdown to fixed
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.
labelstringThe label for the form element.
multiplebooleanIndicates if the listbox is in multi-selection mode.
namestringThe name of the element. This element's value will be surfaced during form submission under the provided name.
openbooleanSets the element's menu to be open
options@vonage/vivid-api#VwcOptionElement[]The list of options.
placeholderstringSets the text to be displayed when no option is selected
requiredbooleanRequire the field to be completed prior to form submission.
scale'condensed' | 'normal'Sets the display size of the input element
selectedIndexnumberThe index of the selected option.
selectedOptions@vonage/vivid-api#VwcOptionElement[]A collection of the selected options.
shape'rounded' | 'pill'Sets the shape of the select element
successTextstringProvides a custom success message. Any current error state will be overridden.
value
(modelValue)
stringThe current value of the element.
PropertyTypeDefaultDescription
appearance'fieldset' | 'ghost'Sets the element's appearance
clearablebooleanAdds a clear button to the select that clears the selected value(s).
disabledbooleanSets the element's disabled state. A disabled element will not be included during form submission.
error-textstringProvides a custom error message. Any current error state will be overridden.
fixed-dropdownbooleanSets the position strategy of the dropdown to fixed
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.
labelstringThe label for the form element.
multiplebooleanIndicates if the listbox is in multi-selection mode.
namestringThe name of the element. This element's value will be surfaced during form submission under the provided name.
openbooleanSets the element's menu to be open
options
(property only)
@vonage/vivid-api#VwcOptionElement[]The list of options.
placeholderstringSets the text to be displayed when no option is selected
requiredbooleanRequire the field to be completed prior to form submission.
scale'condensed' | 'normal'Sets the display size of the input element
selectedIndex
(property only)
numberThe index of the selected option.
selectedOptions
(property only)
@vonage/vivid-api#VwcOptionElement[]A collection of the selected options.
shape'rounded' | 'pill'Sets the shape of the select element
success-textstringProvides a custom success message. Any current error state will be overridden.
current-valuestringThe current value of the element.

Slots

NameDescription
contextual-helpSlot for the contextual-help component, displayed next to the label.
defaultDefault slot.
helper-textDescribes how to use the select. Alternative to the `helper-text` attribute.
iconThe preferred way to add an icon to the select control.
metaSlot to add meta content to the select control.
NameDescription
contextual-helpSlot for the contextual-help component, displayed next to the label.
defaultDefault slot.
helper-textDescribes how to use the select. Alternative to the `helper-text` attribute.
iconThe preferred way to add an icon to the select control.
metaSlot to add meta content to the select control.

Events

NameTypeDescription
changeCustomEvent<HTMLElement>Fires a custom 'change' event when the value updates
inputCustomEvent<undefined>Fires a custom 'input' event when the value updates
NameTypeDescription
changeCustomEvent<HTMLElement>Fires a custom 'change' event when the value updates
inputCustomEvent<undefined>Fires a custom 'input' event when the value updates

Methods

NameParamsReturnsDescription
checkValiditybooleanReturn the current validity of the element.
formResetCallbackvoid
reportValiditybooleanReturn the current validity of the element. If false, fires an invalid event at the element.
selectFirstOptionvoidMoves focus to the first selectable option.
slottedOptionsChanged
prev: undefined | Element[]
next: Element[]
void

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.