React-dates: Render date picker within custom container

Created on 1 May 2018  路  4Comments  路  Source: airbnb/react-dates

I am trying to use the date range picker in my app and want a few more buttons within the calendar modal - I want a close button, an OK button and a clear button. I am happy to implement the functionality of these within my app but can't see a way to get these inside the date picker component?

So I wanted to do something like:

               <div>
                 <Button icon={CrossIcon} onClick={onCancel} />
                 <DateRangePicker { ...datePickerProps } />
                 <div>
                   <Button info text="Clear" onClick={this.onClearDates} />
                   <Button primary text="OK" onClick={this.onConfirmDates} />
                 </div>
              </div>

and have the date picker render within my component... Is there any way of achieving this?

All 4 comments

If you want to add buttons below the calendars, try passing them via renderCalendarInfo

<DateRangePicker
  ...
  renderCalendarInfo={(props) => {
    return (
      <div onClick={...}>Apply</div>
    )
  }}
/>

And style it to look something like
44359958-3194e700-a46e-11e8-8cf4-24f1c5847212

Nicotroia's mention helped me in added many buttons like "Last 7 Days", "Last Month" and others. But, here I noticed an issue. Once the button, for example, "Last 7 Days" is clicked, the Date Range is being highlighted and dates are also backfilled, but the calendar is not closed. Can someone please suggest how do I achieve this functionality of closing the calendar on clicking these custom buttons?

I am also not able to find any solution to "close the range picker progrmmatically".

In my use case, I need to have both a left pannel, and a bottom pannel.
The problem is there is only one prop renderCalendarInfo for rendering, and another prop calendarInfoPosition to choose where to display the component.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AsasinCree picture AsasinCree  路  3Comments

prztrz picture prztrz  路  3Comments

thomasdtucker picture thomasdtucker  路  3Comments

Jesus-Gonzalez picture Jesus-Gonzalez  路  3Comments

Adam-Pendleton picture Adam-Pendleton  路  3Comments