Skip to content

DateTimeField API

API reference docs for the React DateTimeField component. Learn about the props, CSS, and other APIs of this exported module.

Demos

For examples and details on the usage of this React component, visit the component demo pages:

Import

import { DateTimeField } from '@mui/x-date-pickers-pro/DateTimeField';
// or
import { DateTimeField } from '@mui/x-date-pickers/DateTimeField';
// or
import { DateTimeField } from '@mui/x-date-pickers-pro';
// or
import { DateTimeField } from '@mui/x-date-pickers';
You can learn about the difference by reading this guide on minimizing bundle size.

Component name

The name MuiDateTimeField can be used when providing default props or style overrides in the theme.

Props

NameTypeDefaultDescription
ampmbool`utils.is12HourCycleInCurrentLocale()`
12h/24h view for hour selection clock.
autoFocusboolfalse
If true, the input element is focused during the first mount.
color'error'
| 'info'
| 'primary'
| 'secondary'
| 'success'
| 'warning'
'primary'
The color of the component. It supports both default and custom theme colors, which can be added as shown in the palette customization guide.
componentsobject{}
Overrideable components.
componentsPropsobject{}
The props used for each component slot.
defaultValueany
The default value. Use when the component is not controlled.
disabledboolfalse
If true, the component is disabled.
disableFutureboolfalse
If true, disable values after the current date for date components, time for time components and both for date time components.
disableIgnoringDatePartForTimeValidationboolfalse
Do not ignore date part when validating min/max time.
disablePastboolfalse
If true, disable values before the current date for date components, time for time components and both for date time components.
focusedboolfalse
If true, the component is displayed in focused state.
formatstring
Format of the date when rendered in the input(s).
FormHelperTextPropsobject
Props applied to the FormHelperText element.
fullWidthboolfalse
If true, the input will take up the full width of its container.
helperTextnode
The helper text content.
hiddenLabelboolfalse
If true, the label is hidden. This is used to increase density for a FilledInput. Be sure to add aria-label to the input element.
idstring
The id of the input element. Use this prop to make label and helperText accessible for screen readers.
InputLabelPropsobject
Props applied to the InputLabel element. Pointer events like onClick are enabled if and only if shrink is true.
inputPropsobject
Attributes applied to the input element.
InputPropsobject
Props applied to the Input element. It will be a FilledInput, OutlinedInput or Input component depending on the variant prop value.
inputReffunc
| { current: any }
Pass a ref to the input element.
labelnode
The label content.
margin'dense'
| 'none'
| 'normal'
'none'
If dense or normal, will adjust vertical spacing of this and contained components.
maxDateany
Maximal selectable date.
maxDateTimeany
Maximal selectable moment of time with binding to date, to set max time in each day use maxTime.
maxTimeany
Maximal selectable time. The date part of the object will be ignored unless props.disableIgnoringDatePartForTimeValidation === true.
minDateany
Minimal selectable date.
minDateTimeany
Minimal selectable moment of time with binding to date, to set min time in each day use minTime.
minTimeany
Minimal selectable time. The date part of the object will be ignored unless props.disableIgnoringDatePartForTimeValidation === true.
minutesStepnumber1
Step over minutes.
namestring
Name attribute of the input element.
onChangefunc
Callback fired when the value changes.

Signature:
function(value: TValue, context: FieldChangeHandlerContext<TError>) => void
value: The new value.
context: The context containing the validation result of the current value.
onErrorfunc
Callback fired when the error associated to the current value changes.

Signature:
function(error: TError, value: TValue) => void
error: The new error.
value: The value associated to the error.
onSelectedSectionsChangefunc
Callback fired when the selected sections change.

Signature:
function(newValue: FieldSelectedSections) => void
newValue: The new selected sections.
readOnlyboolfalse
It prevents the user from changing the value of the field (not from interacting with the field).
requiredboolfalse
If true, the label is displayed as required and the input element is required.
selectedSections'all'
| 'day'
| 'hours'
| 'meridiem'
| 'minutes'
| 'month'
| 'seconds'
| 'weekDay'
| 'year'
| number
| { endIndex: number, startIndex: number }
The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.
shouldDisableClockfunc
Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.
shouldDisableDatefunc
Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.
shouldDisableMonthfunc
Disable specific month.

Signature:
function(month: TDate) => boolean
month: The month to test.
returns (boolean): If true, the month will be disabled.
shouldDisableTimefunc
Disable specific time.

Signature:
function(value: TDate, view: TimeView) => boolean
value: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.
shouldDisableYearfunc
Disable specific year.

Signature:
function(year: TDate) => boolean
year: The year to test.
returns (boolean): If true, the year will be disabled.
size'medium'
| 'small'
The size of the component.
slotPropsobject{}
The props used for each component slot.
slotsobject{}
Overrideable component slots.
sxArray<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.
valueany
The selected value. Used when the component is controlled.
variant'filled'
| 'outlined'
| 'standard'
'outlined'
The variant to use.

Slots

NameTypeDefaultDescription
TextFieldelementTypeTextField from '@mui/material'
Form control with an input to render the value. Receives the same props as @mui/material/TextField.
The component cannot hold a ref.

CSS

Rule nameGlobal classDescription
root.MuiDateTimeField-rootStyles applied to the root element.

You can override the style of the component using one of these customization options: