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

Memorable Date

Use with caution: Available
Three text fields are the easiest way for users to enter most dates.

View va-memorable-date in Storybook

Usage

When to use date inputs

  • Appropriate for most dates.

When to consider something else

  • Consider a date picker for scheduling. If users are trying to schedule something, the date picker might make more sense. Be sure to also provide an option for text entry as well.

Note: We do not currently have a calendar picker as part of the design system. For reference, visit the VA online scheduling tool (VAOS) to see an experimental version of a calendar picker.

Usability Guidance

  • Label each field. Be sure each field is properly labeled — some countries enter dates in day, month, year order.
  • Avoid select elements. It may be tempting to switch all or some of these text fields to select elements, but these tend to be more difficult to use than text boxes.

How to use date inputs

  • The year input is set to accept only a four-digit number while the month and day inputs can accept up to a two-digit number.
  • Always use back-end validation on dates for correctness.

Code usage

Attributes and Properties

Property Attribute Type Default Description
enableAnalytics enable-analytics boolean false Whether or not an analytics event will be fired.
error error string The error message to render (if any) This prop should be leveraged to display any custom validations needed for this component
invalidDay invalid-day boolean false
invalidMonth invalid-month boolean false
invalidYear invalid-year boolean false
label label string Label for the field.
name name string Used to create unique name attributes for each input.
required required boolean false Render marker indicating field is required.
value value string Set the default date value must be in YYYY-MM-DD format.

Events

Name Description
component-library-analytics The event used to track usage of the component. This is emitted when an input value changes and enableAnalytics is true.
dateBlur Fires when the date input loses focus
dateChange Fires when the date input loses focus after its value was changed

Accessibility considerations

  • Follow input guidance. These text fields should follow the accessibility guidelines for all text inputs.
  • Don’t auto-advance focus. Do not use JavaScript to auto advance the focus from one field to the next. This makes it difficult for keyboard-only users to navigate and correct mistakes.
  • Use “text” instead of “number” inputs. Research indicates that numeric inputs still carry many usability problems, according to the gov.uk Technology in Government blog.
Edit this page in GitHub (Permissions required)
Last updated: Jun 28, 2022