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.
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.
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.
| <divstyle={{width:"100px"}}> Actions </div> | <divstyle={{width:"160px"}}> Description </div> | <divstyle={{width:"200px"}}> How To Access </div>|
| :------------ | :---------- | :------------ |
| clear() | Clears the selected option. | Employ a RunJS query (for e.g., <br/>`await components.dropdown1.clear()`) or trigger it using an event. |
| setVisibility()| Sets the visibility of the component. | Employ a RunJS query (for e.g., <br/>`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., <br/>`await components.dropdown1.setLoading(true)`) or trigger it using an event. |
| setDisable() | Disables the component. | Employ a RunJS query (for e.g., <br/>`await components.dropdown1.setDisable(true)`) or trigger it using an event. |
| selectOption() | Selects an option. | Employ a RunJS query (for e.g., <br/>`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.
| <divstyle={{width:"100px"}}> Variable </div> | <divstyle={{width:"200px"}}> Description </div> | <divstyle={{width:"200px"}}> How To Access </div>|
|:----------|:----------|:------------|
| searchText | This 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}}`). |
| label | Holds the label name of the dropdown. | Accessible dynamically with JS (for e.g., `{{components.dropdown1.label}}`). |
| selectedOption | Holds the label and value of the selected option in array form. | Accessible dynamically with JS (for e.g., `{{components.dropdown1.selectedOption.label}}` or <br/>`{{components.dropdown1.selectedOption.value}}`). |
| isValid | Indicates if the input meets validation criteria. | Accessible dynamically with JS (for e.g., `{{components.dropdown1.isValid}}`). |
| options | Holds all the option values of the dropdown in array form. | Accessible dynamically with JS (for e.g., `{{components.dropdown1.options}}` or <br/>`{{components.dropdown1.options[0].label}}` for a specific option). |
| isVisible | Indicates if the component is visible. | Accessible dynamically with JS (for e.g., `{{components.dropdown1.isVisible}}`). |
| isLoading | Indicates if the component is loading. | Accessible dynamically with JS (for e.g., `{{components.dropdown1.isLoading}}`). |
| isDisabled | Indicates if the component is disabled. | Accessible dynamically with JS (for e.g., `{{components.dropdown1.isDisabled}}`). |
| isMandatory | Indicates if the field is required. | Accessible dynamically with JS (for e.g., `{{components.dropdown1.isMandatory}}`). |
| Make this field mandatory | Displays 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 validation | Specifies a validation error message for specific conditions. | Logical Expression (e.g., `{{components.dropdown.value<5&&"Value needs to be more than 5"}}`). |
| Loading state | Enables 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. |
| Visibility | Controls 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. |
| Disable | Enables 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. |
| Tooltip | Provides additional information on hover. Set a string value for display. | String (e.g., `Enter your name here.` ). |
| 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. |
| Color | Sets the color of the component's label. | Select the color or click on **fx** and input code that programmatically returns a Hex color code. |
| Alignment | Sets 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`. |
| Width | Sets 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. |
| Background | Sets the background color of the component. | Select the color or click on **fx** and input code that programmatically returns a Hex color code. |
| Border | Sets the border color of the component. | Select the color or click on **fx** and input code that programmatically returns a Hex color code. |
| Text | Sets 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. |
| Accent | Sets 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 text | Sets 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. |
| Icon | Allows you to select an icon for the component. | Enable the icon visibility, select icon and icon color |
| Border radius | Modifies the border radius of the component. | Enter a number or click on **fx** and enter a code that programmatically returns a numeric value. |
| Box shadow | Sets the box shadow properties of the component. | Select the box shadow color and adjust the related properties. |