Select Input
A select input is a form control for selecting a single item from a list of options.
Default Select Example
When to Use
- Use a select input when there is a predetermined set of options from which to choose. This will reduce errors when users type in answers.
- Use when there are more than two options and when only a single option can be selected.
When Not to Use
- Do not use a select input if only two options are available or if it is preferable for the user to see the available options. Instead, consider a radio button or toggle.
- Do not use if multiple options can be selected. Consider checkboxes or a multi-select instead.
Examples
- Default Example (shown above)
- Default with Error Example
- Select Group Example
Usage
Prefill a select input when it is likely that a user will select one of the available options.
The collapsed state of the select input is styled to match the size and visual treatment of the other form controls; however, the expanded list of options should use the native control on both desktop and mobile devices.
Examples
Default with Error
Select Group
Select groups are useful for form fields requiring multiple interdependent selections. For example, date selection (day, month, and year). If inputs are not directly related to one another, use independent select inputs.
Developer Notes
Select inputs are distinguished from text input fields with an actionable down arrow to the right side of the element. They implement the Messaging and Validation mixins, and provide mechanisms for getting and setting their value.
The following options may be passed when using new Spark.SelectInput(el, {});
:
For all available methods and full API, refer to the component code on Bitbucket.
Default Select Input
Select Group
A group of select inputs can exist inside the same container. Simply wrap a set of elements with the class of spark-select
in a containing element with a class of spark-select-group
. Create an instance of the Spark.SelectInput
helper for each of the inputs.