Skip to content

Date Range Picker

date-range-picker

A button that opens a calendar for a date range: the range said in words on the trigger, a day count, Clear and Done, and optional presets. Ranges can refuse disabled days inside them, for bookings.

Install

$npxshadcnadd@forme/date-range-picker

Adds the component, its registry dependencies, and the token stylesheet you import once.

Usage

import { DateRangePicker } from "@/components/forme/date-range-picker/date-range-picker";

<DateRangePicker label="Report period" value={range} onValueChange={setRange} />

When to use

Reach for it

  • Choosing a span — a report period, a stay, a leave request — where the trigger should say the range in words.

Use something else

  • A single date: use Calendar in a Popover, or a plain date field when the date is typed more often than browsed.

API reference

Read from the source, so it is the API of the file you install. A prop marked * is required.

DateRangePicker

A button that opens a calendar for a date range.

PropTypeDefaultDescription
valueDateRange | null—The range, for controlled use. null is no range; leave it out to go uncontrolled.
defaultValueDateRange | null—The starting range when uncontrolled.
onValueChange(range: DateRange | null) => void—Called with the new range, or null when it is cleared.
presetsreadonly DateRangePreset[][]Quick picks under the calendar: "Last 7 days", "This month".
placeholderstring"Pick a date range"Trigger text while nothing is picked.
labelstring"Date range"Names the trigger and the calendar for assistive technology.
minDate—
maxDate—
isDisabled(date: Date) => boolean—Return true for any date that cannot be picked.
contiguousboolean—Refuse a range with a disabled day inside it, as for a booking.
weekStartsOn0 | 1—0 is Sunday, 1 is Monday.
localestring"en-US"
closeOnSelectbooleanfalseClose once a range is complete or a preset is picked. Off by default.
disabledboolean—
classNamestring—

Accessibility

  • The trigger is named with its label and the current range; opening it focuses the selected day so the arrow keys work at once, and closing returns focus to the trigger.
  • Start, end, refused ranges and the day count are announced as they change.

Motion

  • The trigger's text morphs between ranges so the layout beside it glides; the popover condenses in like every Forme popover.

Responsive behaviour

  • The popover is the calendar's width and never wider than the screen minus its margins.