Date Picker
The Date Picker let the user select a date.
Date pickers are displayed with:
- Dialogs on mobile
- Text field dropdowns on desktop
Basic usage
The Date Picker is rendered as a modal dialog on mobile, and a textbox with a popup on desktop.
Component composition
The Date Picker components are built using the DateField for the keyboard editing and the DateCalendar for the view editing.
All the documented props of those two components can also be passed to the Date Picker components.
Check-out their documentation page for more information:
Uncontrolled vs. Controlled
The component can be uncontrolled or controlled
Responsiveness
The Date Picker component is designed and optimized for the device it runs on.
- The
MobileNextDatePickercomponent works best for touch devices and small screens. - The
DesktopNextDatePickercomponent works best for mouse devices and large screens.
By default, the NextDatePicker component renders the desktop version if the media query @media (pointer: fine) matches.
This can be customized with the desktopModeMediaQuery prop.
There are certain caveats when testing pickers, please refer to this section for more information.
Static mode
It is also possible to render the Date Picker without the modal/popover and text field. This can be helpful when building custom popover/modal containers.
Views
The component can contain three views: day, month, and year.
By default, only the day and year views are enabled.
You can customize the enabled views using the views prop.
Views will appear in the order they're included in the views array.
Landscape orientation
By default, the Date Picker automatically sets the orientation based on the window.orientation value.
You can force a specific orientation using the orientation prop.
MM / DD / YYYY
Custom input component
You can customize the rendering of the input with the Input component slot.
Make sure to spread inputProps correctly to the custom input component.
Validation
You can find the documentation in the Validation page.
Localization
You can find the documentation about localization in the Date localization and Component localization.