Date Range Picker
date-range-pickerA 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.
"use client";
import { useState } from "react";
import { DateRangePicker } from "@/components/forme/date-range-picker/date-range-picker";
import type { DateRange, DateRangePreset } from "@/components/forme/date-range-picker/date-range-picker";
const day = (base: Date, offset: number) =>
new Date(base.getFullYear(), base.getMonth(), base.getDate() + offset);
export function DateRangePickerDemo() {
// Built on mount, never at module scope: "today" on the server is not today
// in the reader's browser, and the mismatch would break hydration.
const [setup] = useState(() => {
const today = new Date();
const presets: DateRangePreset[] = [
{ label: "Last 7 days", range: { from: day(today, -6), to: today } },
{ label: "Last 30 days", range: { from: day(today, -29), to: today } },
{
label: "This month",
range: {
from: new Date(today.getFullYear(), today.getMonth(), 1),
to: new Date(today.getFullYear(), today.getMonth() + 1, 0),
},
},
];
return { today, presets };
});
const [range, setRange] = useState<DateRange | null>({
from: day(setup.today, -6),
to: setup.today,
});
return (
<div className="flex flex-col items-start gap-6">
<DateRangePicker
label="Report period"
value={range}
onValueChange={setRange}
presets={setup.presets}
max={setup.today}
weekStartsOn={1}
/>
<DateRangePicker
label="Stay"
placeholder="Check-in – check-out"
min={setup.today}
// A booked stretch the stay can't cross: `contiguous` refuses a range
// over it rather than quietly including it.
isDisabled={(date) => {
const offset = Math.round((date.getTime() - setup.today.getTime()) / 86_400_000);
return offset >= 9 && offset <= 11;
}}
contiguous
closeOnSelect
/>
</div>
);
}Install
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
Calendarin aPopover, 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.
| Prop | Type | Default | Description |
|---|---|---|---|
value | DateRange | null | — | The range, for controlled use. null is no range; leave it out to go uncontrolled. |
defaultValue | DateRange | null | — | The starting range when uncontrolled. |
onValueChange | (range: DateRange | null) => void | — | Called with the new range, or null when it is cleared. |
presets | readonly DateRangePreset[] | [] | Quick picks under the calendar: "Last 7 days", "This month". |
placeholder | string | "Pick a date range" | Trigger text while nothing is picked. |
label | string | "Date range" | Names the trigger and the calendar for assistive technology. |
min | Date | — | |
max | Date | — | |
isDisabled | (date: Date) => boolean | — | Return true for any date that cannot be picked. |
contiguous | boolean | — | Refuse a range with a disabled day inside it, as for a booking. |
weekStartsOn | 0 | 1 | — | 0 is Sunday, 1 is Monday. |
locale | string | "en-US" | |
closeOnSelect | boolean | false | Close once a range is complete or a preset is picked. Off by default. |
disabled | boolean | — | |
className | string | — |
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.
Related


Calendar
A month grid for a single date or a range, with no date library. Full WAI-ARIA keyboard support, month and year pickers, min, max and disabled days, a range that previews under the pointer or the keyboard, and a fixed six-week height so nothing below it jumps.
inputsColor picker
A full colour editor: a saturation and brightness area, hue and opacity rails, a hex field, numeric channels, screen sampling and preset swatches — all composed from parts, opened from a trigger chip that previews the value.
inputsColor selector
A row of colour swatches where exactly one is chosen. Real radio inputs inside a fieldset, so forms, required state, arrow keys and screen-reader grouping all work natively, and one selection ring hops between swatches.
inputs