The date & time picker supports single, multiple & range selection with mobile & desktop optimized rendering and interaction model.
Use it as a scroller and dropdown. Easily switch between scroller and calendar view or single and range selection.
The capabilities like built-in validation, minimum, maximum values, disabled dates are supported by both the scroller and calendar.
Use the date & time for both mobile and desktop or set it up responsively.
The main difference between the two rendering modes is how the picker is laid out. Set the touchUi option to false and the component shows up suitable for larger screens and pointer interaction while setting it to true renders it suitable for touch screens.
Use the date picker on an existing form field, custom input or use it on Mobiscroll form fields. You can also embed it directly into your page.
When linked to an input, the component will be shown on focus or when someone clicks on the field. Alternatively, you can leave the input editable and show the component only on a button click.
The date & time has a liquid layout, which means it nicely adapts to its surroundings. There are times however when you would like to set up the component responsively.
Use the responsive option to configure the picker and change the options based on the viewport width. There are five predefined breakpoints:
xsmall - min-width: 0px
small - min-width: 576px
medium - min-width: 768px
large - min-width: 992px
xlarge - min-width: 1200px
use custom for setting a custom breakpoint
It is a good idea to change the display or controls option to taiilor the UX. This way you can have a bottom positioned calendar on mobile, a popover anchored to the input on tablet and desktop display on large sceens.
Change the viewport
Date & Time - Understanding display modes
Understanding display modes
The date picker has five built-in display modes that can be controlled through the display option:
top - modal that slides down from the top
bottom - modal that slides up from the bottom
center - modal that shows up in the middle with a pop animation
anchored - modal that shows up anchored to an input or any dom element
inline - embeddable picker that is rendered into the markup without its own modal
Use the touchUi option to switch between touch optimized mobile renderign and pointer optimized desktop renderign. It can be dynamically switched with the help of the responsive oprion.
The defaults change on a theme to theme basis. The ios theme comes with bottom on mobile and anchored on desktop while the material and windows themes have center on mobile and anchored on desktop.
The date picker ships with four built-in variations for rendering the UI. The controls option supports the following:
date - renders a date-only scroller or dropdown control
time - renders a time-only scroller or dropdown control
datetime - renders a date & time scroller or dropdown
calendar - renders a calendar view for date picking
Use controls: ['datetime'] for rendering a date & time picker within the same control, tied to the same input, or use them separately for two inputs - controls: ['date'] and controls: ['time']. It will render a scrollers for touchUi: true and a dropdowns for touchUi: false.
Single value selection is the default behavior of the date picker. You can explicitly enable it by setting the selectMultiple to false.
You can dynamically switch between single and multiple select or range select which helps with building a system for one-way and two-way bookings.
Date & Time - Range selection
To enable range selection set the select option to range.
The microcopy for rangeStartLabel and rangeEndLabel can be easily overriden. For flight booking "Outbound" and "Return" makes sense while for accomodation booking "Check in" and "Check out" might be more appropriate.
The date & time picker works with different date types:
JS date object - a common way of passing a date is through a Date object: new Date(1995, 11, 17, 15, 24) (make sure to not simply pass a date string to new Date())
ISO date string - standardized way of passing dates: '2008-09-15T15:53:00' (make sure to pass it as a string)
Moment.js object - a great solution that solves common date management difficulties: moment([2018, 3, 27, 12, 15]) (make sure to have moment.js loaded)
When passing dates to the component - eg. min/max, invalids - you can do it in either format and the picker will automatically know what to do with it. If you want to specify how the picker should return values, you can do it in the returnFormat option.
Date & Time - Formatting values
Use the dateFomat, timeFormat options to customize how the values show up in the inputs after selection. If the formats are not expicitly set, they are inherited from the localization settings.
Besides customizing the date and time formats you can reorder the picker wheels and change its formats with the dateWheels and timeWheels options.
Configuring minimum and maximum selectable values is great for reducing mistakes. Help people by limiting the selections for the task at hand. Use the min and max options to restrict the selection.
Setting the values will disable dates/times earlier than min and dates/times that come after max.
Enforcing validation is essential to a great UX. First make sure to have the min & max values right and then work your way through disabled values.
Dates and times can be disabled through the invalid option.
Another tool for setting disabled values are valid overrides. This means that you can make certain values valid from the invalid set. Eg. Invalidate all Tuesdays, but make Aug. 04, 2020 valid.
Disable recurring days, set marked or colored days with the help of the recurring object. Learn how to configure daily, weekly,monthly and yearly recurring dates and pass rule in the recurring property under the invalid option.
Use the configurator to experiment, build strings and objects that you can grab and use.
All components are fully localized.
In case of the date picker this covers date and time format, button copy, rtl and more.
You can see how each example shows up by clicking on the small flag icon or checking the examples below.