U.S. flagA digital services project by Flexion

Date Picker

formUSWDS-derivedinteractive

A calendar date selector popup from a text input with keyboard navigation and min/max date support.

Reference: USWDS documentation ↗

Variants

Date Picker With Constraints

Date Picker With Default

Default Date Picker

Contract

Class mapping

USWDSFlexNotes
usa-date-picker<flex-date-picker> (custom element)Container element
usa-date-picker__external-input.flex-date-picker__external-inputText input for date entry (mm/dd/yyyy)
usa-date-picker__button.flex-date-picker__buttonCalendar toggle button
usa-date-picker__calendar.flex-date-picker__calendarCalendar popup container
usa-date-picker__calendar__previous-month.flex-date-picker__nav--prevPrevious month navigation button
usa-date-picker__calendar__next-month.flex-date-picker__nav--nextNext month navigation button
usa-date-picker__calendar__month-selection.flex-date-picker__month-labelMonth/year label that opens month selection
usa-date-picker__calendar__date.flex-date-picker__dayIndividual day button in calendar grid
usa-date-picker__calendar__date--selected.flex-date-picker__day--selectedSelected date styling
usa-date-picker__calendar__date--today.flex-date-picker__day--todayToday date styling

Verified properties

font-familyfont-sizecolorbackground-colorcursor

Intentional differences

background-color: ours = var(--flex-gray-5) (#f0f0f0) — calendar background, USWDS = #f0f0f0 — same color, different token

Using design token for theming support

Behavior promises

  • ✓ Click toggle button opens calendar popup
  • ✓ Click toggle button again closes calendar
  • ✓ Calendar renders correct days for the month
  • ✓ Previous/Next month buttons navigate months
  • ✓ Click day selects date and closes calendar
  • ✓ Selected date appears in input as mm/dd/yyyy
  • ✓ ArrowLeft/Right moves focus by day
  • ✓ ArrowUp/Down moves focus by week
  • ✓ Home/End moves to first/last day of week
  • ✓ PageUp/PageDown moves by month
  • ✓ Enter selects focused date
  • ✓ Escape closes calendar
  • ✓ Outside click closes calendar
  • ✓ Min/max date constraints disable out-of-range days
  • ✓ Month label click toggles month selection view
  • ✓ Today is visually highlighted
  • ✓ Selected date has accent background
  • ✓ Calendar opens with focus on selected or today date
  • ✓ Accessibility audit passes

Source CSS

Base styles: Form Control Base