DateRangePicker
Deprecated, use DatePicker with presets. DateRangePicker selects a range of dates: two months side by side, presets such as Today, Last 7 days or Last month next to them, and an input where the range can be typed. The presets follow the first day of the week of the locale, the active one is highlighted, custom presets can be added, and the value is a [start, end] pair of dates for template-driven, reactive and Signal Forms.
Deprecated #
DateRangePicker is deprecated since 22.15.0 and will be removed in 23. Use DatePicker with selectionMode="range" and the presets input instead, as shown in the Presets section of DatePicker: it takes the same preset keys and custom presets, and the datePresets key of the locale translates both components. DateRangePicker keeps working until then.
Import #
import { DateRangePicker } from '@exhaustive-ui/core/daterangepicker';Basic #
DateRangePicker is bound with ngModel to a [start, end] pair of dates, null while there is no range. The button opens two months side by side with a list of presets next to them: pick a preset, or click the first and the last day in the calendars. The range can also be typed in the input, such as 02/12/2026 – 09/12/2026 with the date format of the locale.
Presets #
The presets input chooses the built-in presets and their order: today, yesterday, last7Days, last30Days, last90Days, thisWeek, lastWeek, monthToDate, thisMonth, lastMonth, yearToDate, thisYear and lastYear. They are computed from the current day each time the panel opens, and the weeks start on the firstDayOfWeek of the locale, or of the input of the same name, here Monday. The preset that matches the range is highlighted, and the Custom range item when none does; an empty array hides the list.
Custom Presets #
A custom preset has a label and a range: a pair of dates, or a function that computes them when the list opens and when the preset is picked. Custom presets mix with the keys of the built-in ones, in the order of the array, and showCustomPreset removes the Custom range item.
Number of Months #
Two months are displayed side by side by default, the end of the range on the last one. numberOfMonths changes the number of months; on screens narrower than 768px, a single month is displayed and the presets move below the calendar.
Min and Max Dates #
minDate and maxDate bound the days that can be picked, typed or reached by a preset: a preset that goes past them is cut to them, and one entirely outside of them is disabled. disabledDates and disabledDays disable single days or days of the week. Here the range has to be in the last 90 days.
Time #
With showTime, the calendars have a time picker for the date picked last and the input shows the times; the panel then stays open after the second date so that the times can be changed. A preset ends at 23:59. hourFormat switches to a 12 hour clock.
Inline #
With inline, the presets and the calendars are displayed in the page, without an input.
- Today
- Last 7 days
- This week
- This month
- Last month
- This year
- Custom range
Template #
The preset template replaces the content of a preset, with the preset, whether it is active and whether it is focused; the range of a built-in or custom preset is in preset.range. The header and footer templates add content above and below the panel, and dropdownicon replaces the icon of the button.
Labels and Locale #
The texts of the component, the names of the presets and the announcements included, are merged from the labels input with the English defaults. The names of the days and of the months, the date format and the first day of the week come from the locale of the configuration, set with setTranslation; dateFormat, firstDayOfWeek and rangeSeparator override them for one component.
Clear #
With showClear, a button clears the range when there is one. Emptying the input does the same.
Sizes #
DateRangePicker provides small and large sizes as alternatives to the base.
Filled #
Specify the variant property as filled to display the component with a higher visual emphasis than the default outlined style.
Disabled #
When the disabled property is present, the range cannot be changed.
Invalid #
The invalid state is applied using the invalid property to indicate failed validation, here while there is no range.
Forms #
Template Driven #
The value is a [start, end] pair of dates once a whole range is picked, typed or set by a preset, and null otherwise: a start date alone is not a value, so required works as on the other fields. Link the message with ariaDescribedBy so that it is read with the field.
Reactive Forms #
DateRangePicker can also be used with reactive forms, through the formControlName property. setValue takes a pair of dates, or of ISO strings, and a reversed pair is put in order.
Signal Forms #
DateRangePicker can also be used with Angular Signal Forms. The [formField] directive binds the component to a field holding a pair of dates or null, and sets its invalid and touched states, so it is styled as invalid once the field is touched or the form is submitted.
Accessibility #
Screen Reader
The input has the combobox role with aria-haspopup="dialog", aria-expanded and aria-controls, like the button that opens the panel, whose accessible name is the chooseRangeLabel text. Label the input with a label element pointing at inputId, with ariaLabelledBy or with ariaLabel; without any of them it is named by the inputLabel text. Link an error message with ariaDescribedBy; aria-invalid follows the invalid state.
The panel is a dialog named by the chooseRangeLabel text, a group when the component is inline. The presets are a listbox named by the presetsLabel text: the preset that matches the range, or the custom range item, has aria-selected="true", the option with the keyboard focus is given by aria-activedescendant, and presets outside of the minimum and maximum dates have aria-disabled="true". The calendars are the grids of DatePicker, each day named by its full date.
A polite live region announces the range selected, with the name of the preset when it comes from one, that the start date is picked and the end date is expected, and that the range is cleared. All the texts can be replaced, or translated, with the labels input.
<label for="period">Period</label>
<p-date-range-picker inputId="period" ariaDescribedBy="period-help" />
<small id="period-help">The figures of the report cover these days.</small>
<p-date-range-picker ariaLabel="Période" [labels]="{ chooseRangeLabel: 'Choisir une période', presetsLabel: 'Périodes', rangeSelectedMessage: 'Du {0} au {1}' }" />Input Keyboard Support
| Key | Function |
|---|---|
| any character | Types the range; it is selected as soon as both dates are complete and selectable, such as 02/12/2026 – 09/12/2026. A hyphen between spaces or to also separates the dates. |
| down arrow | Opens the panel and moves the focus to the presets, or to the calendars without presets. |
| enter | Closes the panel and shows the selected range in the input. |
| escape | Closes the panel. |
| tab | Moves the focus to the clear button and to the button that opens the panel. |
Panel Keyboard Support
| Key | Function |
|---|---|
| tab | Moves the focus from the presets to the buttons of the calendars and to the days, and back to the presets from the last element. |
| shift + tab | Moves the focus backwards, and to the last element from the presets. |
| escape | Closes the panel and moves the focus back to the input. A start date picked without an end date is dropped. |
Presets Keyboard Support
| Key | Function |
|---|---|
| up arrow / down arrow | Moves the focus to the previous or the next preset, skipping the disabled ones. |
| home / end | Moves the focus to the first or the last preset. |
| enter / space | Selects the range of the preset and closes the panel; on the custom range item, moves the focus to the calendars. |
Calendars Keyboard Support
| Key | Function |
|---|---|
| left arrow / right arrow | Moves the focus to the previous or the next day. |
| up arrow / down arrow | Moves the focus to the same day of the previous or the next week. |
| page up / page down | Shows the previous or the next month. |
| home / end | Moves the focus to the first or the last day of the month. |
| enter / space | Picks the start date, then the end date: the range is selected and the panel closes. |