Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions website/docs/guides/custom-components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Custom components allow you to extend DayPicker beyond just using [formatters](.
| `Dropdown` | [`DropdownProps`](../api/functions/Dropdown.md) | Forward `aria-label` and call `onChange` with target. |
| `Root` | [`RootProps`](../api/functions/Root.md) | Forward `rootRef` when `animate` is enabled. |

The `components` prop accepts a **partial** map—pass only the entries you want to override. The legacy `Button` entry is deprecated; prefer `NextMonthButton` and `PreviousMonthButton`.
The `components` prop accepts a **partial** map—pass only the entries you want to override.

## List of Custom Components

Expand Down Expand Up @@ -89,7 +89,6 @@ The `components` prop accepts a **partial** map—pass only the entries you want
| [`Weekdays`](../api/functions/Weekdays.md) | The row containing the week days. |
| [`Weeks`](../api/functions/Weeks.md) | The weeks section in the month grid. |
| [`YearsDropdown`](../api/functions/YearsDropdown.md) | The dropdown with the years. |
| `Button` | Deprecated: use `NextMonthButton`/`PreviousMonthButton`. |

## DayPicker Hook

Expand Down
17 changes: 13 additions & 4 deletions website/docs/guides/custom-selections.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,24 @@ Use `modifiersClassNames` or `modifiersStyles` to surface your custom state (for

## Week numbers and starts

For week-based selections, set `weekStartsOn` (locale-aware) and consider handling `onWeekNumberClick` to select a week when its number is clicked. Combine it with `showWeekNumber`.
For week-based selections, set `weekStartsOn` (locale-aware) and use a custom `WeekNumber` component to handle week selection when clicking the week number.

```tsx
<DayPicker
showWeekNumber
weekStartsOn={1}
onWeekNumberClick={(weekNumber, week, e) => {
e.preventDefault();
setSelectedWeek({ from: week.from, to: week.to });
components={{
WeekNumber: ({ week, ...thProps }) => (
<th
{...thProps}
onClick={() =>
setSelectedWeek({ from: week.days[0].date, to: week.days[6].date })
}
style={{ cursor: "pointer" }}
>
{week.weekNumber}
</th>
),
}}
modifiers={{ selected: selectedWeek }}
/>
Expand Down
Loading