Skip to main content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Components

Select

Use: Deployed English, Spanish USWDS v3
A select component allows users to choose one option from a menu.

Examples - v3

Default

View va-select default in Storybook

Required

View va-select required in Storybook

With 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

Examples - v1

Default

View va-select v3 along with additional variations in Storybook

Usage

Refer to the U.S. Web Design System for usage guidance

Additional guidance for VA

Additional reasons to consider something else

More than 15 options. If the list of options is very long, we do not yet have the combo box component in our system thus an alternative is to use functionality that allows users to type the same information into a text input that suggests possible options instead as seen in our search input component.

Code usage

Attributes and Properties

Property Attribute Type Default Description
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.
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.
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.
uswds uswds boolean true Whether or not the component will use USWDS v3 styling.
value value string Selected value (will get updated on select).

Events

Name Description
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

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

Refer to the U.S. Web Design System for accessibility guidance

Component checklist

Maturity

Guidance
Examples, usage, code usage, content considerations, and accessibility considerations are all complete.
Research
VFS team conducted research on this component which is linked from this page.
Stability
Component has been in production for more than 3 months with no significant issues found.
Adoption
Multiple teams have adopted this component.

Accessibility

Accessible use of color
Color is not used as the only visual means of conveying information (WCAG 2.2 1.4.1).
Accessible contrast
Text has a contrast ratio of at least 4.5:1 for small text and at least 3:1 for large text (WCAG 2.2 1.4.3). Visual information required to identify components and states (except inactive components) has a contrast ratio of at least 3:1 (WCAG 2.2 1.4.11).
Keyboard interactions
Follows WCAG 2.2 standards for keyboard accessibility guidelines and includes a description of the keyboard interactions. All interactive elements can be selected and activated using the keyboard.
Content zoom tested
Component has been tested with the display set to 400% at 1280px viewport width to ensure that the component does not have overlapping text or elements and all interactive elements still operate.
Tested in screen readers
Tested with screen readers to ensure there are no issues with reading order, spelling, dynamic content, and interactive elements.

Code assets

Variations
Storybook includes all variations (style, size, orientation, optional iconography, selection, error state, etc.)
Responsive
Component depicted in all responsive breakpoints.
Interactive states
Includes all interactive states that are applicable (hover, active, focus, keyboard focus, disabled).
Tokens
All design attributes (color, typography, layout, etc.) are available as tokens.
Internationalization
Describes i18n attributes.

Visual assets

Variations
Sketch library includes all variations (style, size, orientation, optional iconography, selection, error state, etc.)
Responsive
Component designed to work in all responsive breakpoints.
Interactive states
Includes all interactive states that are applicable (hover, active, focus, keyboard focus, disabled).
Tokens
All design attributes (color, typography, layout, etc.) are available as tokens.
100% complete (16 of 16)

Legend:

  • Complete
  • Incomplete
  • Not applicable
Edit this page in GitHub (Permissions required)
Last updated: Mar 13, 2024