Skip to main content
Version: 8.10.2

Localization

Configure the Locale​

Set a Different Locale​

To set a locale different than the the default English (US), pass to the locale prop a Locale object imported from date-fns.

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 "date-fns/locale";

<DayPicker locale={es} />; // Set the locale to Spanish

First Date of the Week​

Use weekStartsOn to override the first date of the week.

<DayPicker weekStartsOn={0} />

First Week of the Year​

Use weekStartsOn to override the first date of the first week of the year, used to calculate the week numbers. Possible values are 1 (Monday) or 4 (Thursday).

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

ISO Week Dates​

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

<DayPicker
showWeekNumber
ISOWeek // Switch to ISO week
/>

Translate DayPicker​

Draft

This paragraph is still a work in progress. If you have any questions, ask to the discussions page on Github.

Use these props to translate DayPicker in any language.

ARIA Labels​

ARIA labels are used by DayPicker to provide a better accessibility experience. Use the labels prop to translate the labels used in the component.

<DayPicker
labels={{
labelNext: () => "Prossimo mese"
labelPrevious: () => "Mese precedente"
}}
/>

Formatters​

Use the formatters prop to format the dates and the week numbers.

RTL Text Direction​

To set the right-to-left text direction, toggle the dir prop to rtl.

import { arSA } from "date-fns/locale";

<DayPicker locale={arSA} dir="rtl" />;

Numbering System​

Use the proper formatters to change the numbering system used in the calendar.

For example, to switch to hindu-arabic use the native Date.toLocaleString:

import { format } from "date-fns/format";
import { arSA } from "date-fns/locale";
import { DayPicker, Formatters } from "react-day-picker";

const NU_LOCALE = "ar-u-nu-arab";

const formatDay = (day) => day.getDate().toLocaleString(NU_LOCALE);
const formatWeekNumber = (weekNumber) => weekNumber.toLocaleString(NU_LOCALE);
const formatMonthCaption = (date, options) => {
const y = date.getFullYear().toLocaleString(NU_LOCALE);
const m = format(date, "LLLL", options);
return `${m} ${y}`;
};

export function NumberingSystemExample() {
return (
<DayPicker
locale={arSA}
dir="rtl"
showWeekNumber
formatters={{
formatDay,
formatMonthCaption,
formatWeekNumber
}}
/>
);
}