Skip to main content

An official website of the United States government

Here's how you know

An official website of the United States government

Here's how you know

Theme:

Design system switcher

Version:

Design system switcher

Theme:

Design system switcher

Version:

Design system switcher

Month Picker

Examples

The Month Picker component renders a grid of checkboxes with shortened month names as well as buttons for selecting or deselecting all. For internationalization one can pass a locale prop, and the month names will change to match the language of the locale. Full month names are also included as aria-label attributes.

Accessibility

Accessibility

  • Be mindful of color contrast ratios between the checkbox and its background color. For instance, a dark green or blue behind the component will most likely cause problems for users. When using a dark background, consider using the inversed prop. Read our guidance on color for more information.

Accessibility testing

Keyboard testing

  • All checkboxes can be accessed using only the tab key.
  • The checkbox focus follows logical content order. When you tab through the months with a keyboard, the focus stays in order of the content as intended.
  • The spacebar is used to check/uncheck a focused checkbox.
  • There is a visible focus state.
  • The change in state is visible.

Screen reader testing

For desktop users:
  • Some screen readers read the legend text for each element within the fieldset, so it should be brief and descriptive.
  • Each label should be announced for every checkbox.
  • The checkbox element should be identified with a role of checkbox.
  • If hints or errors are present, they are read after the label.
  • In a checkbox group, I should hear the question or title related to them via a legend inside a fieldset.
  • When the checkbox is selected, that state is read out.
For mobile users:
  • All the above from the desktop screen reader experience apply.
  • Swiping focuses on a checkbox.
  • Double tapping with the checkbox in focus makes a selection and announces its been selected.
  • Users may select either the text label or the checkbox itself to select an option.
  • Click/tap target area is a minimum of 24x24px.

Code

React

Review Storybook for React guidance of this component.

Web Component

Go to Storybook for Web Component guidance of this component.

Style customization

The following CSS variables can be overridden to customize MonthPicker fields:

CSS variables for choice
VariableDefault Core Theme Value
--choice__background-colorhex value: #ffffff--color-background
--choice__background-color--checkedhex value: #0071bc--color-primary
--choice__background-color--inversehex value: transparent--color-transparent
--choice__border-colorhex value: #262626--color-base
--choice__border-color--checkedhex value: #0071bc--color-primary
--choice__border-color--errorhex value: #262626--color-base
--choice__border-color--error--inversehex value: #ffffff--color-white
--choice__border-color--inversehex value: #ffffff--color-white
--choice__border-color--lefthex value: #0071bc--color-primary
--choice__border-radius0px
--choice__border-width2px
--choice__color--uncheckedhex value: #ffffff--color-white
--choice__color--disabledhex value: #5a5a5a--color-muted
--choice__size--small20px
--choice__size-radio22px
--choice__size-radio--small12px
--choice-label__color--disabledhex value: #5a5a5a--color-muted
--choice-label__color--disabled--inversehex value: #e9ecf1--color-muted-inverse
--choice-label__top-offset0.25rem
--choice__background-color--disabledhex value: #d9d9d9--color-gray-lighter
--choice__border-color--disabledhex value: #a6a6a6--color-gray-light
--choice__border-color--focushex value: #004f84--color-primary-darker
--choice__border-color--disabled--inversehex value: #a6a6a6--color-gray-light
--choice__size32px
--choice__background-color--disabled--inversehex value: #e9ecf126#e9ecf126
--choice-wrapper__gap0.5rem
--choice-wrapper__gap--small0.5rem

Form components

This component also makes use of form field styles, which can be customized by the following variables:

CSS variables for form
VariableDefault Core Theme Value

Component maturity

For more information about how we tested and validated our work for each checklist item, read our component maturity documentation.

Accessibility

  • Color

    Meets AA color contrast standards for accessibility and color blindness.
    Complete
  • Forced Colors Mode (FCM)

    While using FCM the components text is legible and improves readability.
    Complete
  • WCAG 2.1 Level AA Conformance

    All Axe checks for WCAG AA compliance have passed.
    Complete
  • Screen readers

    VoiceOver, NVDA, and JAWS screen readers provide concise communication and interaction.
    Complete
  • Keyboard navigation

    Component is fully navigable with a keyboard.
    Complete

Code

  • Storybook

    Component has stories to cover all defined props.
    Complete
  • Responsive

    Component designed to work in all responsive breakpoints.
    Complete
  • Spanish translations

    Includes Spanish translations for default text content.
    Complete

Tokens

  • Code

    Tokens implemented in code.
    Complete
  • Design

    Tokens implemented in Figma.
    Incomplete