1 | import React from "react";
|
2 |
|
3 | import { DayPicker } from "react-day-picker";
|
4 |
|
5 | export function CustomDayButton() {
|
6 | const [selected, setSelected] = React.useState<Date>();
|
7 | return (
|
8 | <DayPicker
|
9 | mode="single"
|
10 | onSelect={setSelected}
|
11 | selected={selected}
|
12 | components={{
|
13 | DayButton: (props) => {
|
14 | const { day, modifiers, ...buttonProps } = props;
|
15 | return (
|
16 | <button
|
17 | {...buttonProps}
|
18 | onDoubleClick={() => setSelected(day.date)}
|
19 | onClick={() => setSelected(undefined)}
|
20 | />
|
21 | );
|
22 | }
|
23 | }}
|
24 | footer={selected?.toDateString() || "Double click to select a date"}
|
25 | />
|
26 | );
|
27 | }
|