EQTY LabDocs

Date Range Picker

Input for selecting a start and end date

View as Markdown

Overview

Date Range Picker lets users choose a start and end date from a calendar. It renders as a Button showing the current range, which opens a Popover containing a month calendar with navigation.

Usage

Import the component:

tsx
import { DateRangePicker } from "@eqtylab/equality";

Hold the range in state and pass it back through onSelect:

tsx
import { useState } from "react";

const [dateRange, setDateRange] = useState<{ from?: Date; to?: Date }>({});

<DateRangePicker dateRange={dateRange} onSelect={setDateRange} />;

Both from and to are optional Date objects. from is the first moment of its day and to the last (23:59:59.999), so a completed range covers both selected days in full.

Time Zone

Days follow the browser’s time zone. When your app lets people pick their own, pass it as timeZone, an IANA name. The calendar’s today, the selected days, the trigger’s label and the from and to you get back then all follow that zone, so the range matches dates shown elsewhere in your app. An unknown zone name throws a RangeError, as Intl does, so check a stored preference before passing it.

tsx
<DateRangePicker
  dateRange={dateRange}
  onSelect={setDateRange}
  timeZone="Europe/Paris"
/>

Default

Props

NameDescriptionTypeDefaultRequired
dateRangeThe currently selected range. { from, to } — both optional Date values.{ from?: Date; to?: Date }—✅
onSelectCalled with the updated range whenever the user picks a date or clears the selection.(range: { from?: Date; to?: Date }) => void—✅
classNameAdditional CSS classes applied to the trigger button.string—❌
timeZoneIANA time zone the days follow, such as Europe/Paris.stringBrowser’s zone❌