Skip to content

DateRangePicker

A period: from one day to another, in one control. Both days are typed part by part, or picked on one calendar by pressing the first day and then the last.

import { DateRangePicker } from '@sypnia/ui/react'

On this page
  1. From one day to another
  2. States
  3. When to use it
  4. For everyone
  5. Props

From one day to another

Open the calendar and press two days. The hint counts the days.

17 days of logs, both ends included.

Code
import { useState } from 'react';
import { DateRangePicker, Field, FormGrid, type DateRange } from '@sypnia/ui/react';

const days = (r: DateRange) => Math.round((Date.parse(r.end) - Date.parse(r.start)) / 86_400_000) + 1;

export default function Basic() {
  const [period, setPeriod] = useState<DateRange | null>({ start: '2026-11-01', end: '2026-11-17' });
  return (
    <FormGrid>
      <Field label="Logs from" hint={period ? `${days(period)} days of logs, both ends included.` : 'Choose the first and the last day.'}>
        <DateRangePicker value={period} onChange={setPeriod} max="2026-11-17" />
      </Field>
    </FormGrid>
  );
}

States

With an error that says how to fix it, and disabled.

An export covers up to 31 days. Bring the two days closer.

Set by the plan.

Code
import { DateRangePicker, Field, FormGrid } from '@sypnia/ui/react';

export default function States() {
  return (
    <FormGrid>
      <Field label="Export rows created" error="An export covers up to 31 days. Bring the two days closer.">
        <DateRangePicker defaultValue={{ start: '2026-08-01', end: '2026-11-17' }} />
      </Field>
      <Field label="Billing period" hint="Set by the plan.">
        <DateRangePicker disabled defaultValue={{ start: '2026-11-01', end: '2026-11-30' }} />
      </Field>
    </FormGrid>
  );
}

When to use it

Use it when

  • A stretch of time filters or bounds something: the logs of a period, the days of an export, a maintenance window in days.
  • The start and the end only make sense together.

Do not use it when

  • It is a single day: DatePicker.
  • The two dates are separate facts (hired on, left on): two DatePickers, each with its label.
  • Only fixed periods make sense («last 7 days»): a Select.

For everyone

  • Tab enters the first day; left and right arrows move through the parts of both days; up and down change the part.
  • In the calendar, Enter on a day starts the period and Enter on another ends it; Escape before the second day cancels.
  • The control is a group named by its label, with «start date» and «end date» inside. The chosen period is announced.
  • The value is { start, end } with both days as ISO text, both included.
  • Inside a Field it takes the label, the hint and the error by itself; alone, give it an aria-label.

Props

DateRangePickerTypeDefault
aria-describedby string
aria-label

The name for screen readers when there is no Field around it.

string
aria-labelledby string
className string
defaultValue DateRange
disabled boolean
endName string
id

Inside a Field it comes from the Field.

string
invalid

Marks the value as wrong. Inside a `<Field error>` it is set for you.

boolean
max

The last day that can be chosen.

string
min

The first day that can be chosen, as `2026-11-01`.

string
name

The name of the value when it travels in a form.

string
onChange ((range: DateRange | null) => void)
startName

Names of the two values when they travel in a form.

string
unavailable

Days that cannot be chosen: return true for them.

((date: string) => boolean)
value

From one day to another, both included: `{ start: '2026-11-01', end: '2026-11-17' }`.

DateRange | null
  1. From one day to another
  2. States
  3. When to use it
  4. For everyone
  5. Props

    Search pages, sections and terms