DateRangePicker

Two inputs to type a start and an end date, with a calendar of two months to pick the range. The text is a date in the YYYY-MM-DD format, which is the same in every country.

General

Name the group with aria-label. In the calendar, the first click sets the start, the second sets the end and closes it.

Initial value

Start with a range using initialValue, a pair of dates. Use value and onChange to control it.

Controlled

onChange receives the pair [start, end]. While the range is being picked, end is null.

Min and max

A date outside the limits cannot be typed, and its day is disabled in the calendar.

Variants

Use filled, light, ghost or subtle with a type to change the surface of the field.

Disabled

Locks both inputs and the calendar button.

APIs

DateRangePicker.Props

AttributeDescriptionTypeAccepted valuesDefault
valueselected range, to control the component[Date | null, Date | null]--
initialValuerange at the start[Date | null, Date | null]-[null, null]
onChangecalled with [start, end], with end as null while the range is picked(range: [Date | null, Date | null]) => void--
minfirst date that can be pickedDate--
maxlast date that can be pickedDate--
localelanguage of the calendarstringany Intl localeen-US
weekStartsOnfirst day of the week in the calendar, 0 is Sundaynumber0 to 60
startPlaceholdertext shown when the start input is emptystring-YYYY-MM-DD
endPlaceholdertext shown when the end input is emptystring-YYYY-MM-DD
startLabelname of the start inputstring-Start date
endLabelname of the end inputstring-End date
calendarLabelname of the calendar button and of its dialogstring-Choose dates
disableddisable the componentboolean-false
typecolor of the fieldNormalTypes'default', 'primary', 'secondary', 'success', 'warning', 'error', 'info'default
roundedround the cornersboolean-false
filledfilled variantboolean-false
lightlight variantboolean-false
ghostoutline variantboolean-false
subtlesubtle variantboolean-false
...native props, passed to the group divHTMLAttributes'aria-label', 'id', ...-

Typing

Each input changes the range only for a real date inside min and max. The end cannot come before the start, so that text is not accepted. When an input loses the focus, it goes back to the last valid date. An empty text clears that edge of the range.

Ref

The ref points at the group div.

Accessibility

The group is named by aria-label, and each input has its own name, Start date and End date, which you can translate with startLabel and endLabel. The calendar button has aria-haspopup="dialog" and aria-expanded. The calendar opens in a dialog that shows two months side by side, with the focus on the day of the start. Escape closes it and puts the focus back on the button, and picking the end puts the focus on the end input. See Calendar for the keys.

Edit this page on GitHub