Skip to content

MultiInputDateRangeField API

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

Demos

Import

import { MultiInputDateRangeField } from '@mui/x-date-pickers-pro/MultiInputDateRangeField';
// or
import { MultiInputDateRangeField } from '@mui/x-date-pickers-pro';

Learn about the difference by reading this guide on minimizing bundle size.

Props

NameTypeDefaultDescription
autoFocusbool-

If true, the input element is focused during the first mount.

classesobject-

Override or extend the styles applied to the component.

See CSS classes API below for more details.

dateSeparatorstring"–"

String displayed between the start and the end dates.

defaultValueArray<object>-

The default value. Use when the component is not controlled.

direction'column-reverse'
| 'column'
| 'row-reverse'
| 'row'
| Array<'column-reverse'
| 'column'
| 'row-reverse'
| 'row'>
| object
'column'

Defines the flex-direction style property. It is applied for all screen sizes.

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.

disablePastboolfalse

If true, disable values before the current date for date components, time for time components and both for date time components.

dividernode-

Add an element between each child.

formatstring-

Format of the date when rendered in the input(s).

formatDensity'dense'
| 'spacious'
"dense"

Density of the format when rendered in the input. Setting formatDensity to "spacious" will add a space before and after each /, - and . character.

maxDateobject-

Maximal selectable date.

minDateobject-

Minimal selectable date.

onChangefunc-

Callback fired when the value changes.

Signature:function(value: TValue, context: FieldChangeHandlerContext) => 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).

referenceDateobjectThe closest valid date using the validation props, except callbacks such as `shouldDisableDate`. Value is rounded to the most granular section used.

The date used to generate a part of the new value that is not present in the format when both value and defaultValue are empty. For example, on time fields it will be used to determine the date to set.

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 FieldSectionType is provided, the first section with that name will be selected. 3. If "all" is provided, all the sections 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.
Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.

Signature:function(day: TDate, position: string) => boolean
  • day The date to test.
  • position The date to test, 'start' or 'end'.

Returns: Returns true if the date should be disabled.

shouldRespectLeadingZerosbool`false`

If true, the format will respect the leading zeroes (e.g: on dayjs, the format M/D/YYYY will render 8/16/2018) If false, the format will always add leading zeroes (e.g: on dayjs, the format M/D/YYYY will render 08/16/2018)
Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so shouldRespectLeadingZeros={true} might lead to inconsistencies when using AdapterLuxon.
Warning n°2: When shouldRespectLeadingZeros={true}, the field will add an invisible character on the sections containing a single digit to make sure onChange is fired. If you need to get the clean value from the input, you can remove this character using input.value.replace(/\u200e/g, '').
Warning n°3: When used in strict mode, dayjs and moment require to respect the leading zeros. This mean that when using shouldRespectLeadingZeros={false}, if you retrieve the value directly from the input (not listening to onChange) and your format contains tokens without leading zeros, the value will not be parsed by your library.

slotPropsobject{}

The props used for each component slot.

slotsobject{}

Overridable component slots.

See Slots API below for more details.

spacingArray<number
| string>
| number
| object
| string
0

Defines the space between immediate children.

sxArray<func
| object
| bool>
| func
| object
-

The system prop, which allows defining system overrides as well as additional CSS styles.

See the `sx` page for more details.

timezonestringThe 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.

useFlexGapboolfalse

If true, the CSS flexbox gap is used instead of applying margin to children.
While CSS gap removes the known limitations, it is not fully supported in some browsers. We recommend checking https://caniuse.com/?search=flex%20gap before using this flag.
To enable this flag globally, follow the theme's default props configuration.

valueArray<object>-

The selected value. Used when the component is controlled.

The component cannot hold a ref.

CSS classes

These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.

Class nameRule nameDescription
.MuiMultiInputDateRangeField-rootrootStyles applied to the root element.
.MuiMultiInputDateRangeField-separatorseparatorStyles applied to the separator element.

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