DateRangePicker
The DateRangePicker control combines an input text field with a RangeCalendar which allows displaying a date range selected by a user in the input. You can align the popup with calendars relative to the input, set the width of the popup, apply the desired date format, use a placeholder in the input, display a selected date range and hide calendar buttons.

Related resources
- Get the widget by installing the
@svar-ui/react-corepackage. - Check DateRangePicker API Reference to see the list of configuration properties and events.
- Explore the samples to visualize the available features.
Initialization
To create a DateRangePicker instance on a page, you need to complete two steps:
- import the source file of the control on a page:
import { DateRangePicker } from "@svar-ui/react-core";
- apply the
<DateRangePicker>tag to initialize a date range picker:
<DateRangePicker />
A default date range picker is initialized with no date range selected.
Setting the value
You can select a particular date range in calendars and show it in the input of a date range picker. Use the value property for this purpose. The value of this property is an object with the start and end dates of a range. Set each date as a Date object:
const date = {
start: new Date(2024, 1, 1),
end: new Date(2024, 3, 3),
};
<DateRangePicker value={date} />
The specified date range will appear in the date range picker input and the days of the range will be highlighted in the calendars, if visible.

Related sample: DateRangePicker
Getting the current value
You can get the current value of the DateRangePicker control. For this, you need to:
- declare a state variable that will contain the control's value (it may contain the initial value):
import { useState } from "react";
import { DateRangePicker } from "@svar-ui/react-core";
function App() {
const [daterange, setDaterange] = useState({
start: new Date(2020, 1, 1),
end: new Date(2021, 3, 3),
});
return <DateRangePicker value={daterange} onChange={({ value }) => setDaterange(value)} />;
}
If you want to start with an undefined value and then update it, initialize state to null/undefined:
import { useState } from "react";
import { DateRangePicker } from "@svar-ui/react-core";
function App() {
const [value, setValue] = useState(null);
return <DateRangePicker value={value} onChange={({ value }) => setValue(value)} />;
}
After that the state assigned to the controlled value will be updated on each change of the date range.