Dropdown Select
The DropdownSelect question type presents users with a dropdown list from which they can select one answer.
Basic Usage
Parameters
Unique identifier for the question.
The main question text.
Additional text to provide context or instructions.
An array of strings representing the available options.
Whether the question is required.
The placeholder text displayed when no option is selected.
A custom validation function that takes the response as input and returns true if valid, or an error message string if invalid.
Custom styles to apply to the question. Available keys are:
root
innerContainer
textContainer
text
subText
select
option
errorMessage
Data
Response Format
The DropdownSelect question type returns a string representing the selected option:
Validation
The DropdownSelect question validates that:
- An option has been selected when required is set to true.
- The selected option is valid (exists in the options array).
- Any custom validation provided in the
customValidation
function passes.
If validation fails, it displays an appropriate error message.
Methods
The DropdownSelect question type inherits methods from the base Element class and includes some specific methods:
Set the response for the question.
Parameters:
value
(string): The selected option
Validate the current response against the question’s rules.
Returns:
- An object with
isValid
(boolean) anderrorMessage
(string) properties.
Example
Here’s an example of how to create a customized dropdown select question: