Components
Select
use: best-practiceExamples
Default
View va-select default in Storybook
Required
View va-select required in Storybook
Hint text
View va-select with hint text in Storybook
Read only
View va-select inert, or read only in Storybook
Error
View va-select error message in Storybook
Dynamic options
View va-select dynamic options in Storybook
Internationalization
View va-select internationalization in Storybook
Widths
View va-select widths in Storybook
Forms pattern - Single
View va-select forms pattern single in Storybook
Forms pattern - Single error
View Error state for single select pattern in Storybook
Forms pattern - Multiple
View Multiple select pattern example in Storybook
Usage
Additional guidance for VA
Choosing between variations
- Use the Forms pattern - Single and Forms pattern - Multiple variations for implementing the Ask users for a single response pattern. These component variations are specifically designed to help implement the single response pattern. The Forms pattern - Single error variation shows error handling for the component variation. For select components used outside of this pattern, for example on a longer form page, use the standard select variations.
Choosing the right component for the task
When deciding which component to use, consider the number of options available to the user. The total number of options will determine which component is right for the task:
- 2 - 5 options: Use Radio button when there are only a few options that can all be exposed at once.
- 6 - 15 options: Use Select for a limited number of options.
- 16 - 100 options: Use Combo box, which combines a select with typeahead functionality for easier selection.
- 101+ options: Use Search input with typeahead to help users quickly find the right option from a large set.
Exceptions to consider when choosing a component
In some cases, exceptions may be considered when choosing the right component:
- When the options are known and memorable. Use Combo box if the user will know what to expect as options in the dropdown, such as a list of countries or states. See the USWDS address pattern.
- When the radio button labels are long or radio tiles contain descriptive text. Long labels within a dropdown might make it difficult to read and select an option. Radio tiles often include descriptive text that cannot be used in a dropdown. In these cases, Radio button may be the better choice.
Contact the Design System team via #platform-design-system for help if you have other use cases that may be considered exceptions.
Errors
- Refer to the specific error example above.
Hint text
- Refer to the hint text example above.
Code usage
Web
Attributes and Properties
enableAnalytics
enable-analytics
boolean
false
Whether or not to fire the analytics events
error
error
string
Error message to display. When defined, this indicates an error.
formHeading
form-heading
string
The content of the heading if useFormsPattern is true.
formHeadingLevel
form-heading-level
number
3
The heading level for the heading if useFormsPattern is true.
fullWidth
full-width
boolean
false
If true, sets the select to take the full-width of its container
headerAriaDescribedby
header-aria-describedby
string
An optional message that will be read by screen readers when the header is focused. The label-header-level prop must be set for this to be active.
hideRequiredText
hide-required-text
boolean
false
Whether or not to show the (*Required) text.
hint
hint
string
Optional hint text.
invalid
invalid
boolean
false
Whether or not aria-invalid will be set on the inner select. Useful when
composing the component into something larger, like a date component.
label
label
string
Text label for the field.
labelHeaderLevel
label-header-level
string
Insert a header with defined level inside the label
messageAriaDescribedby
message-aria-describedby
string
An optional message that will be read by screen readers when the select is focused.
name
name
string
Name attribute for the select field.
reflectInputError
reflect-input-error
boolean
false
Whether or not to add usa-input–error as class if error message is outside of component
required
required
boolean
false
Whether or not this is a required field.
showError
show-error
boolean
true
Whether an error message should be shown - set to false when this component is used inside va-date or va-memorable-date in which the error for the va-select will be rendered outside of va-select
useFormsPattern
use-forms-pattern
string
Enabling this will add a heading and description for integrating into the forms pattern. Accepts single or multiple to indicate if the form is a single input or will have multiple inputs
value
value
string
Selected value (will get updated on select).
width
width
string
Displays the select at a specific width. Accepts 2xs (4ex), xs (7ex), sm or small (10ex), md or medium (20ex), lg (30ex), xl (40ex), and 2xl (50ex). Defined in USWDS here: https://github.com/uswds/uswds/blob/develop/packages/uswds-core/src/styles/tokens/units/input-widths.scss
Events
component-library-analytics
The event used to track usage of the component. This is emitted when an
option is selected and enableAnalytics is true.
vaKeyDown
The event attached to select's onkeydown
vaSelect
The event emitted when the selected value changes
vaSelectBlur
The event emitted when the select element is blurred
Native Events
- The native onKeyDown event is available on this component. It can be used by adding the event handler to your component and it will then listen to the event and respond accordingly when the event fires.
Accessibility considerations
Privacy guidance
When Personally Identifiable Information (PII) or Protected Health Information (PHI) is an option in a selection list, selections can’t be tracked in analytics or passed into other page elements that may be tracked.
- Analytics tracking for this component must remain off if the options contain PII or PHI.
- Selections can’t be utilized in elements on follow-on or related pages, such as a parameter or title tag.
Example: A form application asks the user to select a health condition from a dropdown list. Details about a person’s health conditions are considered PHI. The option selected can be stored in our data systems, but the selection can’t be tracked in analytics or utilized as part of the title tag in the next page.
Learn more about PII/PHI on the VA Platform website
Component checklist
Web Platform
11 of 11 complete
Maturity
-
Guidance
-
Web
Examples, usage, code usage, content considerations, and accessibility considerations are all complete. -
Research
-
Web
VFS team conducted research on this component which is linked from this page. -
Stability
-
Web
Component has been in production for more than 3 months with no significant issues found. -
Adoption
-
Web
Multiple teams have adopted this component.
Accessibility
While this component has been previously tested against older criteria, it has not yet been audited with the updated testing criteria.
Code assets
-
Variations
-
Web
Storybook includes all variations (style, size, orientation, optional iconography, selection, error state, etc.) -
Responsive
-
Web
Component depicted in all responsive breakpoints. -
Interactive states
-
Web
Includes all interactive states that are applicable (hover, active, focus, keyboard focus, disabled). -
Tokens
-
N/A Web
All design attributes (color, typography, layout, etc.) are available as tokens. -
Internationalization
-
Web
Describes i18n attributes.
Visual assets
-
Variations
-
Web
Figma library includes all variations (style, size, orientation, optional iconography, selection, error state, etc.) -
Responsive
-
Web
Component designed to work in all responsive breakpoints. -
Interactive states
-
Web
Includes all interactive states that are applicable (hover, active, focus, keyboard focus, disabled). -
Tokens
-
N/A Web
All design attributes (color, typography, layout, etc.) are available as tokens.
Legend:
-
Complete -
Incomplete - N/A Not applicable
Provide feedback
Share your feedback, report issues, or suggest improvements for the Select component. Your input helps us make the design system better for everyone.
- Get immediate support in #platform-design-system for technical or urgent issues.
- Explore all feedback channels for additional ways to share your input.