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:
- Dialogs on mobile
- Text field dropdowns on desktop
Flatpickr is a versatile datetime picker.
Stylesheet material-plugins.css
is required as this material design theme for flatpickr is fully designed by djibe.
Plugin is jQuery free but can be initialized as a jQuery plugin.
Demo
flatpickr will probably become default Picker as it corresponds perfectly to latest Material design guidelines: Dropdown calendar on desktop and system’s default picker on mobile.
Don’t use inline picker for Date and Time inputs.
Using flatpickr
Import material-plugins.css after Material CSS. Don’t use extra flatpickr CSS.
Import flatpickr after Material JavaScripts.
Set HTML code of your picker menu.
Initialize plugin with JavaScript or jQuery parameters.
All parameters are detailed in official documentation.
That’s it.
Inline picker is not rendered using mobile’s default operating system Picker and is barely usable on mobile.
Try to avoid using inline
parameter for a good mobile User experience.
Picker types
Date
Single date selection is default picker. See Demo example above.
Picker is also compatible with multiple dates selection.
Date range
Select a start and final date.
Example displays the picker inline
and sets minDate
to Today.
DateTime
Select date and time.
Example also displays week numbers
and sets time format in British 12h
format.
Time
Select time only.
Simplest time picker in a 24h
format and a default time
.
More details
For date format, display, seconds, localization and more, read official documentation