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

# Custom Header - Vue Agenda demo

Build a custom header for the Vue event calendar agenda — assemble navigation controls, add a segmented view switcher or any custom action. For Vue and Nuxt.

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

## Description

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

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.:

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

## What this demo shows

- Shows a monthly agenda view with events listed and grouped by date.
- **Header navigation** The month and year label in the top left opens date navigation. 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.
- **Agenda list** The area below the header lists events for the selected month. Events in the agenda are grouped by date.
- **Sticky day headers** As the agenda scrolls vertically, each day stays visible with a sticky date header while its events appear underneath.
- **Events:** Events appear as agenda cards with a colored strip on the left and the event title next to it. Start and end times are stacked on the right side of timed events. All-day events show the all-day label on the right.
- **Event interaction** Hovering an event highlights it.
- **Event selection** Clicking an event selects and highlights it.
- **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 agenda switching** Interfaces where users need to move between a month overview for agenda and event calendar 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.

## 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
- [`data`](https://mobiscroll.com/docs/vue/eventcalendar/api#opt-data) - option
- [`selectedDate`](https://mobiscroll.com/docs/vue/eventcalendar/api#opt-selectedDate) - option
- [`view`](https://mobiscroll.com/docs/vue/eventcalendar/api#opt-view) - option
- [`cssClass`](https://mobiscroll.com/docs/vue/forms/button#opt-cssClass) - 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 currentDate = ref(new Date())
const currentView = ref('agenda')
const myEvents = ref([])
const myView = ref({ agenda: { type: 'month' } })

function changeView() {
  switch (currentView.value) {
    case 'calendar':
      myView.value = {
        calendar: { type: 'month' }
      }
      break
    case 'agenda':
      myView.value = {
        agenda: { type: 'month' }
      }
      break
  }
}

function prevPage() {
  currentDate.value = new Date(currentDate.value.getFullYear(), currentDate.value.getMonth() - 1, 1)
}

function nextPage() {
  currentDate.value = new Date(currentDate.value.getFullYear(), currentDate.value.getMonth() + 1, 1)
}

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

<template>
  <MbscEventcalendar :data="myEvents" :selectedDate="currentDate" :view="myView">
    <template #header>
      <MbscCalendarNav className="mds-custom-header-nav"></MbscCalendarNav>
      <div class="mbsc-flex mbsc-flex-1-0 mbsc-justify-content-center">
        <MbscButton
          cssClass="mds-custom-header-button"
          icon="material-arrow-back"
          variant="flat"
          @click="prevPage()"
        />
        <MbscCalendarToday />
        <MbscButton
          cssClass="mds-custom-header-button"
          icon="material-arrow-forward"
          variant="flat"
          @click="nextPage()"
        />
      </div>
      <div class="mds-custom-header-switch">
        <MbscSegmentedGroup v-model="currentView" @change="changeView()">
          <MbscSegmented value="agenda" icon="material-view-day" />
          <MbscSegmented value="calendar" icon="calendar" />
        </MbscSegmentedGroup>
      </div>
    </template>
  </MbscEventcalendar>
</template>

<style>
.mds-custom-header-nav {
  width: 180px;
}

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

.mds-custom-header-switch .mbsc-segmented {
  width: 110px;
  margin-top: 0;
  margin-bottom: 0;
}

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

.mds-custom-header-switch .mbsc-segmented-button.mbsc-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 currentDate = ref<Date>(new Date())
const currentView = ref<string>('agenda')
const myEvents = ref<MbscCalendarEvent[]>([])
const myView = ref<MbscEventcalendarView>({ agenda: { type: 'month' } })

function changeView() {
  switch (currentView.value) {
    case 'calendar':
      myView.value = {
        calendar: { type: 'month' }
      }
      break
    case 'agenda':
      myView.value = {
        agenda: { type: 'month' }
      }
      break
  }
}

function prevPage() {
  currentDate.value = new Date(currentDate.value.getFullYear(), currentDate.value.getMonth() - 1, 1)
}

function nextPage() {
  currentDate.value = new Date(currentDate.value.getFullYear(), currentDate.value.getMonth() + 1, 1)
}

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

<template>
  <MbscEventcalendar :data="myEvents" :selectedDate="currentDate" :view="myView">
    <template #header>
      <MbscCalendarNav className="mds-custom-header-nav"></MbscCalendarNav>
      <div class="mbsc-flex mbsc-flex-1-0 mbsc-justify-content-center">
        <MbscButton
          cssClass="mds-custom-header-button"
          icon="material-arrow-back"
          variant="flat"
          @click="prevPage()"
        />
        <MbscCalendarToday />
        <MbscButton
          cssClass="mds-custom-header-button"
          icon="material-arrow-forward"
          variant="flat"
          @click="nextPage()"
        />
      </div>
      <div class="mds-custom-header-switch">
        <MbscSegmentedGroup v-model="currentView" @change="changeView()">
          <MbscSegmented value="agenda" icon="material-view-day" />
          <MbscSegmented value="calendar" icon="calendar" />
        </MbscSegmentedGroup>
      </div>
    </template>
  </MbscEventcalendar>
</template>

<style>
.mds-custom-header-nav {
  width: 180px;
}

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

.mds-custom-header-switch .mbsc-segmented {
  width: 110px;
  margin-top: 0;
  margin-bottom: 0;
}

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

.mds-custom-header-switch .mbsc-segmented-button.mbsc-button {
  font-size: 20px;
  height: 32px;
  padding: 0;
}
</style>
```

## Implementation notes

- Use `renderHeader` (React/JS/jQuery) / `headerTemplate` (Angular) / `header` slot (Vue) to replace the default header. Assemble it from the built-in nav components: `CalendarNav` (navigation label), `CalendarToday` (today button), and custom prev/next `Button`s that shift `currentDate` by ±1 month. Place a `SegmentedGroup` at the far right with "agenda" and "calendar" segments to switch views.
- Keep `selectedDate` and `onSelectedDateChange` wired so that the custom prev/next buttons and the nav label stay in sync. On segment change, swap `view` between `{ agenda: { type: 'month' } }` and `{ calendar: { type: 'month' } }`.
- Load events from `https://trial.mobiscroll.com/events/?vers=5` via JSONP using `getJson(url, callback, 'jsonp')`. Angular: use `HttpClient.jsonp()` instead. JS/jQuery: 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: [Full Event Customization](https://demo.mobiscroll.com/vue/agenda/full-event-customization.md) - Fully customize Vue agenda event card layout — show images, location, participants, and custom fields in each event row.
- Next: [Customizable Day Headers](https://demo.mobiscroll.com/vue/agenda/customizing-day-header.md) - Build customizable Vue agenda day headers — add per-day action buttons, including headers for days without events or any custom actions.
