single-choice-dropdown
Version compatibility
single-choice-dropdown
is supported in all versions of the JourneyApps Container and Runtime.- It received several functional updates in version 4.84.0 of the JourneyApps Runtime.
A
single-choice-dropdown
component allows users to make a single selection from a pre-defined set of options in a dropdown component.main.view.xml
<var name="selected_country" type="single-choice">
<option key="us">USA</option>
<option key="uk">UK</option>
<option key="de">Germany</option>
...
</var>
<single-choice-dropdown label="Country of residence" bind="selected_country" required="false" />


Version compatibility
align-content
was introduced in version 4.84.0 of the JourneyApps Runtime.Optional
Type:
center
| left
| right
Default:
center
Version compatibility
align-dialog-content
was introduced in version 4.84.0 of the JourneyApps Runtime.Specifies how the content of the list of options dialog should be aligned. This includes the display value of each option, as well as the header text of the dialog.
<single-choice-dropdown label="Country of residence" align-dialog-content="left" bind="selected_country" />
Optional
Default: "Choose an option"
Version compatibility
dialog-title
was introduced in version 4.84.0 of the JourneyApps Runtime.Header text of the dialog that displays the list of options of the
single-choice-dropdown
.<single-choice-dropdown label="Country of residence" dialog-title="Choose the country of residence" bind="selected_country" />
Version compatibility
empty-message
was introduced in version 4.84.0 of the JourneyApps Runtime.Optional
Default: unset
Text that is displayed if no options are available to list once the user opens the
single-choice-dropdown
.<single-choice-dropdown label="Country of residence" bind="selected_country" empty-message="No countries are available. Please contact your administrator." />
Version compatibility
icon-position
was introduced in version 4.86.1 of the JourneyApps Runtime.Version compatibility
label-case
was introduced in version 4.84.0 of the JourneyApps Runtime.Version compatibility
modifier-text
was introduced in version 4.84.0 of the JourneyApps RunOptional
Type:
auto
| none
| show
Default:
auto
Version compatibility
search-controls
was introduced in version 4.84.0 of the JourneyApps Runtime.
Set the visibility of the search box of the
single-choice-dropdown
component. auto
shows the search box when the list of options contains 12 options or more. none
never shows the search box, and show
always shows the search box at the top of the list of options.<single-choice-dropdown label="Country of residence" bind="selected_country" search-controls="show" />
The following component methods are available when an
id
is assigned to the component and component.singleChoiceDropdown({id:'my-id'})
is called from JS/TS:Programmatically clear the selected value bound to the
single-choice-dropdown
.Programmatically clear a value entered into the search box.
Programmatically open the list of items.
Programmatically close the list of items.
Programmatically scroll down the list of items when the
single-choice-dropdown
is opened.Programmatically scroll until the
single-choice-dropdown
is visible in the view.Programmatically scroll up the list of items when the
single-choice-dropdown
is opened.Programmatically select an item from the list by its label.
main.view.xml
<var name="favorite_color" type="single-choice">
<option key="green">Green</option>
<option key="red">Red</option>
<option key="yellow">Yellow</option>
</var>
<single-choice-dropdown id="my-dropdown" bind="favorite_color" label="Favorite Color" />
main.js
function select() {
component.singleChoiceDropdown({id: 'my-dropdown'}).openDropdown(); // Need to open the dropdown first
component.singleChoiceDropdown({id: 'my-dropdown'}).selectItem('Yellow');
}
Programmatically select an item from the list by its index. Note: Indexes begin at 1.
main.view.xml
<var name="favorite_color" type="single-choice">
<option key="green">Green</option>
<option key="red">Red</option>
<option key="yellow">Yellow</option>
</var>
<single-choice-dropdown id="my-dropdown" bind="favorite_color" label="Favorite Color" />
main.js
function select() {
component.singleChoiceDropdown({id: 'my-dropdown'}).openDropdown(); // Need to open the dropdown first
component.singleChoiceDropdown({id: 'my-dropdown'}).selectItemByIndex(2);
// Selects "Red"
}
Programmatically enter a search value and triggers a search of the
single-choice-dropdown
.Last modified 3mo ago