Date Picker is a popover control for picking a date value for a date input. It's also sometimes referred to as Datepicker.

Design Guidelines

Date Picker is a calendar-view popover. It is paired with a text input so that it can send a formatted date value to the input.

Date Picker is shown by clicking, or gaining focus and hitting enter, on the calendar icon next to the input field.

Today’s date is displayed in bold. Unless preloaded with another date, today’s date will be selected in the Date Picker.

Clicking on the check-calendar icon inside the Date Picker returns the focus to today’s date.

Focus is indicated by a grey background. Focus can be moved around inside the Date Picker using arrow and tab keys. Clicking the enter key will select a value.

Date Picker

Usage

A Date Picker is used to select a date when a user needs to understand the date in context with other possible dates. Date choices are influenced by day of the week, or week within a month. A Date Picker is also helpful when the formatting of the date is important.

Date Pickers aren’t helpful when the date is a known value like a birthdate. A user will likely want to type that value in versus hunting for it in a Date Picker. In cases where space is limited, it may be a good idea to omit the Date Picker.

Views

The Month and Year views are shown when a user clicks on the month or year titles in the date view.

Month Picker
Month

12 month values can be selected from. Arrow keys can be used to navigate through the values. Selecting a month value will return the user back to the date view.

Year Picker
Year

10 year values are displayed at one time. Arrow keys can be used to navigate through the values, future years, and past years. Selecting a year value will return the user back to the date view.

Small Screens

We automatically disable the Clarity Date Picker on small mobile phones. This is done because unlike desktop browsers, most mobile browsers have a built-in date picker. These built-in date pickers are optimized to work on mobile devices and provide an experience which the user is already familiar with.

Clarity Date Picker is shown at screen width 768px and above.

Important Notes about User Input

  • Every time the user changes the value in the input field, the value is validated against the placeholder to check if a valid date is entered or not. If a valid date is entered, the date picker opens with the entered date selected. If an invalid date is entered, the date picker opens with the focus on today's date.
  • Selecting a date from the date picker overrides the value in the input field.
  • Date picker ideally requires a 4 digit year but can convert a 2 digit year input by the user to a 4 digit year. For eg: a 2 digit year 20 will convert to 2020. If the 4 digit conversion is 20 more than the current year, we subtract 100 from it. If the current year is 2018 and the year input is 99, then the converted year is 1999. Anything other than a 4 digit or 2 digit year is considered invalid.

Code & Examples

Summary of Options

Input/Output Values Default Effect
[(clrDate)]
Type: Date
NA
Javascript Date Objects NA Two-way binding on the date value.