---
title: "Vue Event calendar Custom Header Example | Mobiscroll"
component: "Event calendar"
framework: "Vue"
library_version: "6.2.0"
url: "https://demo.mobiscroll.com/vue/eventcalendar/customizing-header"
---

# Custom Header - Vue Event calendar demo

Customize the Vue event calendar header — rearrange navigation controls, toggle calendar/scheduler views or add any custom action. For Vue and Nuxt.

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

## Description

You can customize how the header of the event 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 calendar and scheduler.

Use the [`header`](https://mobiscroll.com/docs/vue/eventcalendar/api#slot-header) template for passing a custom header layout. There are predefined components - shorthands if you will - that can be used to assemble the header:

- **Navigation component** - `<MbscCalendarNav />`. Use the `.md-header-filter-controls` CSS class for custom overrides.
- **Today button** - `<MbscCalendarToday />`. Use the `.md-header-filter-today` CSS class for custom overrides.
- **Previous month button** - `<MbscCalendarPrev />`. Use the `.md-header-filter-prev` CSS class for custom overrides.
- **Next month button** - `<MbscCalendarNext />`. 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 `header` template. 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.:

```
.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/vue/eventcalendar/resource-filtering-in-header)

## What this demo shows

- A desktop month-view event calendar is shown 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 calendar icon selected by default and a list icon for switching views.
- **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.
- **Scheduler view** Selecting the list option from the segmented control switches the layout to a weekly scheduler view.
- **Scheduler view** The weekly scheduler shows the days of the week at the top, an all-day section for all-day events, and a 24-hour time grid for timed events.
- **Scheduler view** The current time is marked with a blue line in the time grid.
- **Scheduler view** The time grid can be scrolled vertically with the mouse wheel while the header stays sticky.

## 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/vue/eventcalendar/api#opt-theme) - option
- [`themeVariant`](https://mobiscroll.com/docs/vue/eventcalendar/api#opt-themeVariant) - option
- [`labels`](https://mobiscroll.com/docs/vue/eventcalendar/api#opt-labels) - option
- [`data`](https://mobiscroll.com/docs/vue/eventcalendar/api#opt-data) - option
- [`view`](https://mobiscroll.com/docs/vue/eventcalendar/api#opt-view) - option
- [`selectedDate`](https://mobiscroll.com/docs/vue/eventcalendar/api#opt-selectedDate) - option

## Code

### SFC JS

```vue
<script setup>
import {
  getJson,
  MbscButton,
  MbscCalendarNav,
  MbscCalendarToday,
  MbscEventcalendar,
  MbscSegmented,
  MbscSegmentedGroup,
  setOptions
} from '@mobiscroll/vue'
import { onMounted, ref } from 'vue'

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

const myEvents = ref([])
const currentDate = ref(new Date())
const view = ref('calendar')
const calView = ref({
  calendar: { labels: true }
})

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

function navigatePage(prev) {
  const newCurrentDate = currentDate.value
  if (view.value === 'calendar') {
    const prevNextPage = new Date(
      newCurrentDate.getFullYear(),
      newCurrentDate.getMonth() + (prev ? -1 : 1),
      1
    )
    currentDate.value = prevNextPage
  } else {
    const prevNextSunday = getFirstDayOfWeek(newCurrentDate, prev)
    currentDate.value = prevNextSunday
  }
}

function changeView() {
  switch (view.value) {
    case 'calendar':
      calView.value = {
        calendar: { labels: true }
      }
      break
    case 'schedule':
      calView.value = {
        scheduler: { type: 'week' }
      }
      break
  }
}

onMounted(() => {
  getJson(
    'https://trial.mobiscroll.com/events/?vers=5',
    (events) => {
      myEvents.value = events
    },
    'jsonp'
  )
})
</script>

<template>
  <MbscEventcalendar
    :data="myEvents"
    :view="calView"
    :selectedDate="currentDate"
    className="md-custom-header"
  >
    <template #header>
      <MbscCalendarNav className="md-custom-header-nav"></MbscCalendarNav>
      <div class="md-custom-header-controls">
        <MbscButton
          @click="navigatePage(true)"
          icon="material-arrow-back"
          variant="flat"
          className="md-custom-header-button"
        ></MbscButton>
        <MbscCalendarToday className="md-custom-header-today"></MbscCalendarToday>
        <MbscButton
          @click="navigatePage(false)"
          icon="material-arrow-forward"
          variant="flat"
          className="md-custom-header-button"
        ></MbscButton>
      </div>
      <div class="md-custom-header-view">
        <MbscSegmentedGroup v-model="view" @change="changeView()">
          <MbscSegmented value="calendar" v-model="view" icon="calendar"></MbscSegmented>
          <MbscSegmented value="schedule" v-model="view" icon="material-list"></MbscSegmented>
        </MbscSegmentedGroup>
      </div>
    </template>
  </MbscEventcalendar>
</template>

<style>
.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;
}
</style>
```

### SFC TS

```vue
<script setup lang="ts">
import {
  getJson,
  MbscButton,
  MbscCalendarNav,
  MbscCalendarToday,
  MbscEventcalendar,
  MbscSegmented,
  MbscSegmentedGroup,
  setOptions
} from '@mobiscroll/vue'
import type { MbscCalendarEvent, MbscEventcalendarView } from '@mobiscroll/vue'
import { onMounted, ref } from 'vue'

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

const myEvents = ref<MbscCalendarEvent[]>([])
const currentDate = ref<any>(new Date())
const view = ref<string>('calendar')
const calView = ref<MbscEventcalendarView>({
  calendar: { labels: true }
})

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

function navigatePage(prev: boolean) {
  const newCurrentDate = currentDate.value
  if (view.value === 'calendar') {
    const prevNextPage = new Date(
      newCurrentDate.getFullYear(),
      newCurrentDate.getMonth() + (prev ? -1 : 1),
      1
    )
    currentDate.value = prevNextPage
  } else {
    const prevNextSunday = getFirstDayOfWeek(newCurrentDate, prev)
    currentDate.value = prevNextSunday
  }
}

function changeView() {
  switch (view.value) {
    case 'calendar':
      calView.value = {
        calendar: { labels: true }
      }
      break
    case 'schedule':
      calView.value = {
        scheduler: { type: 'week' }
      }
      break
  }
}

onMounted(() => {
  getJson(
    'https://trial.mobiscroll.com/events/?vers=5',
    (events: MbscCalendarEvent[]) => {
      myEvents.value = events
    },
    'jsonp'
  )
})
</script>

<template>
  <MbscEventcalendar
    :data="myEvents"
    :view="calView"
    :selectedDate="currentDate"
    className="md-custom-header"
  >
    <template #header>
      <MbscCalendarNav className="md-custom-header-nav"></MbscCalendarNav>
      <div class="md-custom-header-controls">
        <MbscButton
          @click="navigatePage(true)"
          icon="material-arrow-back"
          variant="flat"
          className="md-custom-header-button"
        ></MbscButton>
        <MbscCalendarToday className="md-custom-header-today"></MbscCalendarToday>
        <MbscButton
          @click="navigatePage(false)"
          icon="material-arrow-forward"
          variant="flat"
          className="md-custom-header-button"
        ></MbscButton>
      </div>
      <div class="md-custom-header-view">
        <MbscSegmentedGroup v-model="view" @change="changeView()">
          <MbscSegmented value="calendar" v-model="view" icon="calendar"></MbscSegmented>
          <MbscSegmented value="schedule" v-model="view" icon="material-list"></MbscSegmented>
        </MbscSegmentedGroup>
      </div>
    </template>
  </MbscEventcalendar>
</template>

<style>
.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;
}
</style>
```

## Implementation notes

- Define two view configs toggled by a state variable: calendar uses `{ calendar: { labels: true } }`; schedule uses `{ scheduler: { type: 'week' } }`.
- Use `renderHeader` (Angular: `headerTemplate`, Vue: `header` slot) to build a fully custom header with three zones:
  - Left: `CalendarNav` for the month/year title
  - Center: two flat icon `Button` components (`material-arrow-back` and `material-arrow-forward`) flanking `CalendarToday` - these replace the built-in `CalendarPrev`/`CalendarNext`
  - Right: an icon-only `SegmentedGroup` with a `calendar` icon and a `material-list` icon for switching between views
- Track the currently displayed date in a `selectedDate` state variable, kept in sync via `onSelectedDateChange`. The custom prev/next buttons call a `navigatePage()` helper that computes the target date based on the active view: in calendar view, it adds or subtracts one month; in schedule view, it adds or subtracts one week. Update `selectedDate` with the result to drive navigation. JS/jQuery: call `inst.navigate(date)` instead of updating a bound prop.
- Load events from a remote endpoint using `getJson` and assign them to `data`; for the imperative API, call `inst.setEvents(events)` in the callback.

## 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-vue.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 vue
   ```

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 vue --trial`.

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

## Related demos

- Previous: [Event Popover](https://demo.mobiscroll.com/vue/eventcalendar/customize-event-popover.md) - Customize how events appear in the day popover of a Vue event calendar — use full custom layouts or add fields like assignee, location, and participants.
- Next: [Custom Event Tooltip](https://demo.mobiscroll.com/vue/eventcalendar/custom-event-tooltip.md) - Add custom hover tooltips to a Vue event calendar — show appointment details, status, location, and confirm or delete actions to each event.
