Custom Header

You can customize how the header of calendar looks and how the components are arranged. Besides that you can also add custom functionality, like a segmented control that lets people switch between week and month view.

Use the renderCalendarHeader option for passing a custom header layout. There are predefined components - shorthands if you will - that can be used to assemble the header:

  • Navigation component - <CalendarNav />
  • Today button - <CalendarToday />
  • Previous month button - <CalendarPrev />
  • Next month button - <CalendarNext />
Get started with this example

Demo

Default header

The default header contains the two arrows on the far-right for previous and next months, while the current month indicator with the CalendarNav component is placed to the far-left.

<Datepicker
    controls={['calendar']}
    calendarType="week"
    calendarSize={2}
/>
Custom header arrangement

You can reorder the controls and place the CalendarNav in the middle with the two arrows - CalendarPrev and CalendarNext - to the sides.

const calendarHeader = () => {
    return <React.Fragment>
            <CalendarPrev className="custom-prev" />
            <CalendarNav className="custom-nav" />
            <CalendarNext className="custom-next" />
    </React.Fragment>;
}
<Datepicker
    controls={['calendar']}
    renderCalendarHeader={calendarHeader}
/>
Add a today button

You can also add a custom component, like a CalendarToday button.

const calendarHeader = () => {
    return <React.Fragment>
        <CalendarNav />
        <div className="custom-buttons">
            <CalendarPrev />
            <CalendarToday />
            <CalendarNext />
        </div>
    </React.Fragment>;
}
<Datepicker
    controls={['calendar']}
    renderCalendarHeader={calendarHeader}
/>
Switch between week and month view

Use a segmented component for creating a view switcher.

const [calendarType, setCalendarType] = React.useState('week');
const calendarHeader = () => {
    return <React.Fragment>
        <CalendarNav className="custom-view-nav" />
        <div className="custom-view">
            <SegmentedGroup value={view} onChange={changeView}>
                <SegmentedItem value="week" icon="material-date-range" />
                <SegmentedItem value="month" icon="material-event-note" />
            </SegmentedGroup>             
        </div>
        <CalendarPrev />
        <CalendarNext />
    </React.Fragment>;
}
const changeView = (event) => {
    setCalendarType(event.target.value);
}
<Datepicker
    controls={['calendar']}
    calendarType={calendarType}
    calendarSize={2}
    renderCalendarHeader={calendarHeader}
/>
Preview the selection

Above all that you can give instructions or show the selected {value} in the header

<Datepicker
    controls={['calendar']}
    calendarType="week"
    calendarSize={2}
    headerText="You selected {value}"
/>

Duplicate Session

You have signed in on a different machine. To keep everything in sync, you have been signed out of this session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.

Duplicate Session

We noticed you are logged in on a different machine and have closed your old session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.