Prodular UI

Date range picker

Pro

A trigger showing the selected range that opens presets and a two-month calendar, with an optional compare to previous period toggle. Changes apply on Apply.

npx prodular-ui add date-range-picker

Part of Prodular UI Pro. Preview and read the docs freely, install with a license. See pricing

Reporting period with compare

The trigger shows the comparison period on wide screens. Future dates are disabled.

Revenue for Sep 22 – Oct 21, 2026, compared with Aug 23 – Sep 21, 2026

Custom presets

Replace the preset list with periods that fit the product. Custom is always added at the end.

Anatomy

<DateRangePicker  value={range}  onValueChange={setRange}  comparable  compare={compare}  onCompareChange={setCompare}/>

Guidance

Use it when

  • Analytics and reports where people switch between standard periods and sometimes pick exact dates.
  • comparable on dashboards that show deltas, so the comparison period is explicit.

Avoid

  • Picking a single date. Use Calendar in a Popover.
  • Very long ranges spanning years. Add year presets or a year select instead of paging months.

Rules for AI agents

Published in llms-full.txt, the registry and the MCP server, so coding agents follow them when they build with this component.

  • Pass a fixed today when rendering on the server or in tests, and disabledDates={{ after: today }} when future data cannot exist.
  • Treat onValueChange as the commit. It fires on Apply, not on every click in the calendar.
  • Use getPreviousPeriod(range) to compute the comparison window for your query instead of recomputing it yourself.
  • Pass presets that match the product's reporting periods. Keep them short, five at most.
  • Give the trigger an aria-label or a visible label when the context does not name the period.

API

DateRangePicker

PropTypeDefaultDescription
value / defaultValue / onValueChangeDateRange | undefined{ from, to }. onValueChange fires on Apply.
comparablebooleanfalseShows the Compare to previous period switch.
compare / defaultCompare / onCompareChangebooleanCompare state, committed with Apply.
presetsDateRangePreset[]Today, Last 7 days, Last 30 days, This quarter, Year to date{ id, label, range(today) }. Pass [] to hide the column.
todayDatenew Date()Reference date for presets.
numberOfMonthsnumber2Months shown side by side.
disabledDatesMatcherreact-day-picker matcher, for example { after: today }.

getPreviousPeriod

PropTypeDefaultDescription
(range)functionSame-length period ending the day before range.from.

formatDateRange

PropTypeDefaultDescription
(range)functionFormats as Sep 22 – Oct 21, 2026.

Installation

The Prodular UI CLI adds the source to components/ui with everything it depends on. In a project that already uses shadcn/ui, the shadcn CLI installs it from the Prodular registry too. See Installation for the first setup.

npx prodular-ui add date-range-picker# or, with the registry in components.jsonnpx shadcn@latest add @prodular/date-range-picker

Used in these screens