Skip to main content
Version: 3.1.0-Beta 🚧

Dropdown

The Dropdown component can be used to collect user input from a list of options. This document goes through all the properties related to the Dropdown component.

info

To get the configuration of legacy Dropdown component, please refer to this document.

Data

Property
Description
Expected Value
LabelText to display as the label for the field.String (e.g., Country).
PlaceholderA hint displayed to guide the user on what to enter.String (e.g., Choose an option).

Options

Allows you to add options to the dropdown field. You can click on Add new option and add options manually or enable Dynamic options and enter the options using code.

Example Code for Dynamic Columns

  1. Passing an array of objects and specifying each value:
{{
[{label: 'option1', value: 1, disable: false, visible: true, default: true},
{label: 'option2', value: 2, disable: false, visible: true},
{label: 'option3', value: 3, disable: false, visible: true}]
}}
  1. Passing an array of objects with a default value from a Table component's selected row:
{{
queries.getEmployees.data.map(option => ({
label: option.firstname,
value: option.firstname,
disable: false,
visible: true,
default: option.firstname === components.table1.selectedRow.firstname
}))
}}

Options loading state

Allows you to add a loading state to the dynamically generated options. You can enable or disable the toggle button or dynamically configure the value by clicking on fx and entering a logical expression.

Events

On select
Triggers when an option is selected.

On search text changed
Triggers when search text changes.

On focus
Triggers whenever the user clicks inside the component.

On blur
Triggers whenever the user clicks outside the component.

Component specific actions (CSA)

Following actions of the component can be controlled using the component specific actions(CSA):

Actions
Description
How To Access
clear()Clears the selected option.Employ a RunJS query (for e.g.,
await components.dropdown1.clear()) or trigger it using an event.
setVisibility()Sets the visibility of the component.Employ a RunJS query (for e.g.,
await components.dropdown1.setVisibility(false)) or trigger it using an event.
setLoading()Sets the loading state of the component.Employ a RunJS query (for e.g.,
await components.dropdown1.setLoading(true)) or trigger it using an event.
setDisable()Disables the component.Employ a RunJS query (for e.g.,
await components.dropdown1.setDisable(true)) or trigger it using an event.
selectOption()Selects an option.Employ a RunJS query (for e.g.,
await components.dropdown1.selectOption(2)) or trigger it using an event.

Note: The data type passed to CSAs like selectOption() depends on how you configure the component. When adding options manually using the Add new option button, values must be strings (for example, components.dropdown1.selectOption(['2'])). When using dynamic options, supply values with the correct data types as they appear in your code logic.

For example, if the code is:

{{
[
{ label: 'option1', value: 1, disable: false, visible: true, default: true },
{ label: 'option2', value: 2, disable: false, visible: true },
{ label: 'option3', value: 3, disable: false, visible: true }
]
}}

You should pass numeric values in the selectOptions component-specific action since the value type is Number:

components.dropdown1.selectOption([2])

Exposed Variables

Variable
Description
How To Access
searchTextThis variable is initially empty and holds the value whenever the user searches on the dropdown.Accessible dynamically with JS (for e.g., {{components.dropdown1.searchText}}).
labelHolds the label name of the dropdown.Accessible dynamically with JS (for e.g., {{components.dropdown1.label}}).
valueHolds the value selected by the user in the component.Accessible dynamically with JS (for e.g., {{components.dropdown1.value}}).
selectedOptionHolds the label and value of the selected option in array form.Accessible dynamically with JS (for e.g., {{components.dropdown1.selectedOption.label}} or
{{components.dropdown1.selectedOption.value}}).
isValidIndicates if the input meets validation criteria.Accessible dynamically with JS (for e.g., {{components.dropdown1.isValid}}).
optionsHolds all the option values of the dropdown in array form.Accessible dynamically with JS (for e.g., {{components.dropdown1.options}} or
{{components.dropdown1.options[0].label}} for a specific option).
isVisibleIndicates if the component is visible.Accessible dynamically with JS (for e.g., {{components.dropdown1.isVisible}}).
isLoadingIndicates if the component is loading.Accessible dynamically with JS (for e.g., {{components.dropdown1.isLoading}}).
isDisabledIndicates if the component is disabled.Accessible dynamically with JS (for e.g., {{components.dropdown1.isDisabled}}).
isMandatoryIndicates if the field is required.Accessible dynamically with JS (for e.g., {{components.dropdown1.isMandatory}}).

Validation

Validation Option
Description
Expected Value
Make this field mandatoryDisplays a 'Field cannot be empty' message if no option is selected.Enable/disable the toggle button or dynamically configure the value by clicking on fx and entering a logical expression.
Custom validationSpecifies a validation error message for specific conditions.Logical Expression (e.g., {{components.dropdown.value<5&&"Value needs to be more than 5"}}).

Additional Actions

Action
Description
Configuration Options
Loading stateEnables a loading spinner, often used with isLoading to indicate progress. Toggle or set dynamically.Enable/disable the toggle button or dynamically configure the value by clicking on fx and entering a logical expression.
VisibilityControls component visibility. Toggle or set dynamically.Enable/disable the toggle button or dynamically configure the value by clicking on fx and entering a logical expression.
DisableEnables or disables the component. Toggle or set dynamically.Enable/disable the toggle button or dynamically configure the value by clicking on fx and entering a logical expression.
TooltipProvides additional information on hover. Set a string value for display.String (e.g., Enter your name here. ).

Devices

Show on desktop

Makes the component visible in desktop view. You can set it with the toggle button or dynamically configure the value by clicking on fx and entering a logical expression.

Show on mobile

Makes the component visible in mobile view. You can set it with the toggle button or dynamically configure the value by clicking on fx and entering a logical expression.


Label

Label Property
Description
Configuration Options
ColorSets the color of the component's label.Select the color or click on fx and input code that programmatically returns a Hex color code.
AlignmentSets the position of the label and input field.Click on the toggle options or click on fx to input code that programmatically returns an alignment value - side or top.
WidthSets the width of the input field.Keep the Auto width option for standard width or deselect it to modify the width using the slider or through code entry in fx that returns a numeric value.

Field

Field Property
Description
Configuration Options
BackgroundSets the background color of the component.Select the color or click on fx and input code that programmatically returns a Hex color code.
BorderSets the border color of the component.Select the color or click on fx and input code that programmatically returns a Hex color code.
TextSets the text color of the text entered in the component.Select the color or click on fx and input code that programmatically returns a Hex color code.
AccentSets the color of the border when the dropdown is opened.Select the color or click on fx and input code that programmatically returns a Hex color code.
Error textSets the text color of validation message that displays.Select the color or click on fx and input code that programmatically returns a Hex color code.
IconAllows you to select an icon for the component.Enable the icon visibility, select icon and icon color
Border radiusModifies the border radius of the component.Enter a number or click on fx and enter a code that programmatically returns a numeric value.
Box shadowSets the box shadow properties of the component.Select the box shadow color and adjust the related properties.

Container

Padding
Allows you to maintain a standard padding by enabling the Default option.