Athena Wisdom
Athena Wisdom

Reputation: 6831

Cannot Open Up in "Month" View using react-daterange-picker

How can we set DateRangePicker from the @wojtekmaj/react-daterange-picker package to show only months (i.e. like a month picker) when the component is first clicked?

Tried using

<DateRangePicker
    onChange={onChange}
    value={value}
    maxDetail="month"
    calendarIcon={null}
/>

but it is opening up in the "day" view

enter image description here

instead of the "month" view

enter image description here

Upvotes: 0

Views: 661

Answers (2)

Nazmul Alam
Nazmul Alam

Reputation: 91

Your DateRangePicker options maxDetail value should be "year" instead of "month".

<DateRangePicker
   onChange={onChange}
   value={value}
   maxDetail="year"
/>

Upvotes: 2

buzatto
buzatto

Reputation: 10382

maxDetail default is already set to month. Since a month is composed (details) by days that's why you get that outcome.

In your case you need to set maxDetail="year", given year details are composed by months:

<DateRangePicker
    onChange={onChange}
    value={value}
    maxDetail="year"
    calendarIcon={null}
/>

Upvotes: 1

Related Questions