Skip to content

DateField API

API documentation for the React DateField component. Learn about the available props and the CSS API.

Import

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

Component name

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

Props

NameTypeDefaultDescription
componentsobject{}
Overrideable components.
componentsPropsobject{}
The props used for each component slot.
defaultValueany
The default value. Use when the component is not controlled.
disableFutureboolfalse
If true disable values before the current date for date components, time for time components and both for date time components.
disablePastboolfalse
If true disable values after the current date for date components, time for time components and both for date time components.
formatstring
Format of the date when rendered in the input(s).
maxDateany
Maximal selectable date.
minDateany
Minimal selectable date.
onChangefunc
Callback fired when the value changes.

Signature:
function(value: TValue, The: FieldChangeHandlerContext<TError>) => void
value: The new value.
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).
selectedSections'day'
| 'hours'
| 'meridiem'
| 'minutes'
| 'month'
| 'seconds'
| '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.
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.
shouldDisableYearfunc
Disable specific year.

Signature:
function(year: TDate) => boolean
year: The year to test.
returns (boolean): If true the year will be disabled.
valueany
The selected value. Used when the component is controlled.

Slots

NameTypeDefaultDescription
InputelementTypeTextField
Input rendered.
The component cannot hold a ref.

Demos