Skip to content

Commit

Permalink
website: add docs for controlled month
Browse files Browse the repository at this point in the history
  • Loading branch information
gpbl committed Dec 15, 2024
1 parent ac1f7dc commit 04c11a1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion website/docs/docs/navigation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@ To programmatically control the month displayed when navigating, use the `month`
| `month` | `Date` | The month displayed in the calendar. |
| `onMonthChange` | [`MonthChangeEventHandler`](../api/type-aliases/MonthChangeEventHandler.md) | Callback when the month changes. |

### "Today" Button
```tsx
import { useState } from "react";

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

export function Controlled() {
const [month, setMonth] = useState(new Date());
return <DayPicker month={month} onMonthChange={setMonth} />;
}
```

### Today Button

For example, to implement a <strong>Go to Today</strong> button, set `month` to the current date when the button is clicked.

Expand Down

0 comments on commit 04c11a1

Please sign in to comment.