Talisman LogoTalisman Logo Design System
Browse documentation
Components

Date range picker

A button that opens a popover to pick a period with two calendars, typed dates, shortcuts and an optional comparison period.

Stableimport { DateRangePicker } from "@repo/ui/date-range";Source

Select the button, choose the start and the end on the calendars, or type both dates. Select Atualizar to apply the period.

When to use

  • To filter lists, reports and timelines by period.
  • When shortcuts such as “Últimos 7 dias” and “Este Mês” save time.
  • When a second period must be compared with the first (showCompare).

When not to use

  • A single date. Use the simple date picker or the date and time picker.
  • A period with a time of day. Use two date and time pickers.
  • A short list of fixed periods. Use a Select or radio filters.

States

Empty

The button shows the placeholder message until a period is applied.

Open range

With allowOpenRange, a period may have only a start or only an end.

Disabled

Examples

Comparison period

showCompare adds a switch inside the popover. When it is on, the popover shows a second pair of dates and the button shows “vs.” with the compared period.

Custom messages

Wrap the picker in DateRangeLocaleProvider to replace any message. See Messages below.

Messages

@repo/ui/date-range-locale holds the text of the picker. The package has no translation system of its own: apps provide the messages once, and every DateRangePicker below the provider uses them. Without a provider, the pt-BR defaults apply.

import { DateRangeLocaleProvider } from "@repo/ui/date-range-locale";

<DateRangeLocaleProvider value={{ cancel: "Cancel", update: "Apply" }}>
  <DateRangePicker onUpdate={handleUpdate} />
</DateRangeLocaleProvider>;

Unset keys fall back to the defaults. useDateRangeLocale() returns the active messages. useDateRangeFilterPresets() builds the quick presets (today, last 7 days, last 30 days, this month) from them. isAppDateRangeTablePresetId() checks the preset ids that the app uses in the URL.

Content

  • Name the field by what the period filters: “Período de distribuição”.
  • Pass locale="pt-BR". It formats the dates on the button and defaults to en-US.
  • Dates in the typed fields always use the day-month-year order.
  • Use placeholder for a specific hint: “Escolha o período”.

Accessibility

  • The trigger is a Button inside a Radix Popover (modal). Escape closes it and focus returns to the button.
  • The start and end fields are DateInputs with an aria-label (“Data inicial”, “Data final”) and aria-invalid when the typed text is not a valid date. An invalid range shows a message with role="alert".
  • The calendar is react-day-picker in range mode: arrow keys move between days, PageUp and PageDown change the month, Enter or Space select.
  • The layout adapts to the window size. In wide windows the shortcuts are buttons in a side list. In narrower windows they become a select. Under 400px wide or 600px high the popover is compact and the buttons are smaller (32px).
  • The footer buttons are, in order, “Limpar Filtro”, “Cancelar” and “Atualizar”. “Atualizar” is disabled while the typed dates are invalid.

Code

import { DateRangePicker } from "@repo/ui/date-range";
import type { DateRange } from "@repo/ui/date-range";

const [range, setRange] = useState<DateRange>({
  from: undefined,
  to: undefined,
});

<DateRangePicker
  locale="pt-BR"
  onUpdate={({ range }) => setRange(range)}
  showCompare={false}
  value={range}
/>;

Props

DateRangePicker
PropTypeDefaultDescription
align"start" | "center" | "end"endAlignment of the popover to the trigger
allowOpenRangebooleanfalseKeeps ranges with only a start or only an end
disabledbooleanfalseBlocks opening the picker and discards draft edits
localestring"en-US"BCP 47 tag used to format the dates in the trigger (for example pt-BR)
showComparebooleantrueShows the switch that adds a second period for comparison
side"top" | "right" | "bottom" | "left"—Side of the trigger where the popover opens
More props
PropTypeDefaultDescription
valueDateRange—Applied range. Edits are committed only through onUpdate.
onUpdate(values: { range: DateRange; rangeCompare?: DateRange }) => void—Called when the user applies the period or clears it.
initialDateFrom, initialDateToDate | string—Initial range. A string is read as yyyy-MM-dd in the local timezone.
initialCompareFrom, initialCompareToDate | string—Initial comparison range.
triggerReactNode—Custom trigger. It must accept the Radix trigger props and ref.
rangeLabels{ from: string; to: string; invalid: string }—Accessible names for the two fields and the message for an invalid range. `to` also prefixes the button text when only an end date exists.
defaultOpenbooleanfalseOpens the picker on mount without changing the range.
onOpenChange(open: boolean) => void—Called when the popover opens or closes.
DateRangeLocaleProvider
PropTypeDefaultDescription
valuePartialDeep<DateRangeLocaleMessages>—Messages to replace: placeholder, quickPresetPlaceholder, compareLabel, clearFilter, cancel, update, presets, dateInputLabels and appTableFilter.
childrenReactNode—The pickers that use these messages.

Known issues

Issue Effect
The calendars inside the popover receive no locale. Month names and weekdays are in English even when the messages and the button are in Portuguese.
locale defaults to en-US, while the messages default to pt-BR. Without locale="pt-BR" the button reads “Mar 14, 2025” next to Portuguese labels.
The calendars open on the month before today, ignoring the applied range. A period from last year opens on the wrong month, and the user must navigate back.
The “vs.” text on the button and the “… -” prefix are hardcoded, and the button text uses opacity-60. Apps cannot translate “vs.”, and the opacity lowers contrast of the secondary text and the chevron.
Preset buttons mark the selected one with a check at opacity-70. The selected state is low contrast.
The layout depends on window.innerWidth and innerHeight, with no container query. Inside a narrow dialog on a wide screen the popover still uses the wide layout.
The default trigger has no aria-label; its text is the period or the placeholder. Screen readers do not hear what the period filters. Pass a custom trigger or a visible label.
Edit this page on GitHub