DateTimePicker API
API reference docs for the React DateTimePicker component. Learn about the props, CSS, and other APIs of this exported module.
Component demos
Import
import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
// or
import { DateTimePicker } from '@mui/x-date-pickers';
// or
import { DateTimePicker } from '@mui/x-date-pickers-pro';
Props of the native component are also available.
Name | Type | Default | Description |
---|---|---|---|
ampm | bool | `utils.is12HourCycleInCurrentLocale()` | 12h/24h view for hour selection clock. |
ampmInClock | bool | true on desktop, false on mobile | Display ampm controls under the clock (instead of in the toolbar). |
autoFocus | bool | - | If |
closeOnSelect | bool | `true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop). | If |
dayOfWeekFormatter | func | (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase() | Formats the day of week displayed in the calendar header. Signature: function(date: TDate) => string
Returns: The name to display. |
defaultValue | object | - | The default value. Used when the component is not controlled. |
desktopModeMediaQuery | string | '@media (pointer: fine)' | CSS media query when |
disabled | bool | false | If |
disableFuture | bool | false | If |
disableHighlightToday | bool | false | If |
disableIgnoringDatePartForTimeValidation | bool | false | Do not ignore date part when validating min/max time. |
disableOpenPicker | bool | false | If |
disablePast | bool | false | If |
displayWeekNumber | bool | - | If |
fixedWeekNumber | number | - | The day view will show as many weeks as needed after the end of the current month to match this value. Put it to 6 to have a fixed number of weeks in Gregorian calendars |
format | string | - | Format of the date when rendered in the input(s). Defaults to localized format based on the used |
formatDensity | 'dense' | 'spacious' | "dense" | Density of the format when rendered in the input. Setting |
inputRef | ref | - | Pass a ref to the |
label | node | - | The label content. |
loading | bool | false | If |
localeText | object | - | Locale for components texts. Allows overriding texts coming from |
maxDate | object | - | Maximal selectable date. |
maxDateTime | object | - | Maximal selectable moment of time with binding to date, to set max time in each day use |
maxTime | object | - | Maximal selectable time. The date part of the object will be ignored unless |
minDate | object | - | Minimal selectable date. |
minDateTime | object | - | Minimal selectable moment of time with binding to date, to set min time in each day use |
minTime | object | - | Minimal selectable time. The date part of the object will be ignored unless |
minutesStep | number | 1 | Step over minutes. |
monthsPerRow | 3 | 4 | 3 | Months rendered per row. |
name | string | - | Name attribute used by the |
onAccept | func | - | Callback fired when the value is accepted. Signature: function(value: TValue) => void
|
onChange | func | - | Callback fired when the value changes. Signature: function(value: TValue, context: FieldChangeHandlerContext
|
onClose | func | - | Callback fired when the popup requests to be closed. Use in controlled mode (see |
onError | func | - | Callback fired when the error associated to the current value changes. If the error has a non-null value, then the Signature: function(error: TError, value: TValue) => void
|
onMonthChange | func | - | Callback fired on month change. Signature: function(month: TDate) => void
|
onOpen | func | - | Callback fired when the popup requests to be opened. Use in controlled mode (see |
onSelectedSectionsChange | func | - | Callback fired when the selected sections change. Signature: function(newValue: FieldSelectedSections) => void
|
onViewChange | func | - | Callback fired on view change. Signature: function(view: TView) => void
|
onYearChange | func | - | Callback fired on year change. Signature: function(year: TDate) => void
|
open | bool | false | Control the popup or dialog open state. |
openTo | 'day' | 'hours' | 'meridiem' | 'minutes' | 'month' | 'seconds' | 'year' | - | The default visible view. Used when the component view is not controlled. Must be a valid option from |
orientation | 'landscape' | 'portrait' | - | Force rendering in particular orientation. |
reduceAnimations | bool | `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13 | If |
referenceDate | object | The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`. | The date used to generate the new value when both |
renderLoading | func | () => <span data-mui-test="loading-progress">...</span> | Component displaying when passed Signature: function() => React.ReactNode Returns: The node to render when loading. |
selectedSections | 'all' | 'day' | 'empty' | 'hours' | 'meridiem' | 'minutes' | 'month' | 'seconds' | 'weekDay' | 'year' | number | - | The currently selected sections. This prop accepts four formats: 1. If a number is provided, the section at this index will be selected. 2. If a string of type |
shouldDisableDate | func | - | Disable specific date. Signature: function(day: TDate) => boolean
Returns: If |
shouldDisableMonth | func | - | Disable specific month. Signature: function(month: TDate) => boolean
Returns: If |
shouldDisableTime | func | - | Disable specific time. Signature: function(value: TDate, view: TimeView) => boolean
Returns: If |
shouldDisableYear | func | - | Disable specific year. Signature: function(year: TDate) => boolean
Returns: If |
showDaysOutsideCurrentMonth | bool | false | If |
skipDisabled | bool | false | If |
slotProps | object | {} | The props used for each component slot. |
slots | object | {} | Overridable component slots. See Slots API below for more details. |
sx | Array<func | object | bool> | func | object | - | The system prop that allows defining system overrides as well as additional CSS styles. See the `sx` page for more details. |
thresholdToRenderTimeInASingleColumn | number | 24 | Amount of time options below or at which the single column time renderer is used. |
timeSteps | { hours?: number, minutes?: number, seconds?: number } | { hours: 1, minutes: 5, seconds: 5 } | The time steps between two time unit options. For example, if |
timezone | string | The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise. | Choose which timezone to use for the value. Example: "default", "system", "UTC", "America/New_York". If you pass values from other timezones to some props, they will be converted to this timezone before being used. See the timezones documentation for more details. |
value | object | - | The selected value. Used when the component is controlled. |
view | 'day' | 'hours' | 'meridiem' | 'minutes' | 'month' | 'seconds' | 'year' | - | The visible view. Used when the component view is controlled. Must be a valid option from |
viewRenderers | { day?: func, hours?: func, meridiem?: func, minutes?: func, month?: func, seconds?: func, year?: func } | - | Define custom view renderers for each section. If |
views | Array<'day' | 'hours' | 'minutes' | 'month' | 'seconds' | 'year'> | - | Available views. |
yearsPerRow | 3 | 4 | 4 on desktop, 3 on mobile | Years rendered per row. |
Slot name | Class name | Default component | Description |
---|---|---|---|
tabs | DateTimePickerTabs | Tabs enabling toggling between date and time pickers. | |
toolbar | DateTimePickerToolbar | Custom component for the toolbar rendered above the views. | |
calendarHeader | PickersCalendarHeader | Custom component for calendar header. Check the PickersCalendarHeader component. | |
switchViewButton | IconButton | Button displayed to switch between different calendar views. | |
switchViewIcon | ArrowDropDown | Icon displayed in the SwitchViewButton. Rotated by 180° when the open view is 'year'. | |
previousIconButton | IconButton | Button allowing to switch to the left view. | |
nextIconButton | IconButton | Button allowing to switch to the right view. | |
leftArrowIcon | ArrowLeft | Icon displayed in the left view switch button. | |
rightArrowIcon | ArrowRight | Icon displayed in the right view switch button. | |
day | PickersDay | Custom component for day. Check the PickersDay component. | |
actionBar | PickersActionBar | Custom component for the action bar, it is placed below the picker views. | |
shortcuts | PickersShortcuts | Custom component for the shortcuts. | |
desktopPaper | PickersPopperPaper | Custom component for the paper rendered inside the desktop picker's Popper. | |
desktopTransition | Grow or Fade from '@mui/material' when `reduceAnimations` is `true`. | Custom component for the desktop popper Transition. | |
desktopTrapFocus | FocusTrap from '@mui/base'. | Custom component for trapping the focus inside the views on desktop. | |
popper | Popper from '@mui/material'. | Custom component for the popper inside which the views are rendered on desktop. | |
textField | TextField from '@mui/material' or PickersTextField if `enableAccessibleFieldDOMStructure` is `true`. | Form control with an input to render the value inside the default field. | |
inputAdornment | InputAdornment | Component displayed on the start or end input adornment used to open the picker on desktop. | |
openPickerButton | IconButton | Button to open the picker on desktop. | |
layout | Custom component for wrapping the layout. It wraps the toolbar, views, action bar, and shortcuts. | ||
clearIcon | ClearIcon | Icon to display inside the clear button. | |
clearButton | IconButton | Button to clear the value. | |
field | Component used to enter the date with the keyboard. | ||
openPickerIcon | Icon displayed in the open picker button on desktop. | ||
digitalClockItem | MenuItem from '@mui/material' | Component responsible for rendering a single digital clock item. | |
digitalClockSectionItem | MenuItem from '@mui/material' | Component responsible for rendering a single multi section digital clock section item. | |
dialog | PickersModalDialogRoot | Custom component for the dialog inside which the views are rendered on mobile. | |
mobilePaper | Paper from '@mui/material'. | Custom component for the paper rendered inside the mobile picker's Dialog. | |
mobileTransition | Fade from '@mui/material'. | Custom component for the mobile dialog Transition. |