MaskedDateInput
Masked date input with individual fields for day, month and year
Source
LLM docs
Docs
Package
Usage
MaskedDateInput is similar to TimePicker but for dates.
It provides individual masked input fields for day, month, and year with an optional
calendar dropdown for date selection.
Controlled
The MaskedDateInput value is a string in YYYY-MM-DD format (for example 2000-06-15).
When withTime is set, the value uses YYYY-MM-DD HH:mm:ss format (for example 2000-06-15 14:30:00).
null is used to represent no value. The onChange function is called when all fields are filled
or when all fields are cleared.
null
With time
Set the withTime prop to display hours and minutes fields in addition to date fields.
With seconds
Set the withSeconds prop to display the seconds field. The withTime prop must also be set.
12-hour format
Set format="12h" to use 12-hour time format. The am/pm selector is displayed automatically.
Change am/pm labels
Use the amPmLabels prop to customize am/pm labels:
Date separator
Use the dateSeparator prop to change the separator displayed between date fields. The default is /.
Time separator
Use the timeSeparator prop to change the separator displayed between time fields. The default is :.
Fields order
Use the fieldsOrder prop to control the display order of day, month, and year fields.
The default order is ['day', 'month', 'year'].
Min and max dates
Set the minDate and maxDate props to restrict the selectable date range. If a value outside
the allowed range is entered, it is clamped to the nearest valid date when the input loses focus.
Allow deselect
Set the allowDeselect prop to allow clearing the value by clicking the selected date in the
calendar dropdown:
Without dropdown
Set withDropdown={false} to disable the calendar dropdown:
Dropdown position
Use popoverProps to pass props down to the underlying Popover component.
For example, to always display the dropdown above the input:
Hours/minutes/seconds step
Use hoursStep, minutesStep and secondsStep props to control the increment/decrement step
for each time field when using arrow keys:
Paste events
By default, MaskedDateInput handles pasted values in YYYY-MM-DD and YYYY-MM-DD HH:mm:ss
formats. With the pasteSplit prop you can provide a custom paste parser that extracts day,
month, and year values from a pasted string:
Try pasting a date in DD.MM.YYYY format. For example, try pasting 15.06.2000
Clearable
Set the clearable prop to display a clear button in the right section of the input.
Clear section mode
The clearSectionMode prop determines how the clear button and rightSection are rendered:
'both'(default) – render both the clear button andrightSection'rightSection'– render only the user-suppliedrightSection, ignore clear button'clear'– render only the clear button, ignorerightSection
Disabled
Read only
Input props
MaskedDateInput component supports Input and Input.Wrapper component features and all div element props. The MaskedDateInput documentation does not include all features supported by the component – see the Input documentation to learn about all available features.
Input description
Get refs
Use dayRef, monthRef, yearRef, hoursRef, minutesRef, secondsRef and amPmRef props
to get refs of the inner inputs:
onFocus and onBlur
onFocus is called when one of the inputs receives focus and onBlur is called when focus
leaves all inputs:
Accessibility
Each field has an English aria-label by default (Day, Month, Year, Hours, Minutes, Seconds, AM/PM),
and the fields are grouped under the label. Use the corresponding props to translate the labels.
Also set an aria-label for the clear button if clearable is used:
Keyboard interactions: