Customizable Day Headers

You can use agendaDay slot to set up a custom day header template. This provides flexibility to format and style the date according to your preferences, allowing further customization of the headers and ensuring a consistent layout that matches your page's overall design.

In this demo, setting the showEmptyDays property to true allows us to add functionalities to the day header, such as creating new events for empty days, which is useful in various situations.

Get started with this example

Demo

Loading the live demo

Preview in full screen

Build customizable agenda day headers — add per-day action buttons, including headers for days without events or any custom actions.

Code

<script setup>
import {
  formatDate,
  getJson,
  MbscButton,
  MbscEventcalendar,
  MbscToast,
  setOptions 
} from '@mobiscroll/vue'
import { onMounted, ref } from 'vue'

setOptions({
  locale:  ,
  theme: ' ',
  themeVariant: ' '
})

const myEvents = ref([])
const myView = { agenda: { type: 'month', showEmptyDays: true } }
const isToastOpen = ref(false)

function addEvent(date) {
  const newEvent = {
    title: 'Event',
    start: date
  }

  myEvents.value = [...myEvents.value, newEvent]
  isToastOpen.value = true
}

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

<template>
  <MbscEventcalendar cssClass="mds-custom-day-header" :data="myEvents" :view="myView">
    <template #agendaDay="day">
      <div class="mbsc-flex mbsc-flex-1-1 mbsc-align-items-center">
        <div class="mbsc-flex-1-1">
          <div>{{ formatDate('D MMM YYYY', day.date) }}</div>
        </div>
        <MbscButton
          className="mds-custom-day-header-btn"
          color="primary"
          startIcon="plus"
          variant="outline"
          @click="addEvent(day.date)"
          >Add event</MbscButton
        >
      </div>
    </template>
  </MbscEventcalendar>
  <MbscToast message="Event added" :isOpen="isToastOpen" @close="isToastOpen = false" />
</template>

<style>
.mds-custom-day-header .mbsc-event-day.mbsc-windows {
  padding: 8px 24px;
}

.mds-custom-day-header-btn.mbsc-button {
  height: 24px;
  line-height: 24px;
  margin: 0;
  padding: 0 10px;
}

.mds-custom-day-header-btn .mbsc-button-txt {
  font-size: 12px;
}

.mds-custom-day-header-btn .mbsc-button-icon {
  width: 16px;
  height: 16px;
  line-height: 16px;
  font-size: 14px;
}
</style>

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.