Date Range Picker

DateRangePicker is a two-date input that pairs a text-style trigger with a calendar popover and an optional preset side panel.

tsx
import { DateRangePicker } from '@/components/ui/wideset/daterangepicker/DateRangePicker';

<DateRangePicker className="w-[18rem] max-w-full" defaultSelected={{ from: '2026-11-03', to: '2026-11-09' }} />

Installation

pnpm dlx wideset add date-range-picker

Copies the component and any Wideset components it uses into your project.

Examples

Variants

Primary is the field's normal state. Danger marks a range that failed validation, such as an end date before the start; pair it with an error message under the field (Form field does that), because the red border alone tells a screen reader nothing.

tsx
import { DateRangePicker } from '@/components/ui/wideset/daterangepicker/DateRangePicker';

export default function DateRangePickerVariants() {
  return (
    <div className="gap-ws-12 flex w-[18rem] max-w-full flex-col">
      {(['primary', 'danger'] as const).map((variant) => (
        <DateRangePicker
          key={variant}
          variant={variant}
          defaultSelected={{ from: '2026-11-03', to: '2026-11-09' }}
        />
      ))}
    </div>
  );
}

Presets

Border outlines the field, for forms where it sits among other inputs. Ghost drops the outline, for toolbars and report headers where the field should read as part of the surface. Keep one preset per form.

tsx
import { DateRangePicker } from '@/components/ui/wideset/daterangepicker/DateRangePicker';

export default function DateRangePickerPresets() {
  return (
    <div className="gap-ws-12 flex w-[18rem] max-w-full flex-col">
      {(['border', 'ghost'] as const).map((preset) => (
        <DateRangePicker
          key={preset}
          preset={preset}
          defaultSelected={{ from: '2026-11-03', to: '2026-11-09' }}
        />
      ))}
    </div>
  );
}

Sizes

Medium is the default. Small fits dense tables and filter bars; large gives the field more presence and a bigger hit area on touch screens. Match the size of the inputs next to it.

tsx
import { DateRangePicker } from '@/components/ui/wideset/daterangepicker/DateRangePicker';

export default function DateRangePickerSizes() {
  return (
    <div className="gap-ws-12 flex w-[18rem] max-w-full flex-col">
      {(['sm', 'md', 'lg'] as const).map((size) => (
        <DateRangePicker
          key={size}
          size={size}
          defaultSelected={{ from: '2026-11-03', to: '2026-11-09' }}
        />
      ))}
    </div>
  );
}

Date presets

showDatePresets adds a side panel of common ranges (Today, This Week, Last Month…) next to the calendar. A chosen preset shows its name in the field, not the dates, and is worked out from today when the field mounts. Turn it on for reporting filters; leave it off when the user books specific days. Open the field to see the panel.

tsx
import { DateRangePicker } from '@/components/ui/wideset/daterangepicker/DateRangePicker';

export default function DateRangePickerDatePresets() {
  return (
    <div className="gap-ws-5 flex flex-wrap items-center justify-center">
      <DateRangePicker className="w-[16rem]" showDatePresets defaultDatePreset="lastWeek" />
      <DateRangePicker
        className="w-[16rem]"
        showDatePresets
        defaultSelected={{ from: '2026-11-03', to: '2026-11-09' }}
      />
    </div>
  );
}

States

Empty shows the placeholder, so phrase it as the thing to pick ("Pick your stay"). With a range chosen the field shows both ends in dateFormat, while onSelect always gets ISO yyyy-MM-dd strings. A disabled field does not open and leaves the tab order.

tsx
import { DateRangePicker } from '@/components/ui/wideset/daterangepicker/DateRangePicker';

export default function DateRangePickerStates() {
  return (
    <div className="gap-ws-12 flex w-[18rem] max-w-full flex-col">
      <DateRangePicker placeholder="Pick your stay" />
      <DateRangePicker defaultSelected={{ from: '2026-11-03', to: '2026-11-09' }} />
      <DateRangePicker defaultSelected={{ from: '2026-11-03', to: '2026-11-09' }} disabled />
    </div>
  );
}

API reference

NameDescriptionDefault
activeDatePreset

Active preset. Provide to make the component controlled.

'today''custom''yesterday''thisWeek''lastWeek''thisMonth''lastMonth''thisYear''lastYear'
—
aria-describedby

Ids of the elements that describe the trigger button, such as a FormField's helper text.

string
—
aria-invalid

Marks the trigger button invalid; FormField sets it while it shows an error.

boolean | 'true' | 'false' | 'grammar' | 'spelling'
—
aria-label

Accessible name of the trigger button when no visible label is associated.

string
—
aria-labelledby

Id of the element that names the trigger button.

string
—
className

Class name to add to the root element. Additional class name forwarded to the trigger element.

string
—
dateFormat

date-fns format string used to render the selected range in the trigger (e.g. `'MMMM d, yyyy'`). Defaults to `'MM/dd/yy'`.

string
'MM/dd/yy'
defaultDatePreset

Initial preset for uncontrolled usage. Mutually exclusive with defaultSelected.

'today''custom''yesterday''thisWeek''lastWeek''thisMonth''lastMonth''thisYear''lastYear'
—
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
defaultSelected

Initial range for uncontrolled usage. Mutually exclusive with defaultDatePreset.

DateRangeValue
—
disabled

Apply the `disabled` modifier to the matching days. Disabled days cannot be selected when in a selection mode is set. Disables the trigger and prevents the popup from opening.

((Matcher | Matcher[]) & boolean)
—
disabledDates

Dates or matchers that should be unselectable inside the calendar grid.

Matcher | Matcher[]
—
id

Id of the trigger button, so a `<label htmlFor>` can name it.

string
—
onSelect

Fired when a range or preset is picked. Receives the new range and the matching preset (`'custom'` for arbitrary range selections).

((range?: DateRangeValue | undefined, preset?: 'today' | 'custom' | 'yesterday' | 'thisWeek' | 'lastWeek' | 'thisMonth' | 'lastMonth' | 'thisYear' | 'lastYear' | undefined) => void)
—
placeholder

Placeholder shown in the trigger when no range is selected. Defaults to `'Select date range'`.

string
'Select date range'
preset
'border''ghost'
—
presetLabels

Override labels for one or more presets, in the side panel and in the trigger while a preset other than `custom` is active (`custom` shows the picked dates there). Unspecified keys fall back to the built-in English labels.

Partial<Record<'today' | 'custom' | 'yesterday' | 'thisWeek' | 'lastWeek' | 'thisMonth' | 'lastMonth' | 'thisYear' | 'lastYear', string>>
—
selected

Selected range. Provide to make the component controlled.

DateRangeValue
—
showDatePresets

Shows the preset side panel (Today, This Week, Last Month, …) alongside the calendar. Defaults to `false`.

boolean
false
size
'sm''md''lg'
—
today

The today’s date. Default is the current date. This date will get the `today` modifier to style the day. The date the calendar marks as today and the presets (Today, This Week, Last Month, …) count from. Defaults to the current date; set it to show a fixed sample date.

Date
—
variant
'primary''danger'
—

Accessibility

  • Name the trigger with id plus a label, or aria-label. FormField links helper and error text and sets aria-invalid.
  • Pair variant="danger" with an error message (an end before the start, a span too long).
tsx
import { DateRangePicker } from '@/components/ui/wideset/daterangepicker/DateRangePicker';

<DateRangePicker className="w-[18rem] max-w-full" defaultSelected={{ from: '2026-11-03', to: '2026-11-09' }} />

Appearance

Variant
Style
Size

Content

Preset panel
Value

State

Disabled