---
title: "React Scheduler Custom Header Example | Mobiscroll"
component: "Scheduler"
framework: "React"
library_version: "6.1.5"
url: "https://demo.mobiscroll.com/react/scheduler/customizing-header"
---

# Custom Header - React Scheduler demo

Arrange navigation controls and add a scheduler/calendar view-switcher in a custom React Scheduler header. For React and Next.JS.

- [Live demo](https://demo.mobiscroll.com/react/scheduler/customizing-header)
- [View React JS code on GitHub](https://github.com/acidb/mobiscroll-demos-react/tree/main/src/demos/eventcalendar/scheduler/customizing-header)
- [View React TS code on GitHub](https://github.com/acidb/mobiscroll-demos-react-ts/tree/main/src/demos/eventcalendar/scheduler/customizing-header)
- This demo in other frameworks: [JavaScript](https://demo.mobiscroll.com/javascript/scheduler/customizing-header.md), [jQuery](https://demo.mobiscroll.com/jquery/scheduler/customizing-header.md), [Angular](https://demo.mobiscroll.com/angular/scheduler/customizing-header.md), [Vue](https://demo.mobiscroll.com/vue/scheduler/customizing-header.md)

## Description

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

Use the [`renderHeader`](https://mobiscroll.com/docs/react/eventcalendar/api#renderer-renderHeader) 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 />`. Use the `.md-header-filter-controls` CSS class for custom overrides.
- **Today button** - `<CalendarToday />`. Use the `.md-header-filter-today` CSS class for custom overrides.
- **Previous month button** - `<CalendarPrev />`. Use the `.md-header-filter-prev` CSS class for custom overrides.
- **Next month button** - `<CalendarNext />`. Use the `.md-header-filter-next` CSS class for custom overrides.

For changing the order the controls are laid out, you only need to set up the `renderHeader`. This example sets a consistent order and layout across all themes and shows a custom control at the far right end.

### Overriding the order for specific themes

For a custom order on a theme to theme basis, you will need to use a little CSS. [Flex layout](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) makes reordering easy. It's just a matter of setting the order in CSS. For material use the `.mbsc-material`, for windows the `.mbsc-windows` prefix and for iOS it is `.mbsc-ios` class. Eg.:

```css
.mbsc-material .md-header-filter-prev { order: 1; }
            .mbsc-material .md-header-filter-next { order: 2; }
            .mbsc-material .md-header-filter-controls { order: 3; }
            .mbsc-material .md-header-filter-today { order: 4; }
```

**Want to add a filter to the header?** [Check out the next example →](https://demo.mobiscroll.com/react/eventcalendar/resource-filtering-in-header)

## What this demo shows

- A desktop weekly scheduler layout with a custom header and a view switcher that toggles between calendar and scheduler-style layouts.
- **Header** The left side shows the currently displayed month and year. The center contains previous and next month navigation arrows with a blue `Today` button between them for jumping back to the current date. The right side contains a segmented control with a list icon selected by default and a calendar icon for switching views.
- **Week view** The fixed strip below the header displays the days of the selected week, with the current date highlighted by a blue circle.
- **All-day events** All-day events appear in a dedicated row that stays fixed above the time grid.
- **Time grid** The scheduler grid scrolls vertically through the hours of the selected week.
- **Timed events** Timed events are displayed in the weekly scheduler grid as colored cards with a colored stripe on the left, the event title in bold, and the exact start and end time displayed above the title.
- **Event overlapping** If events overlap, the scheduler places them side by side without hiding any of them or causing other conflicts.
- **Current time** A blue current-time line appears across the time grid, with a small blue dot marking the current date.
- **Hover behavior** Hovering over the time grid shows a time indicator that follows the cursor in 15-minute increments.
- **Event interaction** Hovering over events highlights them and shows drag and resize handles for repositioning or changing duration.
- **Event selection** Clicking an event selects and highlights it.
- **Event creation** Double-clicking the time grid or clicking and dragging on it creates a new event.
- **Event calendar view** Selecting the calendar option from the segmented control switches the layout to a monthly calendar view.
- **Event labels** Days with events display labels directly inside the month cells. Labels use different styles and colors to distinguish all-day events, multi-day, and timed events.
- **Overflow handling** The number of visible event labels depends on the available vertical space in the day cell. Additional events are moved into a popover and indicated by an `X more` label, where `X` represents the number of hidden events. Clicking it opens a popover that lists the remaining events for that day.
- **Label interaction** Hovering over or clicking an event label selects it and highlights the selected label. This is tru in both views, event calendar month view and the scheduler week view.
- **Day cell states** Hovering a day cell highlights the day number with a gray background, while clicking the empty part of the cell selects the day and highlights the day number with a blue background.
- **Month navigation** The month can be changed by clicking and dragging the calendar left or right.

## Best for

- **Calendar and schedule switching** Interfaces where users need to move between a month overview and a more detailed weekly schedule from the same header control.
- **Desktop planning tools** Scheduling and planning screens designed for desktop use, where a full month grid and richer header controls fit naturally.
- **Operational scheduling** Team, resource, booking, or internal planning tools where users switch between high-level monthly planning and time-precise weekly scheduling.

## API used in this demo

- [`theme`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-theme) - option
- [`themeVariant`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-themeVariant) - option
- [`labels`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-labels) - option
- [`clickToCreate`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-clickToCreate) - option
- [`dragToCreate`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-dragToCreate) - option
- [`dragToMove`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-dragToMove) - option
- [`dragToResize`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-dragToResize) - option
- [`eventDelete`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-eventDelete) - option
- [`onSelectedDateChange`](https://mobiscroll.com/docs/react/eventcalendar/api#event-onSelectedDateChange) - event
- [`selectedDate`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-selectedDate) - option
- [`renderHeader`](https://mobiscroll.com/docs/react/eventcalendar/api#renderer-renderHeader) - renderer
- [`view`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-view) - option
- [`data`](https://mobiscroll.com/docs/react/eventcalendar/api#opt-data) - option

## Code

### JSX

```jsx
import {
  Button,
  CalendarNav,
  CalendarToday,
  Eventcalendar,
  getJson,
  Segmented,
  SegmentedGroup,
  setOptions,
} from '@mobiscroll/react';
import { useCallback, useEffect, useState } from 'react';

setOptions({
  theme: 'ios',
  themeVariant: 'light'
});

function App() {
  const [view, setView] = useState('schedule');
  const [myEvents, setEvents] = useState([]);
  const [currentDate, setCurrentDate] = useState(new Date());
  const [calView, setCalView] = useState({
    scheduler: {
      type: 'week',
    },
  });

  const changeView = useCallback(
    (event) => {
      let calendarView;
      switch (event.target.value) {
        case 'calendar':
          calendarView = {
            calendar: {
              labels: true,
            },
          };
          break;
        case 'schedule':
          calendarView = {
            scheduler: {
              type: 'week',
            },
          };
          break;
      }
      setView(event.target.value);
      setCalView(calendarView);
    },
    [setView, setCalView],
  );

  const handleSelectedDateChange = useCallback(
    (event) => {
      setCurrentDate(event.date);
    },
    [setCurrentDate],
  );

  const getFirstDayOfWeek = useCallback((d, prev) => {
    const day = d.getDay();
    const diff = d.getDate() - day + (prev ? -7 : 7);
    return new Date(d.setDate(diff));
  }, []);

  const navigatePage = useCallback(
    (prev) => {
      if (view == 'calendar') {
        const prevNextPage = new Date(currentDate.getFullYear(), currentDate.getMonth() + (prev ? -1 : 1), 1);
        setCurrentDate(prevNextPage);
      } else {
        const prevNextSunday = getFirstDayOfWeek(currentDate, prev);
        setCurrentDate(prevNextSunday);
      }
    },
    [view, currentDate, setCurrentDate, getFirstDayOfWeek],
  );

  const customWithNavButtons = useCallback(
    () => (
      <>
        <CalendarNav className="md-custom-header-nav" />
        <div className="md-custom-header-controls">
          <Button onClick={() => navigatePage(true)} icon="material-arrow-back" variant="flat" className="md-custom-header-button"></Button>
          <CalendarToday className="md-custom-header-today" />
          <Button
            onClick={() => navigatePage(false)}
            icon="material-arrow-forward"
            variant="flat"
            className="md-custom-header-button"
          ></Button>
        </div>
        <div className="md-custom-header-view">
          <SegmentedGroup value={view} onChange={changeView}>
            <Segmented value="schedule" icon="material-list" />
            <Segmented value="calendar" icon="calendar" />
          </SegmentedGroup>
        </div>
      </>
    ),
    [changeView, navigatePage, view],
  );

  useEffect(() => {
    getJson(
      'https://trial.mobiscroll.com/events/?vers=5',
      (events) => {
        setEvents(events);
      },
      'jsonp',
    );
  }, []);

  return (
    <Eventcalendar
      className="md-custom-header"
      clickToCreate={true}
      dragToCreate={true}
      dragToMove={true}
      dragToResize={true}
      eventDelete={true}
      onSelectedDateChange={handleSelectedDateChange}
      selectedDate={currentDate}
      renderHeader={customWithNavButtons}
      view={calView}
      data={myEvents}
    />
  );
}

export default App;
```

### TSX

```tsx
import {
  Button,
  CalendarNav,
  CalendarToday,
  Eventcalendar,
  getJson,
  MbscCalendarEvent,
  MbscEventcalendarView,
  MbscSelectedDateChangeEvent,
  SegmentedGroup,
  SegmentedItem,
  setOptions,
} from '@mobiscroll/react';
import { ChangeEvent, FC, useCallback, useEffect, useState } from 'react';

setOptions({
  theme: 'ios',
  themeVariant: 'light'
});

const App: FC = () => {
  const [view, setView] = useState<string>('schedule');
  const [myEvents, setEvents] = useState<MbscCalendarEvent[]>([]);
  const [currentDate, setCurrentDate] = useState<Date>(new Date());
  const [calView, setCalView] = useState<MbscEventcalendarView>({
    scheduler: {
      type: 'week',
    },
  });

  const changeView = useCallback((event: ChangeEvent<HTMLInputElement>) => {
    let calendarView = {};
    switch (event.target.value) {
      case 'calendar':
        calendarView = {
          calendar: {
            labels: true,
          },
        };
        break;
      case 'schedule':
        calendarView = {
          scheduler: {
            type: 'week',
          },
        };
        break;
    }

    setView(event.target.value);
    setCalView(calendarView);
  }, []);

  const handleSelectedDateChange = useCallback(
    (event: MbscSelectedDateChangeEvent) => {
      setCurrentDate(new Date(event.date as string));
    },
    [setCurrentDate],
  );

  const getFirstDayOfWeek = useCallback((d: Date, prev: boolean) => {
    const day = d.getDay();
    const diff = d.getDate() - day + (prev ? -7 : 7);
    return new Date(d.setDate(diff));
  }, []);

  const navigatePage = useCallback(
    (prev: boolean) => {
      if (view === 'calendar') {
        const prevNextPage = new Date(currentDate.getFullYear(), currentDate.getMonth() + (prev ? -1 : 1), 1);
        setCurrentDate(prevNextPage);
      } else {
        const prevNextSunday = getFirstDayOfWeek(currentDate, prev);
        setCurrentDate(prevNextSunday);
      }
    },
    [view, currentDate, setCurrentDate, getFirstDayOfWeek],
  );

  const customWithNavButtons = useCallback(
    () => (
      <>
        <CalendarNav className="md-custom-header-nav" />
        <div className="md-custom-header-controls">
          <Button onClick={() => navigatePage(true)} icon="material-arrow-back" variant="flat" className="md-custom-header-button"></Button>
          <CalendarToday className="md-custom-header-today" />
          <Button
            onClick={() => navigatePage(false)}
            icon="material-arrow-forward"
            variant="flat"
            className="md-custom-header-button"
          ></Button>
        </div>
        <div className="md-custom-header-view">
          <SegmentedGroup value={view} onChange={changeView}>
            <SegmentedItem value="calendar" icon="calendar" />
            <SegmentedItem value="schedule" icon="material-list" />
          </SegmentedGroup>
        </div>
      </>
    ),
    [changeView, navigatePage, view],
  );

  useEffect(() => {
    getJson(
      'https://trial.mobiscroll.com/events/?vers=5',
      (events: MbscCalendarEvent[]) => {
        setEvents(events);
      },
      'jsonp',
    );
  }, []);

  return (
    <Eventcalendar
      className="md-custom-header"
      onSelectedDateChange={handleSelectedDateChange}
      selectedDate={currentDate}
      renderHeader={customWithNavButtons}
      view={calView}
      data={myEvents}
    />
  );
};
export default App;
```

### CSS

```css
.md-custom-header-controls {
  display: flex;
  flex: 1 0 auto;
  justify-content: center;
  align-items: center;
}

.md-custom-header-nav,
.md-custom-header-view {
  width: 180px;
}

.md-custom-header-button.mbsc-button {
  font-size: 20px;
  height: auto;
  padding: 0;
  margin: 0;
}

.md-custom-header .mbsc-segmented {
  width: 110px;
  float: right;
  margin-top: 0;
  margin-bottom: 0;
}

.md-custom-header .mbsc-material.mbsc-segmented,
.md-custom-header .mbsc-windows.mbsc-segmented {
  padding: 0;
}

.md-custom-header .mbsc-segmented .mbsc-segmented-button {
  font-size: 20px;
  height: 32px;
  padding: 0;
}
```

## Implementation notes

- Start with `view: { scheduler: { type: 'week' } }`. Load events via `getJson` from a JSONP endpoint on mount.
- Track the current date via `onSelectedDateChange` so the custom navigation buttons know where the view is.
- Pass a custom header renderer to `renderHeader` (Angular: `headerTemplate`, Vue: `#header` slot). The header contains three sections:
  - **Left**: `CalendarNav` - displays the current period label.
  - **Center**: back arrow `Button`, `CalendarToday`, forward arrow `Button`.
  - **Right**: `SegmentedGroup` with two `Segmented` options - schedule (list icon) and calendar (calendar icon).
- **View switching**: on `SegmentedGroup` change, update the active view config between `{ scheduler: { type: 'week' } }` and `{ calendar: { labels: true } }`; for the imperative API, call `inst.setOptions({ view: newViewConfig })`.
- **Custom navigation**: the prev/next arrow buttons call a `navigatePage(prev)` function. In calendar view, jump to the first day of the prev/next month; in scheduler view, compute the first day of the prev/next week. Update `selectedDate` to the new date; for the imperative API, call `inst.navigate(date)`.

## Run it in your project

1. If not signed up yet, or don't own a license, you can [start a free trial](https://mobiscroll.com/starttrial).

2. Clone the repository:

   ```
   git clone https://github.com/acidb/mobiscroll-demos-react.git
   ```

3. If not installed yet, install the Mobiscroll CLI from NPM:

   ```
   npm install -g @mobiscroll/cli
   ```

4. Config Mobiscroll - open a terminal window in the root directory and run:

   ```
   mobiscroll config react
   ```

5. Install dependencies - open a terminal window in the root directory and run:

   ```
   npm install
   ```

6. Run the project:

   ```
   npm run dev
   ```

On a trial, add `--trial` to the config command: `mobiscroll config react --trial`.

Running a demo locally requires a Mobiscroll trial or a license; setup is per framework at https://mobiscroll.com/docs/react/getting-started/installation

## Related demos

- Previous: [Cell Content Template](https://demo.mobiscroll.com/react/scheduler/cell-content-template.md) - Add custom content to React Scheduler cells — show icons, badges, colored backgrounds, or status markers based on date, resource, and event data.
