UIComponentsReact
Two fields the reader types a start date and an end date into, with a button that opens a calendar in a popup to pick the range from.
Built on the headless Date Range Picker.See its API in Docs
Rendered by React 19.3.1
Installation
npx shadcn@4.23.0 add https://hamur.dev/r/react/date-range-picker.jsonIt also adds utils, button, calendar, date-picker, popover. The app needs its setup first: Installation.
Usage
The parts are the Date Picker's with a start and an end: put two DateRangePickerInputs in the DateRangePickerControl, type="start" and type="end", with a DateRangePickerSeparator between them (an en dash by default), then DateRangePickerClear and DateRangePickerTrigger. The popup is a DateRangePickerPortal, DateRangePickerPositioner, DateRangePickerPopup and DateRangePickerCalendar, which picks the range in two presses. The value is { start, end }, ISO date strings, or null. visibleMonths on the root and months on the calendar show more than one month; DateRangePickerPreset takes a function of today that returns a range, and DateRangePickerClose closes the popup. An end typed before the start is not swapped: the end field is marked invalid and the picker's value is null until it is fixed. The rest is the headless Date Range Picker's.
import {
DateRangePicker,
DateRangePickerCalendar,
DateRangePickerClear,
DateRangePickerClose,
DateRangePickerControl,
DateRangePickerInput,
DateRangePickerPopup,
DateRangePickerPortal,
DateRangePickerPositioner,
DateRangePickerPreset,
DateRangePickerSegment,
DateRangePickerSeparator,
DateRangePickerTrigger,
} from '@/components/ui/date-range-picker'Examples
Default
Two inputs with a dash between them and two months.
shadcn has no date range picker item: its page composes a Popover and a Calendar with mode="range" around an outline button. This item follows the Date Picker's composition, so it differs from shadcn's in the same places, and the value is { start, end } strings, not { from, to } dates. It takes the Date Picker's control, segment, trigger, popup, preset and close classes, so the item requires it; the calendar is the Calendar's markup on the range Root.
API reference
The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Date Range Picker's API reference.