### Run DayPicker Examples App Source: https://daypicker.dev/development/contributing Start the development server for the examples app using Vite. This app is served at http://localhost:5173 and is useful for testing isolated examples. ```bash pnpm --filter examples-app run dev ``` -------------------------------- ### Install React DayPicker with Bun Source: https://daypicker.dev/v8?calendar=hebrew Install React DayPicker and date-fns using Bun. ```bash bun add react-day-picker date-fns ``` -------------------------------- ### Install React DayPicker with Bun Source: https://daypicker.dev/v8?calendar=ethiopic Install the react-day-picker and date-fns packages using Bun. ```bash bun add react-day-picker date-fns ``` -------------------------------- ### Install DayPicker with Bun Source: https://daypicker.dev/start Use this command to install the DayPicker package using Bun. ```bash bun add @daypicker/react ``` -------------------------------- ### Install React DayPicker with npm Source: https://daypicker.dev/v8?calendar=ethiopic Install the react-day-picker and date-fns packages using npm. ```bash npm install react-day-picker date-fns ``` -------------------------------- ### Install React DayPicker with Yarn Source: https://daypicker.dev/v8?calendar=hebrew Install React DayPicker and date-fns using Yarn. ```bash yarn add react-day-picker date-fns ``` -------------------------------- ### Install React DayPicker with Yarn Source: https://daypicker.dev/v8?calendar=ethiopic Install the react-day-picker and date-fns packages using Yarn. ```bash yarn add react-day-picker date-fns ``` -------------------------------- ### Install React DayPicker with npm Source: https://daypicker.dev/v8?calendar=hebrew Install React DayPicker and date-fns using npm. ```bash npm install react-day-picker date-fns ``` -------------------------------- ### Install @daypicker/react using Bun Source: https://daypicker.dev/upgrading-v8-to-v10 Use this command to install the v10 package with Bun. The `next` tag is recommended during the prerelease phase. ```bash bun remove react-day-picker bun add @daypicker/react ``` -------------------------------- ### Install DayPicker Hijri Package (Bun) Source: https://daypicker.dev/localization/hijri Install the React and Hijri calendar packages using Bun. ```bash bun add @daypicker/react @daypicker/hijri ``` -------------------------------- ### Install React DayPicker with pnpm Source: https://daypicker.dev/v8?calendar=hebrew Install React DayPicker and date-fns using pnpm. ```bash pnpm add react-day-picker date-fns ``` -------------------------------- ### Install DayPicker with Yarn Source: https://daypicker.dev/start Use this command to install the DayPicker package using Yarn. ```bash yarn add @daypicker/react ``` -------------------------------- ### Install React DayPicker with pnpm Source: https://daypicker.dev/v8?calendar=ethiopic Install the react-day-picker and date-fns packages using pnpm. ```bash pnpm add react-day-picker date-fns ``` -------------------------------- ### Create a Rolling N-day Window Selection Source: https://daypicker.dev/guides/custom-selections This example creates a fixed-length date range (e.g., 7 days) that starts from the day the user clicks. It highlights the start, middle, and end of the range. ```typescript import { addDays } from "date-fns"; import { useState } from "react"; import { type DateRange, DayPicker } from "@daypicker/react"; export function CustomRollingWindow() { const [range, setRange] = useState(); const windowLength = 7; const applyRange = (start: Date): DateRange => ({ from: start, to: addDays(start, windowLength - 1), }); return ( { if (modifiers.disabled || modifiers.hidden) return; setRange(modifiers.selected ? undefined : applyRange(day)); }} onDayKeyDown={(day, modifiers, e) => { if (e.key === " " || e.key === "Enter") { e.preventDefault(); if (modifiers.disabled || modifiers.hidden) return; setRange(modifiers.selected ? undefined : applyRange(day)); } }} /> ); } ``` -------------------------------- ### Install @daypicker/react using npm Source: https://daypicker.dev/upgrading-v8-to-v10 Use this command to install the v10 package with npm. The `next` tag is recommended during the prerelease phase. ```bash npm remove react-day-picker npm install @daypicker/react ``` -------------------------------- ### Install DayPicker Persian Package with Bun Source: https://daypicker.dev/localization/persian Install the DayPicker React package and the Persian calendar package using Bun. ```bash bun add @daypicker/react @daypicker/persian ``` -------------------------------- ### Install @daypicker/react using pnpm Source: https://daypicker.dev/upgrading-v8-to-v10 Use this command to install the v10 package with pnpm. The `next` tag is recommended during the prerelease phase. ```bash pnpm remove react-day-picker pnpm add @daypicker/react ``` -------------------------------- ### Install @daypicker/react using Yarn Source: https://daypicker.dev/upgrading-v8-to-v10 Use this command to install the v10 package with Yarn. The `next` tag is recommended during the prerelease phase. ```bash yarn remove react-day-picker yarn add @daypicker/react ``` -------------------------------- ### Install DayPicker with npm Source: https://daypicker.dev/start Use this command to install the DayPicker package using npm. ```bash npm install @daypicker/react ``` -------------------------------- ### Install DayPicker with pnpm Source: https://daypicker.dev/start Use this command to install the DayPicker package using pnpm. ```bash pnpm add @daypicker/react ``` -------------------------------- ### Install DayPicker Hijri Package (pnpm) Source: https://daypicker.dev/localization/hijri Install the React and Hijri calendar packages using pnpm. ```bash pnpm add @daypicker/react @daypicker/hijri ``` -------------------------------- ### Install DayPicker React and Buddhist Calendar (Bun) Source: https://daypicker.dev/localization/buddhist Install the necessary DayPicker React and Buddhist calendar packages using Bun. ```bash bun add @daypicker/react @daypicker/buddhist ``` -------------------------------- ### Install DayPicker Persian Package with Yarn Source: https://daypicker.dev/localization/persian Install the DayPicker React package and the Persian calendar package using Yarn. ```bash yarn add @daypicker/react @daypicker/persian ``` -------------------------------- ### Install DayPicker Hijri Package (Yarn) Source: https://daypicker.dev/localization/hijri Install the React and Hijri calendar packages using Yarn. ```bash yarn add @daypicker/react @daypicker/hijri ``` -------------------------------- ### Install DayPicker Hijri Package (npm) Source: https://daypicker.dev/localization/hijri Install the React and Hijri calendar packages using npm. ```bash npm install @daypicker/react @daypicker/hijri ``` -------------------------------- ### Example Usage Source: https://daypicker.dev/api/react/type-aliases/DateAfter An example demonstrating how to use the DateAfter type alias to create a matcher for dates after February 2, 2019. ```APIDOC ## Example ```javascript // Match days after February 2, 2019 const matcher: DateAfter = { after: new Date(2019, 1, 2) }; ``` ``` -------------------------------- ### Install DayPicker Persian Package with npm Source: https://daypicker.dev/localization/persian Install the DayPicker React package and the Persian calendar package using npm. ```bash npm install @daypicker/react @daypicker/persian ``` -------------------------------- ### Install Ethiopic Calendar Package with Bun Source: https://daypicker.dev/localization/ethiopic Install the DayPicker React and Ethiopic calendar packages using Bun. ```bash bun add @daypicker/react @daypicker/ethiopic ``` -------------------------------- ### Install DayPicker React and Buddhist Calendar (npm) Source: https://daypicker.dev/localization/buddhist Install the necessary DayPicker React and Buddhist calendar packages using npm. ```bash npm install @daypicker/react @daypicker/buddhist ``` -------------------------------- ### Matcher Example Source: https://daypicker.dev/api/react/type-aliases/Matcher Example of using the Matcher type to specify weekends and a specific holiday range. ```APIDOC ## Example​ ```javascript // Match weekends and specific holidays const matcher: Matcher = [ { dayOfWeek: [0, 6] }, // Weekends { from: new Date(2023, 11, 24), to: new Date(2023, 11, 26) }, // Christmas ]; ``` ``` -------------------------------- ### Install DayPicker React and Buddhist Calendar (Yarn) Source: https://daypicker.dev/localization/buddhist Install the necessary DayPicker React and Buddhist calendar packages using Yarn. ```bash yarn add @daypicker/react @daypicker/buddhist ``` -------------------------------- ### Install DayPicker Persian Package with pnpm Source: https://daypicker.dev/localization/persian Install the DayPicker React package and the Persian calendar package using pnpm. ```bash pnpm add @daypicker/react @daypicker/persian ``` -------------------------------- ### Basic Single Day Picker Example Source: https://daypicker.dev/?calendar=hebrew A basic example demonstrating how to use DayPicker to select a single day. It includes state management for the selected date and a custom footer displaying the selected date or a prompt. ```jsx import { DayPicker } from "@daypicker/react"; import "@daypicker/react/style.css"; function MyDatePicker() { const [selected, setSelected] = useState(); return ( ); } ``` -------------------------------- ### Install Ethiopic Calendar Package with npm Source: https://daypicker.dev/localization/ethiopic Install the DayPicker React and Ethiopic calendar packages using npm. ```bash npm install @daypicker/react @daypicker/ethiopic ``` -------------------------------- ### Install Ethiopic Calendar Package with pnpm Source: https://daypicker.dev/localization/ethiopic Install the DayPicker React and Ethiopic calendar packages using pnpm. ```bash pnpm add @daypicker/react @daypicker/ethiopic ``` -------------------------------- ### Clone DayPicker Repository and Install Dependencies Source: https://daypicker.dev/development/contributing Clone the DayPicker repository and install its dependencies using pnpm. This is the initial step to set up your local development environment. ```bash git clone https://github.com/gpbl/react-day-picker.git cd react-day-picker pnpm install ``` -------------------------------- ### Install Ethiopic Calendar Package with Yarn Source: https://daypicker.dev/localization/ethiopic Install the DayPicker React and Ethiopic calendar packages using Yarn. ```bash yarn add @daypicker/react @daypicker/ethiopic ``` -------------------------------- ### Install DayPicker React and Buddhist Calendar (pnpm) Source: https://daypicker.dev/localization/buddhist Install the necessary DayPicker React and Buddhist calendar packages using pnpm. ```bash pnpm add @daypicker/react @daypicker/buddhist ``` -------------------------------- ### Run DayPicker Documentation Website Source: https://daypicker.dev/development/contributing Start the Docusaurus development server for the documentation website. The site will be available at http://localhost:2001. ```bash pnpm --filter website run start ``` -------------------------------- ### Install Hebrew calendar package with Bun Source: https://daypicker.dev/upgrading When using the Hebrew calendar, install the dedicated package alongside the main React package using Bun. ```bash bun add @daypicker/react @daypicker/hebrew ``` -------------------------------- ### Install Persian calendar package with Bun Source: https://daypicker.dev/upgrading When using the Persian calendar, install the dedicated package alongside the main React package using Bun. ```bash bun add @daypicker/react @daypicker/persian ``` -------------------------------- ### Install Persian calendar package with pnpm Source: https://daypicker.dev/upgrading When using the Persian calendar, install the dedicated package alongside the main React package using pnpm. ```bash pnpm add @daypicker/react @daypicker/persian ``` -------------------------------- ### Install Hebrew calendar package with pnpm Source: https://daypicker.dev/upgrading When using the Hebrew calendar, install the dedicated package alongside the main React package using pnpm. ```bash pnpm add @daypicker/react @daypicker/hebrew ``` -------------------------------- ### Install Persian calendar package with Yarn Source: https://daypicker.dev/upgrading When using the Persian calendar, install the dedicated package alongside the main React package using Yarn. ```bash yarn add @daypicker/react @daypicker/persian ``` -------------------------------- ### Example Matcher Usage Source: https://daypicker.dev/api/react/type-aliases/Matcher Use Matcher to define custom rules for highlighting days, such as weekends or specific holiday periods. This example shows how to combine date ranges and day-of-week rules. ```javascript // Match weekends and specific holidays const matcher: Matcher = [ { dayOfWeek: [0, 6] }, // Weekends { from: new Date(2023, 11, 24), to: new Date(2023, 11, 26) }, // Christmas ]; ``` -------------------------------- ### Install Hebrew calendar package with npm Source: https://daypicker.dev/upgrading When using the Hebrew calendar, install the dedicated package alongside the main React package using npm. ```bash npm install @daypicker/react @daypicker/hebrew ``` -------------------------------- ### Install Persian calendar package with npm Source: https://daypicker.dev/upgrading When using the Persian calendar, install the dedicated package alongside the main React package using npm. ```bash npm install @daypicker/react @daypicker/persian ``` -------------------------------- ### Install Hebrew calendar package with Yarn Source: https://daypicker.dev/upgrading When using the Hebrew calendar, install the dedicated package alongside the main React package using Yarn. ```bash yarn add @daypicker/react @daypicker/hebrew ``` -------------------------------- ### Basic Single Day Picker Example Source: https://daypicker.dev/v8?calendar=hebrew A basic example of a single day picker component using React DayPicker and useState for managing the selected date. Ensure to import the default styles. ```jsx import { DayPicker } from "react-day-picker"; import "react-day-picker/dist/style.css"; function MyDatePicker() { const [selected, setSelected] = useState(); return ; } ``` -------------------------------- ### Upgrade DayPicker Package with Bun Source: https://daypicker.dev/upgrading Use these commands to remove the old react-day-picker package and install the new @daypicker/react package using Bun. ```bash bun remove react-day-picker bun add @daypicker/react ``` -------------------------------- ### Multiple Date Selection Example Source: https://daypicker.dev/docs/selection-modes Demonstrates how to implement multiple date selection using the 'multiple' mode. Requires importing useState and DayPicker. ```javascript import { useState } from "react"; import { DayPicker } from "@daypicker/react"; export function App() { const [selected, setSelected] = useState(); const handleSelect = (newSelected) => { // Update the selected dates setSelected(newSelected); }; return ( ); } ``` -------------------------------- ### startOfDay Source: https://daypicker.dev/api/react/classes/DateLib Calculates the start of the day for a given date. ```APIDOC ## startOfDay() ### Description Returns the start of the day for the given date. ### Parameters #### Path Parameters - **date** (Date) - Required - The original date. ### Returns - **Date** - The start of the day. ``` -------------------------------- ### startOfISOWeek Source: https://daypicker.dev/api/react/classes/DateLib Calculates the start of the ISO week for a given date. ```APIDOC ## startOfISOWeek() ### Description Returns the start of the ISO week for the given date. ### Parameters #### Path Parameters - **date** (Date) - Required - The original date. ### Returns - **Date** - The start of the ISO week. ``` -------------------------------- ### Get Months of an Interval Source: https://daypicker.dev/api/react/classes/DateLib Use the eachMonthOfInterval method to retrieve an array of all months within a specified date interval. The interval should be an object with 'start' and 'end' dates. ```javascript dateLib.eachMonthOfInterval(interval); ``` -------------------------------- ### startOfMonth Source: https://daypicker.dev/api/react/classes/DateLib Calculates the start of the month for a given date. ```APIDOC ## startOfMonth() ### Description Returns the start of the month for the given date. ### Parameters #### Path Parameters - **date** (Date) - Required - The original date. ### Returns - **Date** - The start of the month. ``` -------------------------------- ### Date Ranges with Independent Times Source: https://daypicker.dev/guides/timepicker This example demonstrates how to manage date ranges where the start and end times are selected independently. It applies the selected times to the respective dates when a range is chosen. ```typescript const [from, setFrom] = useState(); const [to, setTo] = useState(); const [fromTime, setFromTime] = useState("09:00"); const [toTime, setToTime] = useState("17:00"); const applyTime = (date: Date | undefined, time: string) => { if (!date) return undefined; const [h, m] = time.split(":").map((str) => parseInt(str, 10)); return setHours(setMinutes(date, m), h); }; { setFrom(applyTime(range?.from, fromTime)); setTo(applyTime(range?.to, toTime)); }} />; ``` -------------------------------- ### Basic Buddhist DayPicker Setup Source: https://daypicker.dev/playground?calendar=buddhist Import and render the DayPicker component for use with the Buddhist calendar. Ensure you have the necessary import from 'react-day-picker/buddhist'. ```javascript import { DayPicker } from "react-day-picker/buddhist"; ``` -------------------------------- ### Get Years of an Interval Source: https://daypicker.dev/api/react/classes/DateLib Use the eachYearOfInterval method to retrieve an array of all years within a specified date interval. The interval should be an object with 'start' and 'end' dates. This method was introduced in version 9.11.1. ```javascript dateLib.eachYearOfInterval(interval); ``` -------------------------------- ### startOfBroadcastWeek Source: https://daypicker.dev/api/react/classes/DateLib Calculates the start of the broadcast week for a given date. ```APIDOC ## startOfBroadcastWeek() ### Description Returns the start of the broadcast week for the given date. ### Parameters #### Path Parameters - **date** (Date) - Required - The original date. - **_dateLib** (DateLib) - Required - ### Returns - **Date** - The start of the broadcast week. ``` -------------------------------- ### Upgrade DayPicker Package with Yarn Source: https://daypicker.dev/upgrading Use these commands to remove the old react-day-picker package and install the new @daypicker/react package using Yarn. ```bash yarn remove react-day-picker yarn add @daypicker/react ``` -------------------------------- ### Upgrade DayPicker Package with pnpm Source: https://daypicker.dev/upgrading Use these commands to remove the old react-day-picker package and install the new @daypicker/react package using pnpm. ```bash pnpm remove react-day-picker pnpm add @daypicker/react ``` -------------------------------- ### Upgrade DayPicker Package with npm Source: https://daypicker.dev/upgrading Use these commands to remove the old react-day-picker package and install the new @daypicker/react package using npm. ```bash npm remove react-day-picker npm install @daypicker/react ``` -------------------------------- ### CalendarMonth Constructor Source: https://daypicker.dev/api/react/classes/CalendarMonth Initializes a new instance of the CalendarMonth class. It takes the month's starting date and an array of CalendarWeek objects as arguments. ```APIDOC ## new CalendarMonth(month, weeks) ### Description Initializes a new instance of the CalendarMonth class. ### Parameters #### Parameters - **month** (Date) - The date representing the first day of the month. - **weeks** (CalendarWeek[]) - An array of CalendarWeek objects representing the weeks within the month. ### Returns `CalendarMonth` - A new instance of the CalendarMonth class. ``` -------------------------------- ### Implement Single Day Selection Source: https://daypicker.dev/guides/custom-selections Replicate the 'single selection' mode behavior. This example manages a single selected date state and applies a 'selected' modifier. ```javascript import { useState } from "react"; import { DayPicker, DayPickerProps } from "@daypicker/react"; export function CustomSingle() { const [selectedDate, setSelectedDate] = useState(); const modifiers: DayPickerProps["modifiers"] = {}; if (selectedDate) { modifiers.selected = selectedDate; } return ( { if (modifiers.disabled || modifiers.hidden) return; setSelectedDate(modifiers.selected ? undefined : day); }} onDayKeyDown={(day, modifiers, e) => { if (e.key === " " || e.key === "Enter") { e.preventDefault(); if (modifiers.disabled || modifiers.hidden) return; setSelectedDate(modifiers.selected ? undefined : day); } }} footer={selectedDate && `You selected ${selectedDate.toDateString()}`} /> ); } ``` -------------------------------- ### Implementing OnSelectHandler Source: https://daypicker.dev/api/react/type-aliases/OnSelectHandler Example of how to implement the OnSelectHandler type for handling date selection events. This handler logs the selected date and the date that triggered the event. ```typescript const handleSelect: OnSelectHandler = ( selected, triggerDate, modifiers, e, ) => { console.log("Selected:", selected); console.log("Triggered by:", triggerDate); }; ``` -------------------------------- ### Implement Week Selection Source: https://daypicker.dev/guides/custom-selections Select an entire week by clicking a single day. This example uses date-fns for week calculations and custom modifiers for styling and ARIA. ```javascript import React, { useState } from "react"; import { endOfWeek, startOfWeek } from "date-fns"; import { type DateRange, DayPicker, rangeIncludesDate } from "@daypicker/react"; /** Select the whole week when the day is clicked. */ export function CustomWeek() { const [selectedWeek, setSelectedWeek] = useState(); return ( selectedWeek ? rangeIncludesDate(selectedWeek, date, true) : false, }} onDayClick={(day, modifiers) => { if (modifiers.disabled || modifiers.hidden) return; if (modifiers.selected) { setSelectedWeek(undefined); return; } setSelectedWeek({ from: startOfWeek(day), to: endOfWeek(day), }); }} onDayKeyDown={(day, modifiers, e) => { if (e.key === " " || e.key === "Enter") { e.preventDefault(); if (modifiers.disabled || modifiers.hidden) return; if (modifiers.selected) { setSelectedWeek(undefined); return; } setSelectedWeek({ from: startOfWeek(day), to: endOfWeek(day), }); } }} footer={ selectedWeek && `Week from ${selectedWeek?.from?.toLocaleDateString()} to ${selectedWeek?.to?.toLocaleDateString()}` } /> ); } ``` -------------------------------- ### Constructor Source: https://daypicker.dev/api/react/classes/DateLib Creates an instance of DateLib with optional configuration options and custom overrides. ```APIDOC ## Constructor Creates an instance of `DateLib`. ### Parameters - `options?` (DateLibOptions): Configuration options for the date library. - `overrides?` (Partial): Custom overrides for the date library functions. ### Returns `DateLib` ``` -------------------------------- ### Basic Single Day Picker Example Source: https://daypicker.dev/?calendar=buddhist This snippet demonstrates how to set up a basic single-day selection calendar using the DayPicker component. It includes state management for the selected date and a custom footer displaying the selected date or a prompt. ```jsx import { DayPicker } from "@daypicker/react"; import "@daypicker/react/style.css"; function MyDatePicker() { const [selected, setSelected] = useState(); return ( ); } ``` -------------------------------- ### Search for formatting and utility functions Source: https://daypicker.dev/upgrading-v8-to-v10 Use these patterns with `rg` to find custom formatting and utility functions in your project. ```bash rg "formatMonthCaption|formatYearCaption|labelDay|labelCaption|isMatch|isDateInRange" ``` -------------------------------- ### Search for component names Source: https://daypicker.dev/upgrading-v8-to-v10 Use these patterns with `rg` to find common component names used for navigation and day rendering. ```bash rg "IconLeft|IconRight|IconDropdown|DayContent|Caption|HeadRow|Row" ``` -------------------------------- ### DateBefore Type Alias Example Source: https://daypicker.dev/api/react/type-aliases/DateBefore Example of how to use the DateBefore type alias to match days before a specific date. This is useful for setting date range limitations. ```typescript // Match days before February 2, 2019 const matcher: DateBefore = { before: new Date(2019, 1, 2) }; ``` -------------------------------- ### Implement 'Go to Today' Button Source: https://daypicker.dev/docs/navigation Create a 'Go to Today' button by resetting the `month` state to the current date when the button is clicked. Requires `date-fns` for `addMonths` if used for initial state. ```jsx import { useState } from "react"; import { addMonths } from "date-fns"; import { DayPicker } from "@daypicker/react"; export function Controlled() { const today = new Date(); const nextMonth = addMonths(today, 1); const [month, setMonth] = useState(nextMonth); return ( <> ); } ``` -------------------------------- ### Reset Range Selection After Completion Source: https://daypicker.dev/selections/range-mode Use the `resetOnSelect` prop to start a new range selection immediately after a complete range has been selected. The clicked day will become the start of the new range. ```jsx ``` -------------------------------- ### Initialize DateLib with Locale Source: https://daypicker.dev/api/react/classes/DateLib Instantiate the DateLib class with a specific locale configuration. This is useful for internationalization and localization of date displays. ```javascript const dateLib = new DateLib({ locale: es }); const newDate = dateLib.addDays(new Date(), 5); ``` -------------------------------- ### Search for custom hooks and providers Source: https://daypicker.dev/upgrading-v8-to-v10 Use these patterns with `rg` to find custom hooks and context providers related to active modifiers, focus management, and selection. ```bash rg "useActiveModifiers|useFocusContext|useSelectSingle|useSelectMultiple|useSelectRange|DayPickerProvider|NavigationProvider|FocusProvider" ``` -------------------------------- ### startOfYear Source: https://daypicker.dev/api/react/classes/DateLib Calculates the start of the year for a given date. ```APIDOC ## startOfYear() ### Description Returns the start of the year for the given date. ### Parameters #### Path Parameters - **date** (Date) - Required - The original date. ### Returns - **Date** - The start of the year. ``` -------------------------------- ### startOfWeek Source: https://daypicker.dev/api/react/classes/DateLib Calculates the start of the week for a given date. ```APIDOC ## startOfWeek() ### Description Returns the start of the week for the given date. ### Parameters #### Path Parameters - **date** (Date) - Required - The original date. - **_options?** (StartOfWeekOptions) - Optional - ### Returns - **Date** - The start of the week. ``` -------------------------------- ### Use DayPicker.Input Component Source: https://daypicker.dev/changelog The `DayPicker.Input` component is now included in the built file. Use `` to render the input component. ```javascript ``` -------------------------------- ### Search for event handler props Source: https://daypicker.dev/upgrading-v8-to-v10 Use these patterns with `rg` to locate common event handler props in your project. ```bash rg "selected=|initialFocus|onWeekNumberClick|onDayKeyUp|onDayKeyPress|onDayPointerEnter|onDayPointerLeave|onDayTouch" ``` -------------------------------- ### Import DayPicker from Persian Build Source: https://daypicker.dev/localization/persian Import the DayPicker component from the dedicated Persian build to enable Persian calendar features. ```javascript import { DayPicker } from "@daypicker/persian"; ``` -------------------------------- ### Remove date-fns package Source: https://daypicker.dev/upgrading-v8-to-v10 If `date-fns` was only installed as a peer dependency for DayPicker locales, you can now remove it. ```bash npm remove date-fns ``` -------------------------------- ### Search for CSS import patterns Source: https://daypicker.dev/upgrading-v8-to-v10 Use these patterns with `rg` to find common CSS import variations in your project. ```bash rg "react-day-picker/dist/style|react-day-picker/dist/style.module|fromDate|toDate|fromMonth|toMonth|fromYear|toYear" ``` -------------------------------- ### DateRange Type Alias Source: https://daypicker.dev/api/react/type-aliases/DateRange Defines a range of dates with optional start and end properties. ```APIDOC ## Type Alias: DateRange > **DateRange** = { `from`: `Date` | `undefined`; `to?`: `Date`; } Defined in: packages/react-day-picker/src/types/shared.ts:202 A range of dates. Unlike DateInterval, the range ends are included. ### Properties #### from > **from** : `Date` | `undefined` Defined in: packages/react-day-picker/src/types/shared.ts:202 * * * #### to? > `optional` **to?** : `Date` Defined in: packages/react-day-picker/src/types/shared.ts:202 ``` -------------------------------- ### Define Modifiers Object Source: https://daypicker.dev/api/react/type-aliases/Modifiers Example of how to define a Modifiers object with various boolean flags for day matching. ```typescript const modifiers: Modifiers = { today: true, selected: false, weekend: true }; ``` -------------------------------- ### startMonth Source: https://daypicker.dev/api/interfaces/PropsBase Specifies the earliest month to be displayed in the navigation. ```APIDOC ## startMonth ### Description The earliest month to start the month navigation. ### Type `optional Date` ### Defined in `packages/react-day-picker/src/types/props.ts:124` ### Since `9.0.0` ### See https://daypicker.dev/docs/navigation#start-and-end-dates ``` -------------------------------- ### Remove date-fns package using Bun Source: https://daypicker.dev/upgrading-v8-to-v10 If `date-fns` was only installed as a peer dependency for DayPicker locales, you can now remove it. ```bash bun remove date-fns ``` -------------------------------- ### Search for prop types Source: https://daypicker.dev/upgrading-v8-to-v10 Use these patterns with `rg` to find prop type definitions for different DayPicker configurations. ```bash rg "DayPickerSingleProps|DayPickerMultipleProps|DayPickerRangeProps|DayPickerDefaultProps|useInput|useNavigation|useDayRender" ``` -------------------------------- ### Remove date-fns package using pnpm Source: https://daypicker.dev/upgrading-v8-to-v10 If `date-fns` was only installed as a peer dependency for DayPicker locales, you can now remove it. ```bash pnpm remove date-fns ``` -------------------------------- ### Remove date-fns package using Yarn Source: https://daypicker.dev/upgrading-v8-to-v10 If `date-fns` was only installed as a peer dependency for DayPicker locales, you can now remove it. ```bash yarn remove date-fns ``` -------------------------------- ### SelectedValue Examples Source: https://daypicker.dev/api/react/type-aliases/SelectedValue Demonstrates how to use the SelectedValue type alias for different selection modes: single, multiple, and range. ```typescript const selected: SelectedValue<{ mode: "single" }> = new Date(); ``` ```typescript const selected: SelectedValue<{ mode: "multiple" }> = [ new Date(), new Date(), ]; ``` ```typescript const selected: SelectedValue<{ mode: "range" }> = { from: new Date(), to: new Date(), }; ```