Reputation: 1649
It is a common pattern for calendars to have previous/next month buttons in addition to the month/year picker:
Has anybody added this to their antd calendar component? Seems like a common enough problem that I'd ask before doing it myself!
Upvotes: 2
Views: 2050
Reputation: 149
you can add next/prev button like :
const [date, setDate] = useState(dayjs());
<Calendar validRange={[dayjs(props.params.startDate), dayjs(props.params.endDate)]}
value={date}
headerRender={() => (
<Row justify="space-between" className="p-1">
<Button type="link" onClick={() => setDate(dayjs())}>
Today
</Button>
<Button type="link" onClick={() => setDate(date.add(-2, 'months'))}>
Next Month
</Button>
<Button type="link" onClick={() => setDate(date.add(2, 'months'))}>
Previous Month
</Button>
</Row>
)}
}/>
you can use moment() as well
Upvotes: 2