---
title: "Vue Scheduler Switch Between Calendar and Scheduler Views Example | Mobiscroll"
component: "Scheduler"
framework: "Vue"
library_version: "6.1.5"
url: "https://demo.mobiscroll.com/vue/scheduler/switching-calendar-scheduler-agenda"
---

# Switch Between Calendar and Scheduler Views - Vue Scheduler demo

Let users switch between month, week, day, and agenda views within a single Vue event calendar — via header control or programmatically. For Vue and Nuxt.

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

## Description

Dynamically switch views within one instance. Use a UI control to let users do the switching or do it programmatically.

The example features a month view with events as labels, a weekly schedule view, a daily schedule and a weekly agenda. Use property binding and when the value of the property changes the settings propagate.

## What this demo shows

- A desktop event calendar with a header segmented control for switching between year, month, week, day, and agenda views.
- **Header and segmented control** A segemnted control with `Year`, `Month`, `Week`, `Day` and `Agenda` options is positioned in the center of the header, between the year navigation label (quick navigation picker) on the left and the blue prev/next arrows with a `Today` button on the right.
- **Month view** The demo opens with the `Month` option selected and displays a desktop month view with event labels.
- **Event labels** Days with events show labels directly inside the month cells, with different colors and styles for all-day, multi-day, and timed events.
- **Overflow handling** When a day cell cannot show all events, additional events are collapsed into an `X more` label. Clicking the label opens a popover with the remaining events for that day.
- **Label interaction** Hovering or clicking an event label selects it and highlights the selected label.
- **Day cell states** Hovering an empty day cell highlights the day number with a gray background. Clicking the empty part of a cell selects the day and highlights the day number with a blue background.
- **Year view** Selecting `Year` shows all twelve months of the current year in a single scrollable layout.
- **Year view events** Days with events show a small label below the date. When multiple events are scheduled, an `X more` label opens a popover above the day cell with the events for that date.
- **Week view** Selecting `Week` shows a desktop weekly scheduler layout with a fixed week strip, a fixed all-day row, and a scrollable time grid for the selected week.
- **Week strip** The strip below the header shows the days of the selected week, with the current date highlighted by a blue circle.
- **Week events** Timed events appear in the scheduler grid as colored cards with a left color stripe, bold event title, and exact start and end time above the title.
- **Current time** A blue current-time line appears across the week time grid, with a small blue dot marking the current date.
- **Time indicator** Hovering over the week time grid shows a time indicator that follows the cursor in 15-minute increments.
- **Day view** Selecting `Day` shows a desktop daily scheduler layout with a fixed week strip, a fixed all-day row, and a scrollable time grid for the selected day.
- **Day navigation** The week strip shows surrounding dates for quick day switching. Dates highlight on hover, and the selected day is marked with a blue circle.
- **Day events** Timed events appear in the daily scheduler grid as colored cards with a left color stripe, bold event title, and exact start and end time above the title.
- **Day current time** A blue current-time line appears across the daily time grid.
- **Day time indicator** Hovering over the daily time grid shows a time indicator that follows the cursor in 15-minute increments.
- **Agenda view** Selecting `Agenda` shows a week calendar at the top and a daily agenda list below it.
- **Agenda selection** The agenda list displays events for the selected date. Selecting a different date in the week calendar updates the agenda automatically.
- **Agenda event markers** Days with events display a small marker below the day in the week calendar.
- **Event creation** Double-clicking or clicking and dragging in the event calendar or scheduler creates a new event.

## Best for

- **Multi-level schedule browsing** Apps where users need to move between year, month, week, day, and agenda views without leaving the same calendar instance.
- **Operational planning** Workflows that need both a broad overview of upcoming activity and detailed time-grid planning for a selected week or day.
- **Daily event review** Interfaces where users need to select a date and review that day's events in an agenda list.
- **Dense calendars** Schedules where month and year views need to handle days with more events than can fit visibly in the cell.
- **Interactive scheduling** Use cases where users create events directly from the calendar or scheduler grid.

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

## Code

### SFC JS

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

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

const myEvents = ref([])
const view = ref('month')
const myView = ref({
  calendar: {
    labels: true
  }
})

function changeView() {
  let calView

  switch (view.value) {
    case 'year':
      calView = {
        calendar: { type: 'year' }
      }
      break
    case 'month':
      calView = {
        calendar: { labels: true }
      }
      break
    case 'week':
      calView = {
        scheduler: { type: 'week' }
      }
      break
    case 'day':
      calView = {
        scheduler: { type: 'day' }
      }
      break
    case 'agenda':
      calView = {
        calendar: { type: 'week' },
        agenda: { type: 'week' }
      }
      break
  }

  myView.value = calView
}

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

<template>
  <MbscEventcalendar
    className="md-switching-view-cont"
    :view="myView"
    :data="myEvents"
    :height="750"
  >
    <template #header>
      <MbscCalendarNav className="cal-header-nav" />
      <div className="cal-header-picker">
        <MbscSegmentedGroup v-model="view" @change="changeView">
          <MbscSegmented value="year"> Year </MbscSegmented>
          <MbscSegmented value="month"> Month </MbscSegmented>
          <MbscSegmented value="week"> Week </MbscSegmented>
          <MbscSegmented value="day"> Day </MbscSegmented>
          <MbscSegmented value="agenda"> Agenda </MbscSegmented>
        </MbscSegmentedGroup>
      </div>
      <MbscCalendarPrev className="cal-header-prev" />
      <MbscCalendarToday className="cal-header-today" />
      <MbscCalendarNext className="cal-header-next" />
    </template>
  </MbscEventcalendar>
</template>

<style>
.md-switching-view-cont .mbsc-segmented {
  max-width: 350px;
  margin: 0 auto;
}

.md-switching-view-cont .mbsc-calendar-grid-item {
  height: 490px;
  box-sizing: border-box;
}

.cal-header-picker {
  flex: 1 0 auto;
}

.cal-header-nav {
  width: 200px;
}

/* material header order */

.mbsc-material.cal-header-prev {
  order: 1;
}

.mbsc-material.cal-header-next {
  order: 2;
}

.mbsc-material.cal-header-nav {
  order: 3;
}

.mbsc-material .cal-header-picker {
  order: 4;
}

.mbsc-material .cal-header-today {
  order: 5;
}

/* windows header order */

.mbsc-windows.cal-header-nav {
  order: 1;
}

.mbsc-windows.cal-header-prev {
  order: 2;
}

.mbsc-windows.cal-header-next {
  order: 3;
}

.mbsc-windows .cal-header-picker {
  order: 4;
}

.mbsc-windows .cal-header-today {
  order: 5;
}
</style>
```

### SFC TS

```vue
<script setup lang="ts">
import {
  getJson,
  MbscCalendarNav,
  MbscCalendarNext,
  MbscCalendarPrev,
  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 view = ref<string>('month')
const myView = ref<MbscEventcalendarView>({
  calendar: {
    labels: true
  }
})

function changeView() {
  let calView: MbscEventcalendarView

  switch (view.value) {
    case 'year':
      calView = {
        calendar: { type: 'year' }
      }
      break
    case 'week':
      calView = {
        scheduler: { type: 'week' }
      }
      break
    case 'day':
      calView = {
        scheduler: { type: 'day' }
      }
      break
    case 'agenda':
      calView = {
        calendar: { type: 'week' },
        agenda: { type: 'week' }
      }
      break
    default:
      calView = {
        calendar: { labels: true }
      }
      break
  }

  myView.value = calView
}

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

<template>
  <MbscEventcalendar
    className="md-switching-view-cont"
    :view="myView"
    :data="myEvents"
    :height="750"
  >
    <template #header>
      <MbscCalendarNav className="cal-header-nav" />
      <div className="cal-header-picker">
        <MbscSegmentedGroup v-model="view" @change="changeView">
          <MbscSegmented value="year"> Year </MbscSegmented>
          <MbscSegmented value="month"> Month </MbscSegmented>
          <MbscSegmented value="week"> Week </MbscSegmented>
          <MbscSegmented value="day"> Day </MbscSegmented>
          <MbscSegmented value="agenda"> Agenda </MbscSegmented>
        </MbscSegmentedGroup>
      </div>
      <MbscCalendarPrev className="cal-header-prev" />
      <MbscCalendarToday className="cal-header-today" />
      <MbscCalendarNext className="cal-header-next" />
    </template>
  </MbscEventcalendar>
</template>

<style>
.md-switching-view-cont .mbsc-segmented {
  max-width: 350px;
  margin: 0 auto;
}

.md-switching-view-cont .mbsc-calendar-grid-item {
  height: 490px;
  box-sizing: border-box;
}

.cal-header-picker {
  flex: 1 0 auto;
}

.cal-header-nav {
  width: 200px;
}

/* material header order */

.mbsc-material.cal-header-prev {
  order: 1;
}

.mbsc-material.cal-header-next {
  order: 2;
}

.mbsc-material.cal-header-nav {
  order: 3;
}

.mbsc-material .cal-header-picker {
  order: 4;
}

.mbsc-material .cal-header-today {
  order: 5;
}

/* windows header order */

.mbsc-windows.cal-header-nav {
  order: 1;
}

.mbsc-windows.cal-header-prev {
  order: 2;
}

.mbsc-windows.cal-header-next {
  order: 3;
}

.mbsc-windows .cal-header-picker {
  order: 4;
}

.mbsc-windows .cal-header-today {
  order: 5;
}
</style>
```

## Implementation notes

- Define five view configurations to switch between:
  - **Year**: `{ calendar: { type: 'year' } }`
  - **Month**: `{ calendar: { labels: true } }` (initial view)
  - **Week**: `{ scheduler: { type: 'week' } }`
  - **Day**: `{ scheduler: { type: 'day' } }`
  - **Agenda**: `{ calendar: { type: 'week' }, agenda: { type: 'week' } }`
- Use `renderHeader` (Angular: `headerTemplate`, Vue: `#header` slot) to render a `SegmentedGroup` in the custom header with one option per view. On selection, update the active view; for the imperative API, call `inst.setOptions({ view: newViewConfig })`.
- Load events from `https://trial.mobiscroll.com/events/?vers=5` via JSONP using `getJson(url, callback, 'jsonp')`. 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: [Color-Coded Time Blocks](https://demo.mobiscroll.com/vue/scheduler/colored-cell-background.md) - Highlight recurring time blocks in a Vue Scheduler — mark lunch breaks, working hours, or special dates, date range, or recurring schedule.
- Next: [Visible hours and days](https://demo.mobiscroll.com/vue/scheduler/show-hide-hours-days.md) - Keep your calendar focused. Trim your view. In Vue, you can show only weekdays and business hours, making schedules cleaner and faster.
