Vue Simple Calendar
Vue Simple Calendar is a flexible, themeable, and lightweight calendar component designed for Vue 3 applications. It focuses on displaying a traditional month-grid calendar, capable of showing scheduled activities, including multi-day items. The current stable version is 7.2.2. The project appears to have a consistent, active release cadence with several 7.x.x releases in recent times, indicating ongoing maintenance and development. Key differentiators include its small footprint with no external dependencies (like Moment.js or jQuery), a flexbox-based layout, and extensive customization options via Vue slots and CSS. It explicitly avoids complex features like an 'agenda' view, built-in AJAX, or item management interfaces, positioning itself as a display-centric component rather than a date picker or full-featured scheduling system. It also offers date range selection and supports various user events like clicks and drags.
Common errors
-
[Vue warn]: Failed to resolve component: Calendar
cause The `Calendar` component was not correctly imported and registered in your Vue application or a specific component's `components` option, preventing Vue from rendering it.fixEnsure you have `import { Calendar } from 'vue-simple-calendar'` in your script setup or `<script>` block, and if not using `<script setup>`, ensure `Calendar` is listed in your component's `components: { Calendar }` option or globally registered with `app.component('Calendar', Calendar)`. -
ReferenceError: require is not defined
cause This error occurs when attempting to use the CommonJS `require()` syntax to import `vue-simple-calendar` within a modern Vue 3 project, which typically utilizes ES Modules (ESM).fixUpdate your module import statements to use the ES Module syntax: `import { Calendar } from 'vue-simple-calendar'`. -
TypeError: Invalid prop: type check failed for prop "items". Expected Array, got Object
cause The `items` prop, which expects an array of calendar item objects, was provided with a JavaScript object instead.fixEnsure that the `items` prop is always bound to a JavaScript array, where each element conforms to the `ICalendarItem` interface or a compatible object structure.
Warnings
- breaking Version 6.0 introduced significant breaking changes, migrating the component to Vue 3 and Vite, and explicitly dropping support for Internet Explorer 11. Users on Vue 2 or those requiring IE11 compatibility must remain on `vue-simple-calendar@5`, which is no longer actively maintained.
- gotcha The library developer notes difficulties in configuring Vite to both emit TypeScript declaration files (`.d.ts`) during the build and maintain Hot Module Replacement (HMR) for development. This could lead to an inconsistent TypeScript experience or missing type definitions in specific development environments.
- gotcha Vue Simple Calendar is primarily designed for desktop web applications. While it may function on mobile devices, its utility might be limited due to screen resolution constraints. Crucially, drag-and-drop features are exclusively supported on desktop browsers and do not function on touch devices.
Install
-
npm install vue-simple-calendar -
yarn add vue-simple-calendar -
pnpm add vue-simple-calendar
Imports
- Calendar
const Calendar = require('vue-simple-calendar')import { Calendar } from 'vue-simple-calendar' - ICalendarItem
import { ICalendarItem } from 'vue-simple-calendar'import type { ICalendarItem } from 'vue-simple-calendar' - CalendarView
import CalendarView from 'vue-simple-calendar'
import { CalendarView } from 'vue-simple-calendar'
Quickstart
<!-- src/App.vue -->
<template>
<div id="app">
<h1>My Event Calendar</h1>
<div style="width: 80%; margin: 0 auto;">
<Calendar
:showDate="currentDate"
:items="calendarItems"
:startingDayOfWeek="1"
@clickDate="onClickDate"
@clickItem="onClickItem"
/>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue';
import { Calendar, type ICalendarItem } from 'vue-simple-calendar';
import 'vue-simple-calendar/dist/style.css';
import 'vue-simple-calendar/dist/css/default.css'; // Or your custom theme CSS
const currentDate = ref(new Date());
const calendarItems: ICalendarItem[] = reactive([
{ id: '1', startDate: new Date(2026, 3, 10), endDate: new Date(2026, 3, 12), title: 'Multi-day Event', class: 'custom-event-class' },
{ id: '2', startDate: new Date(2026, 3, 15, 9, 0), endDate: new Date(2026, 3, 15, 10, 30), title: 'Meeting (9:00 AM)' },
{ id: '3', startDate: new Date(2026, 3, 20), title: 'Project Deadline' },
{ id: '4', startDate: new Date(2026, 3, 25), endDate: new Date(2026, 4, 1), title: 'Week-long Project', class: 'long-project' }
]);
function onClickDate(date: Date) {
console.log('Clicked date:', date.toLocaleDateString());
}
function onClickItem(item: ICalendarItem) {
console.log('Clicked item:', item.title, 'on', item.startDate.toLocaleDateString());
}
</script>
<style>
/* Basic styling, replace with your custom theme */
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
/* Custom classes for calendar items */
.custom-event-class {
background-color: #a7f3d0;
color: #065f46;
border-radius: 4px;
padding: 2px 4px;
}
.long-project {
background-color: #bfdbfe;
color: #1e40af;
border-radius: 4px;
padding: 2px 4px;
opacity: 0.9;
}
</style>