Skip to main content

Date picker

Usage

Overview

Date picker is a component that is composed of two primary elements: a date picker field and a dropdown calendar. The calendar component visually represents a date and provides a consistent navigation experience through day, month, and year views. This inline calendar allows users to browse and select dates within a view.

When to use

  • To select a date close to the current date.
  • To select a date and store it in an input field.
  • To browse through different date views, such as days, months, and years.
  • For a visual representation of the date.

When not to use

  • To select a date in the distant past or future. In this case, use the date input.
  • To select a date range. In this case, use date range.
  • To select only the month and year, without a specific day. In this case, use the month picker.
  • To select only the year, without specifying the month or day. In this case, use the year picker.
  • To select a specific time. In this case, use the time picker.

Formatting

Anatomy

Image depicting the anatomy of the date picker component

The date picker component consists of the following elements:

  1. Date picker field: An input field where the user can manually enter the day, month, and year.
  2. Calendar icon: An icon button that triggers the dropdown calendar when clicked.
  3. Previous month button: A navigational control for viewing and selecting dates from the previous month.
  4. Month button: A control for selecting a different month.
  5. Year button: A control for selecting a different year.
  6. Next month button: A navigational control for viewing and selecting dates from the next month.
  7. Current date: The current date, with a line displayed underneath to visually indicate it.
  8. Selected date: The specific date chosen by the user and highlighted or emphasized within the date picker interface.
  9. “Today” button: A button that automatically populates the date picker field with the current day, month, and year when clicked.

Date format

The format of the date displayed in the date picker depends on the user's locale. This means that the date format will vary based on the user's location and language settings.

For example, in the United States, the date format is typically MM/DD/YYYY, while in many European countries, the format is DD/MM/YYYY.

The date format is shown as a placeholder within the date picker to assist the user as they enter the date. This ensures that the format remains visible throughout the input process.

Image that shows a user typing in the date picker field
A placeholder within the input field guides users on the expected date format as they type.

Content

General writing guidelines

  • Use sentence case for all aspects of designing Guidewire product interfaces. Don't use title case.
  • Use present tense verbs and active voice in most situations.
  • Use common contractions to lend your copy a more natural and informal tone.
  • Use plain language. Avoid unnecessary jargon and complex language.
  • Keep words and sentences short.

Include a label

Label the date picker with clear, descriptive text. This label should communicate its purpose and the specific type of date being selected.

Do position a permanent label outside the field.
Don't use placeholder text as a replacement for the label.

Add help text if it's meaningful

Use help text to provide context and communicate what date to select. Here are some examples of what you might include:

  • Hints that assist the user in choosing the appropriate date
  • More context for why the user needs to select a specific date

Only use help text for pertinent information. Avoid restating the same details that appear in the label. Write help text in sentence case, using 1-2 short, complete sentences that end with a period.

Do use help text to show context.
Don't use help text to simply restate the same information that appears in the label.

Behaviors

States

The date picker component behaves like an input field, with the same interactive states.

Interactions

Mouse

Users can enter the day, month, and year manually in the date picker field or click the calendar icon to select the day, month, and year from a dropdown.

Image that shows a user interacting with the date picker using a mouse

Keyboard

The date picker is expanded and collapsed with Spacebar. Users navigate through the options using the arrow keys and select by means of the Spacebar or Enter key.

A calendar widget appears when the user tabs to the date picker input field. The current date is highlighted and keyboard-only users can enter the date manually here. Users can also place keyboard focus on the widget by pressing the down arrow key when it is expanded. Navigate through the calendar with the arrow keys. 'Previous', 'Month', 'Year', and 'Next' buttons are focusable using the Tab key when the widget is open.

Screenreader

Users are informed of the pre-populated date value when they tab to the date picker input field, and that this value is currently selected. The date can be entered manually from this input field. While focus remains on the pre-populated date, a calendar widget is also available. Users can also move focus into the widget by pressing the down arrow key. Navigation through the calendar portion of the widget is accomplished using the arrow keys, and the value currently in focus is voiced by screen readers through a WAI-ARIA aria-label attribute. The 'Previous', 'Month', 'Year', and 'Next' buttons are focusable using the Tab key when the widget is open. React date picker does not currently enable keyboard navigation to the 'Today' link.

Input handling

The date picker component allows users to move the caret (the blinking text cursor) between different sections of the date (MM/DD/YYYY). However, users cannot delete individual digits within a section. Deleting any digit erases the entire section (MM, DD, or YYYY), requiring users to retype it. This behavior is consistent across date components, where the input mask formats the input as the user types.

Accessibility

The contrast ratio of textual elements against their background is above 4.5:1 as per WCAG 2.1 AA requirements. Non-textual content that needs to convey meaning (such as icons and keyboard focus visibility) has a contrast ratio of at least 3:1 with its adjacent colors. All content is visible and functional up to and including 400% without requiring scrolling in two dimensions.

This component has been validated to meet the WCAG 2.1 AA accessibility guidelines. However, changes made by the content author can affect accessibility conformance.

When using this component, ensure the label clearly communicates which date the user needs to input or select.