Date pickers let users select a date or range of dates. They should be suitable for the context in which they appear.
Date pickers can be embedded into:
Date pickers can display past, present, or future dates – as relevant to the task.
Clearly indicate important dates, such as current and selected days.
To ensure picking a day or time is intuitive, use common picker patterns, such as a calendar.
Mobile calendar pickers can be used to select dates in the near future or past, when it’s useful to see them in a calendar month format. They are displayed in a dialog.
Common use cases include:
They aren’t ideal for selecting dates in the distant past or future that require more navigation, such as entering a birth date or expiration date.
Mobile calendar pickers allow selection of a single date and year.
Mobile calendar picker
Maintain 16dp left and right padding from the edge of the screen. The top and bottom of the picker should be vertically centered in the screen.
Don’t use more than 16dp from the left and right screen edges, as it creates smaller touch targets.
Don’t use a calendar picker to prompt for dates in the distant past or future, such as a date of birth. In these cases, use a mobile input picker or a text field instead.
Mobile calendar pickers navigate across dates in several ways:
Mobile calendar pickers adapt to a device’s orientation.
Mobile date range pickers allow selection of a range of dates. They cover the entire screen.
Common use cases include:
They aren’t ideal for selecting dates in the distant past or future that require more navigation, such as entering a birth date or expiration date.
Mobile date range picker
Mobile date range pickers navigate across dates in several ways:
Mobile date input pickers allow the manual entry of dates using the numbers on a keyboard. Users can input a date or a range of dates in a dialog.
Mobile date input pickers allow for keyboard input to select a date or range of dates.
Mobile date input picker
For dates that don’t require a calendar view, make the mobile date input picker as the default prompt.
Alternatively, a text field with appropriate hint text can prompt for dates, such as in a form.
The mobile date input picker can be accessed from any other mobile date picker, via the edit icon.
Desktop date pickers allow the selection of a specific date and year. The desktop date picker displays a date input field by default, and a dropdown calendar appears when the user taps on the input field. The user can interact with either form of date entry.
Desktop date pickers are ideal for navigating dates in both the near future (or past) and the distant future (or past), as they provide multiple ways to select dates.
Desktop date picker
Users can input dates either using a keyboard or by navigating the calendar UI; both options are immediately available when the desktop date picker is accessed.
Desktop date picker
Desktop date range pickers allow a range of days to be selected. They display both calendar and date input fields.
Desktop date range picker
Tooltips can help explain how to use date picker controls.
On mobile, a date picker should allow users to enter dates manually by inputting text, without using the picker. This interaction allows multiple input methods and makes it accessible to those using assistive technology.
Touch targets for mobile date pickers should be as large as possible, filling the available space. The minimum touch target size for a date picker is 32 x 32dp.
The edit icon indicates the ability to switch to the mobile input picker.
On the mobile date range picker, touch targets are maximized at 48 x 48dp.
The mobile calendar picker is a a standard dialog.
The mobile calendar picker contains an exposed dropdown menu that enables year selection.
The mobile calendar picker is a full-screen dialog.
The mobile calendar picker is a standard dialog.
The desktop date range picker consists of two single pickers displaying consecutive months.
$(container).mdcDatePicker(options) | ||
---|---|---|
A plugin to add date picker to an input container. | ||
container | String | jQuery | Element | The input container. can be either a css selector string or a jQuery object or an element. date picker will be added by default to any container with .has-datepicker class. |
options | object | The picker configuration options. can also be set using html data attributes on the container. |
Options list: | ||
Javascript | HTML attribute | Description |
startDate |
data-start-date |
The earliest date that may be selected; all earlier dates will be disabled. yyyy-MM-dd format is recommended. |
endDate |
data-end-date |
The latest date that may be selected; all later dates will be disabled. yyyy-MM-dd format is recommended. |
selectedDate |
data-selected-date |
The selected date in the picker. defaults to the current date or endDate if not in the range. yyyy-MM-dd format is recommended. |
dateFormat |
data-date-format |
A string representing the date format that will be used for the input. defaults to dd/MM/yyyy .
|
color |
data-color |
The primary color the picker. defualts to purple-900 . see The color system |
label |
data-label |
A label to be used inside the picker. defualts to Select a date |
$(container).mdcDatePicker.open() | ||
A method to open the date picker. will be fired on input focus. | ||
container | String | jQuery | Element | The input container. can be either a css selector string or a jQuery object or an element. |
$(container).mdcDatePicker.close() | ||
A method to close the date picker. | ||
container | String | jQuery | Element | The input container. can be either a css selector string or a jQuery object or an element. |
$(container).mdcDatePicker.setYear(year) | ||
A method to set the currently selected year in the picker. | ||
container | String | jQuery | Element | The input container. can be either a css selector string or a jQuery object or an element. |
year | String | integer | The year to be set. cannot be less than startDate year or greater than endDate year. |
$(container).mdcDatePicker.changeMonth(x) | ||
A method to change the currently selected month in the picker. | ||
container | String | jQuery | Element | The input container. can be either a css selector string or a jQuery object or an element. |
x | integer | Number of months to be added to the currently selected month. can be positive or negative number. |
$(container).mdcDatePicker.selectDate(date) | ||
A method to change the currently selected date in the picker without updating the input. | ||
container | String | jQuery | Element | The input container. can be either a css selector string or a jQuery object or an element. |
date | String | A string representing the new date to be selected. yyyy-MM-dd format is recommended. |
$(container).mdcDatePicker.getSelectedDate() | ||
A method that returns the selected date as formatted string using dateFormat . |
||
container | String | jQuery | Element | The input container. can be either a css selector string or a jQuery object or an element. |
<div class="mdc-text-field has-datepicker purple-900" data-start-date="1985-01-01" data-end-date="2015-12-31" data-date-format="MMMM d, yyyy" data-color="purple-900" data-label="Date of birth" > <div class="icon material-icon">calendar_today</div> <div class="input"><input class="input-element" type="text"></div> <label class="label">DOB</label> </div>