Skip to main content

Localization

Learn how to set the locale, changing the time zone, and adjust other calendar options.

Setting the Locale​

Prop NameTypeDescription
localeLocaleSet the locale. Default is en-US.

DayPicker export the date-fns locales for easier calendar localization. To set a different locale, import it from react-day-picker/locale.

// import the locale object
import { es } from "react-day-picker/locale";

By default, the locale is set to English (US). To localize the calendar, pass the imported Locale object to the locale prop.

For example, to localize the calendar in Spanish, import the es locale object from date-fns and pass it to the component.

import { es } from "react-day-picker/locale";

<DayPicker locale={es} />; // Set the locale to Spanish
septiembre 2024
lumamijuvisádo
1
2345678
9101112131415
16171819202122
23242526272829
30
Customizing the Locale

You can customize the locale by passing an object with the desired translations. Use the defaultLocale object for the default translation values.

import { DayPicker, defaultLocale } from "react-day-picker";

<DayPicker
locale={{
localize: {
...defaultLocale.localize,
day: (day) => "custom-localized-day"
}
}}
month={new Date(2023, 0, 1)}
mode="single"
/>;

Changing the Time Zone​

Experimental Feature

Time zones are supported by the TZDate object by the @date-fns/tz package. If you encounter any issues, please report them. Thank you!

Prop NameTypeDescription
timeZonestringSet a time zone for the dates in the calendar.

Use the timeZone prop to set a different time zone for the calendar. See Wikipedia for a list of the possible values.

<DayPicker timeZone="UTC" /> // Use Coordinated Universal Time
<DayPicker timeZone="Pacific/Kiritimati" /> // Use Line Islands Time
September 2024
SuMoTuWeThFrSa

Working with Time-Zoned Dates​

When working with time zones, make sure to use the TZDate object instead of the native Date object. The TZDate object is exported from @date-fns/tz. Refer to their documentation for more information.

To initialize a date in a specific time zone, use the tz method:

export function TimeZone() {
const timeZone = "America/New_York";
const [selected, setSelected] = useState<Date | undefined>(
TZDate.tz(timeZone) // Make sure you use `TZDate` instead of `Date`
);
return (
<DayPicker
mode="single"
timeZone={timeZone}
selected={selected}
onSelect={setSelected}
/>
);
}

Calendar Options​

Prop NameTypeDescription
weekStartsOn1 | 2 | 3 | 4 | 5 | 6 | 7Display the days falling into the other months.
firstWeekContainsDate1 | 4Configure the first date in the first week of the year.
ISOWeekbooleanUse ISO Week Dates.

First Date of the Week​

Use the weekStartsOn prop to set the first day of the week.

<DayPicker locale={es} weekStartsOn={0} /> // Start the week on Domingo
septiembre 2024
dolumamijuvisá
1234567
891011121314
15161718192021
22232425262728
2930

First Week Contains Date​

The firstWeekContainsDate prop sets the first day of the year's initial week, which is used to calculate week numbers.

<DayPicker
showWeekNumber
firstWeekContainsDate={1} // First week must contain Monday
/>

ISO Week Dates​

Use the ISOWeek prop to switch to ISO Week Dates instead of the locale setting.

<DayPicker ISOWeek />
September 2024
MoTuWeThFrSaSu
351
362345678
379101112131415
3816171819202122
3923242526272829
4030

Jalali Calendar​

DayPicker supports the Jalali calendar through the date-fns-jalali package. To switch to the Jalali calendar, add date-fns-jalali to your dependencies and import DayPicker from react-day-picker/jalali.

Experimental Feature

Support for the Jalali calendar is an experimental feature. Please report any issues you encounter. Thank you!

1. Install the date-fns-jalali package​

npm install date-fns-jalali

2. Import DayPicker from react-day-picker/jalali​

- import { DayPicker } from 'react-day-picker';
+ import { DayPicker } from 'react-day-picker/jalali';

3. Use DayPicker as usual​

You can set the right-to-left direction and change the locale as needed.

./JalaliCalendar.jsx
import React from "react";

import { DayPicker } from "react-day-picker/jalali";
import { faIR } from "react-day-picker/locale";

export function Jalali() {
return <DayPicker mode="single" locale={faIR} dir="rtl" />;
}
جون 1403
ش1ش2ش3ش4ش5شج