# Blazor DateRange Picker Component Overview

The <a href="https://www.telerik.com/blazor-ui/daterange-picker" target="_blank">Blazor DateRange Picker component</a> allows the user to select a date range (start and end date) - both from a visual list ([Telerik UI for Blazor Calendar](https://www.telerik.com/blazor-ui/documentation/components/calendar/overview)) or to type it into a [date input](https://www.telerik.com/blazor-ui/documentation/components/dateinput/overview) that can accept only dates. You can control the format shown in the input, and dates the user cannot select, as well as implement validation and respond to events.

## Creating Blazor Date Range Picker

1. Use the `TelerikDateRangePicker` tag to add the component to your Razor page.
2. Bind its `StartValue` and `EndValue` parameters to `DateTime` objects.
3. (optional) Provide custom `Format`, `Min` and `Max` values.
4. (optional) Set the `AllowReverse` parameter to define whether the range is valid and highlighted when the end date precedes the start date.

> caption Basic Date Range Picker with custom format, min and max and reverse range

<demo metaUrl="client/daterangepicker/basic-2/" height="570"></demo>

## Date Input Typing Settings

The DateRangePicker
textbox is a [DateInput component](https://www.telerik.com/blazor-ui/documentation/components/dateinput/overview), which provides various parameters to configure the keyboard typing experience. The settings are related to:

* Caret placement;
* Two-digit year values;
* Automatic correction of invalid date segments.

See the [DateInput keyboard documentation](https://www.telerik.com/blazor-ui/documentation/components/dateinput/keyboard-typing) for details and examples. The same DateInput parameters with the same behavior exist for the
DateRangePicker.

## Events

The Blazor Date Range Picker generates events that you can handle and further customize its behavior. [Read more about the Blazor Date Range Picker events...](https://www.telerik.com/blazor-ui/documentation/components/daterangepicker/events).

## Validation

You can ensure that the component value is acceptable by using the built-in validation. [Read more about input validation...](https://www.telerik.com/blazor-ui/documentation/common-features/input-validation).

By default, a valid date range is when the start date is before the end date. When a valid range is selected the Calendar popup closes. To set a range where the start date is after the end date as valid you can use the [`AllowReverse` parameter](https://www.telerik.com/blazor-ui/documentation/components/daterangepicker/overview#daterangepicker-parameters). When you set `AllowReverse` to `true` the Calendar popup closes on each date selection.

## Header Template

The DateRangePicker allows you to customize the rendering of the Calendar popup header. Learn more from the [Header Template article](https://www.telerik.com/blazor-ui/documentation/components/daterangepicker/header-template).

## Adaptive Rendering

<demo metaUrl="client/daterangepicker/adaptive/" height="570"></demo>

The component supports different popup rendering depending on the screen size. [Read more about the Adaptive Rendering functionality and how to enable it...](https://www.telerik.com/blazor-ui/documentation/common-features/adaptive-rendering)

## DateRangePicker Parameters

The Blazor Date Range Picker provides various parameters that allow you to configure the component. Also check the [DateRangePicker's public API](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.components.telerikdaterangepicker-1).

<style>
    .article table {
        table-layout: auto;
        word-break: normal;
    }
</style>

| Attribute                   | Type and Default Value                          | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| --------------------------- | ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `AdaptiveMode`              | `AdaptiveMode` <br /> (`None`)                  | The [adaptive mode](https://www.telerik.com/blazor-ui/documentation/common-features/adaptive-rendering) of the component.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `AllowReverse`              | `bool`                                          | Defines if the range is valid when the selected end date is a date before the start date.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `BottomView`                | `CalendarView` enum <br/> (`Month`)             | Defines the bottommost view in the popup calendar to which the user can navigate.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `DebounceDelay`             | `int` <br/> (`150`)                             | Time in milliseconds between the last typed symbol and the value update. Use it to balance between client-side performance and number of database queries.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `DisabledDates`             | `List<DateTime>`                                | A list of dates that can not be selected as the start or end of the range. See the <a href="https://demos.telerik.com/blazor-ui/daterangepicker/disabled-dates" target="_blank">Live Demo: Date Range Picker Disabled Dates</a>.                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `Enabled`                   | `bool`                                          | Whether typing in the inputs is allowed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `ReadOnly`                  | `bool`                                          | If set to `true`, the component will be readonly and will not allow user input. The component is not readonly by default and allows user input.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `EndId` and `StartId`       | `string`                                        | The `id` attribute on the `<input />` element, so you can attach a `<label for="">` to the input.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `Format`                    | `string` <br /> (`ShortDatePattern`)            | The format of the DateRangePicker DateInputs. The default value depends on `CultureInfo.CurrentCulture`. Read more at [Supported date formats by the DateInput](https://www.telerik.com/blazor-ui/documentation/components/dateinput/supported-formats).                                                                                                                                                                                                                                                                                                                                                                                           |
| `Max`                       | `DateTime`  <br /> (`DateTime(2099, 12, 31)`)   | The latest date that the user can select.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `Min`                       | `DateTime`  <br /> (`DateTime(1900, 1, 1)`)     | The earliest date that the user can select.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `InputMode`                 | `string`                                        | The [`inputmode` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode) of the `<input />` element.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `Orientation`               | `CalendarOrientation`enum <br /> (`Horizontal`) | The orientation of the calendar popup. The available options are `Horizontal` and `Vertical`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `Placeholder`               | `string`                                        | The `placeholder` attribute of the two `<input />` elements. The `Placeholder` will appear if the component is bound to **nullable** DateTime objects - `DateTime?`, but will not be rendered if the component is bound to the default value of a non-nullable DateTime objects. The Placeholder value will be displayed when the input is not focused. Once the user focuses it to start typing, the Format Placeholder (default or [customized one](https://www.telerik.com/blazor-ui/documentation/components/daterangepicker/overview#format-placeholder)) will override the Placeholder to indicate the format the date should be entered in. |
| `ShowClearButton`           | `bool`                                          | Defines if the user can clear the component value through an **x** button rendered inside the input.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `ShowWeekNumbers`           | `bool`                                          | Sets if the popup Calendars will display week numbers according to the [ISO-8601 format](https://learn.microsoft.com/en-us/dotnet/api/system.globalization.isoweek.getweekofyear). Note that the [ISO week number may differ from the conventional .NET week number](https://learn.microsoft.com/en-us/dotnet/api/system.globalization.calendar.getweekofyear).                                                                                                                                                                                                                                                                                    |
| `ShowOtherMonthDays`        | `bool`                                          | Defines whether the leading and trailing days from other months in the Calendar popup are visible in the current month view.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `StartValue` and `EndValue` | `T`                                             | The current values of the inputs for start and end of the range. Can be used for two-way binding.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `TabIndex`                  | `int?`                                          | The `tabindex` attribute of both `input` HTML elements in the component. They both will have the same `tabindex`. Use it to customize the tabbing (focus) order of the inputs on your page.                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `Title`                     | `string`                                        | The title text rendered in the header of the popup (action sheet). Applicable only when [`AdaptiveMode` is set to `Auto`](https://www.telerik.com/blazor-ui/documentation/common-features/adaptive-rendering).                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `View`                      | `CalendarView` enum <br/> (`Month`)             | The current view that will be displayed in the popup calendar.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |

The date range picker is, essentially, two [DateInputs](https://www.telerik.com/blazor-ui/documentation/components/dateinput/overview) and a [Calendar](https://www.telerik.com/blazor-ui/documentation/components/calendar/overview) and the properties it exposes are mapped to the corresponding properties of these two components. You can read more about their behavior in the respective components' documentation.

### Typing User Experience

The component provides multiple parameters, which control the [caret placement, two-digit year values and the auto-correct behavior of the textbox. See the **DateInput** documentation for details](https://www.telerik.com/blazor-ui/documentation/components/dateinput/keyboard-typing).

### Styling and Appearance

The following parameters enable you to customize the appearance of the Blazor Date Range Picker:

| Attribute    | Type and Default Value | Description                                                                                |
| ------------ | ---------------------- | ------------------------------------------------------------------------------------------ |
| `Class`      | `string`               | The CSS class that will be rendered on the main wrapping element of the Date Range Picker. |
| `PopupClass` | `string`               | An additional CSS class to customize the appearance of the Date Range Picker popup.        |

You can find more options for customizing the Date Range Picker styling in the [Appearance article](https://www.telerik.com/blazor-ui/documentation/components/daterangepicker/appearance).

### Format Placeholder

It is possible to set custom strings as placeholders for each date format segment. This feature is available for the following Telerik UI for Blazor components:

* DateInput
* DatePicker
* DateRangePicker
* DateTimePicker
* TimePicker

To set up the `FormatPlaceholder`, use the `<*Component*FormatPlaceholder>` nested tag. It allows you to set format placeholders by using the following parameters:

* `Day`
* `Month`
* `Year`
* `Hour`
* `Minute`
* `Second`
* `Weekday`
* `DayPeriod`

By default, the value for all parameters is `null`, which applies the full format specifier.

## DateRangePicker Reference and Methods

Add a reference to the component instance to use the [Date Range Picker's methods](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.components.telerikdaterangepicker-1).

| Method            | Description                                                                                                                                                                                                                                                                                                          |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Close`           | Closes the Calendar popup.                                                                                                                                                                                                                                                                                           |
| `FocusStartAsync` | Focuses the Date Range Picker start value textbox. Always `await` this call, as it relies on `JSInterop`. Also check the dedicated KB article about [programmatic input component focusing](https://www.telerik.com/blazor-ui/documentation/knowledge-base/inputs-set-focus), which provides more examples and tips. |
| `FocusEndAsync`   | Focuses the Date Range Picker end value textbox. Always `await` this call, as it relies on `JSInterop`.                                                                                                                                                                                                              |
| `NavigateTo`      | Navigates to a specified date and view. The method expects a `DateTime` and `CalendarView` arguments.                                                                                                                                                                                                                |
| `Open`            | Opens the Calendar popup.                                                                                                                                                                                                                                                                                            |
| `Refresh`         | Re-renders the Calendar popup.                                                                                                                                                                                                                                                                                       |

<demo metaUrl="client/daterangepicker/basic-1/" height="570"></demo>

## Next Steps

* [Using the Date Range Picker Events](https://www.telerik.com/blazor-ui/documentation/components/daterangepicker/events)

## See Also

* [Live Demo: Date Range Picker](https://demos.telerik.com/blazor-ui/daterangepicker/overview)
* [Input Validation](https://www.telerik.com/blazor-ui/documentation/common-features/input-validation)
* [Supported Input Date Formats](https://www.telerik.com/blazor-ui/documentation/components/dateinput/supported-formats)
* [DateRangePicker API Reference](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.components.telerikdaterangepicker-1)
