Defines a component's value as the text content of the selected item


Purpose: defines a value property that reflects the text content of a selected item.

This mixin is independent of the Elix Elix render pipeline.

Expects the component to provide:

  • selectedIndex state member indicating the index of the currently selected item. This is usually provided by SingleSelectionMixin.
  • items state member representing the items that can be selected. This is usually provided by ContentItemsMixin.

Provides the component with:

  • value property representing the text content of the currently-selected item.


import SelectedItemTextValueMixin from "elix/src/base/SelectedItemTextValueMixin.js";
class MyElement extends SelectedItemTextValueMixin(HTMLElement) {}

This mixin exists for list-like components that want to provide a more convenient way to get/set the selected item using text. It adds a value property that gets the textContent of a component's selectedItem. The value property can also be set to set the selection to the first item in the items collection that has the requested textContent. If the indicated text is not found in items, the selection is cleared.


Used by classes DropdownList, FilterListBox, ListBox, ListWithSearch, Menu, PlainDropdownList, PlainFilterListBox, PlainListBox, PlainListWithSearch, and PlainMenu.

value property

The text content of the selected item.

Setting this value to a string will attempt to select the first list item whose text content match that string. Setting this to a string not matching any list item will result in no selection.

Type: string