vkurko/calendar
À propos
Calendrier d’événements JavaScript pleine taille avec glisser-déposer, vues des ressources et vue chronologique.
Productivité et automatisationProgression mesurée des étoiles
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- +5
- in 1 month
- +8
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
OriginalEventCalendar

Full-sized drag & drop JavaScript event calendar with resource & timeline views:
- Lightweight (39kb br compressed)
- Minimal DOM structure (thanks to CSS Grid)
- Zero-dependency (standalone bundle)
- Used on over 70,000 websites with Bookly
Inspired by FullCalendar, it implements similar options.
Featured sponsors
:heavy_plus_sign: Get on the list |
Table of contents
Usage
JavaScript module
The first step is to install the EventCalendar core package:
npm install --save-dev @event-calendar/core
This package provides functions for creating and destroying the calendar, as well as plugins for various views. You must use at least one plugin that provides a view. The following plugins are currently available:
DayGridListResourceTimelineResourceTimeGridTimeGridInteraction(doesn't provide a view)
Then, in your JavaScript module:
import {createCalendar, destroyCalendar, TimeGrid} from '@event-calendar/core';
// Import CSS if your build tool supports it
import '@event-calendar/core/index.css';
let ec = createCalendar(
// HTML element the calendar will be mounted to
document.getElementById('ec'),
// Array of plugins
[TimeGrid],
// Options object
{
view: 'timeGridWeek',
events: [
// your list of events
]
}
);
// If you later need to destroy the calendar then use
destroyCalendar(ec);
Svelte 5 component
The first step is to install the EventCalendar core package:
npm install --save-dev @event-calendar/core
This package provides the Calendar component, as well as plugins for various views. You must use at least one plugin that provides a view. The following plugins are currently available:
DayGridListResourceTimelineResourceTimeGridTimeGridInteraction(doesn't provide a view)
Then in your Svelte 5 component, use the calendar like this:
<script>
import {Calendar, TimeGrid} from '@event-calendar/core';
let options = $state({
view: 'timeGridWeek',
events: [
// your list of events
]
});
</script>
<Calendar plugins={[TimeGrid]} {options} />
The calendar is destroyed gracefully when the component containing it is destroyed.
Content snippets
The options that define content can also be given as Svelte snippets:
- allDayContent
- dayCellContent
- eventContent
- moreLinkContent
- noEventsContent
- resourceLabelContent
- weekNumberContent
A snippet is passed to the Calendar component under the name of the option it defines:
<Calendar plugins={[DayGrid]} {options}>
{#snippet eventContent({event, timeText})}
<b>{timeText}</b> {event.title}
{/snippet}
</Calendar>
It can also be passed as a property, which is convenient when the snippet is declared elsewhere:
<Calendar plugins={[DayGrid]} {options} eventContent={myEventContent}/>
A snippet receives the same argument as the function form of the option and is rendered in the same place.
The content property of customButtons is also supported, but since custom buttons have arbitrary names, such a snippet is named customButton followed by the name of the button with the first letter capitalized. The button itself does not have to be listed in the customButtons option:
<Calendar plugins={[ResourceTimeline]} options={{headerToolbar: {end: 'myFilter'}}}>
{#snippet customButtonMyFilter()}
<input bind:value={query}>
{/snippet}
</Calendar>
Unlike a function, a snippet is rendered by Svelte itself. It can contain components, event handlers and transitions, and it is updated reactively when the state it uses changes.
If both a snippet and an option with the same name are given, the snippet takes precedence.
React component
The first step is to install the EventCalendar react package:
npm install --save-dev @event-calendar/react
This package provides the EventCalendar component, as well as plugins for various views. You must use at least one plugin that provides a view. The following plugins are currently available:
DayGridListResourceTimelineResourceTimeGridTimeGridInteraction(doesn't provide a view)
Then in your React component, use the calendar like this:
import {useState} from 'react';
import {EventCalendar, TimeGrid} from '@event-calendar/react';
import '@event-calendar/react/index.css';
const plugins = [TimeGrid];
export default function App() {
const [events, setEvents] = useState([
// your list of events
]);
return (
<EventCalendar
plugins={plugins}
view="timeGridWeek"
events={events}
eventClick={({event}) => console.log(event.id)}
/>
);
}
All options are passed as props, and the calendar is updated when they change. Objects, arrays and callbacks can be written right in JSX, there is no need for useMemo and useCallback. The className, style and id props are set on the element that wraps the calendar.
The calendar is destroyed gracefully when the component containing it is destroyed.
Rendering content with React
The following options accept JSX or a function that returns JSX:
- allDayContent
- dayCellContent
- eventContent
- moreLinkContent
- noEventsContent
- resourceLabelContent
- weekNumberContent
- the
contentproperty of customButtons
<EventCalendar
plugins={plugins}
eventContent={({event, timeText}) => <EventBody event={event} time={timeText}/>}
noEventsContent={<i>No events</i>}
headerToolbar={{start: 'title', center: '', end: 'filter today prev,next'}}
customButtons={{filter: {content: <input value={query} onChange={e => setQuery(e.target.value)}/>}}}
/>
The argument of the function is described in the documentation of each option. If the function returns null or undefined, the default content is shown.
Calling methods in React
The methods of the calendar are available through the ref:
const calendar = useRef(null);
<EventCalendar ref={calendar} plugins={plugins}/>
<button onClick={() => calendar.current.next()}>Next</button>
Vue component
The first step is to install the EventCalendar vue package:
npm install --save-dev @event-calendar/vue
This package provides the EventCalendar component, as well as plugins for various views. You must use at least one plugin that provides a view. The following plugins are currently available:
DayGridListResourceTimelineResourceTimeGridTimeGridInteraction(doesn't provide a view)
Then in your Vue component, use the calendar like this:
<script setup>
import {ref} from 'vue';
import {EventCalendar, TimeGrid} from '@event-calendar/vue';
import '@event-calendar/vue/index.css';
const plugins = [TimeGrid];
const events = ref([
// your list of events
]);
</script>
<template>
<EventCalendar
:plugins="plugins"
view="timeGridWeek"
:events="events"
@event-click="({event}) => console.log(event.id)"
/>
</template>
All options are passed as props, and the calendar is updated when they change, including the changes inside reactive objects and arrays, such as events.value.push(event). The callbacks can also be used as event listeners. The class, style and id attributes are set on the element that wraps the calendar.
The calendar is destroyed gracefully when the component containing it is destroyed.
Rendering content with slots
The following options can be given as slots:
- allDayContent
- dayCellContent
- eventContent
- moreLinkContent
- noEventsContent
- resourceLabelContent
- weekNumberContent
- the
contentproperty of customButtons: the slot is namedcustomButtonfollowed by the name of the button with the first letter capitalized
<EventCalendar :plugins="plugins" :header-toolbar="{start: 'title', center: '', end: 'filter today prev,next'}">
<template #eventContent="{event, timeText}">
<EventBody :event="event" :time="timeText"/>
</template>
<template #customButtonFilter>
<input v-model="query">
</template>
</EventCalendar>
The slot props are described in the documentation of each option, as the argument of its function.
Calling methods in Vue
The methods of the calendar are available through the template ref:
<script setup>
import {useTemplateRef} from 'vue';
const calendar = useTemplateRef('calendar');
</script>
<template>
<EventCalendar ref="calendar" :plugins="plugins"/>
<button @click="calendar.next()">Next</button>
</template>
Angular component
The first step is to install the EventCalendar angular package:
npm install --save-dev @event-calendar/angular
This package provides the EventCalendar component and the EcContent directive, as well as plugins for various views. You must use at least one plugin that provides a view. The following plugins are currently available:
DayGridListResourceTimelineResourceTimeGridTimeGridInteraction(doesn't provide a view)
Then in your Angular component, use the calendar like this:
import {Component, signal} from '@angular/core';
import {EventCalendar, EcContent, TimeGrid, type Calendar} from '@event-calendar/angular';
@Component({
selector: 'app-root',
imports: [EventCalendar, EcContent],
template: `<event-calendar [plugins]="plugins" [options]="options()"/>`
})
export class App {
plugins = [TimeGrid];
options = signal<Calendar.Options>({
view: 'timeGridWeek',
events: [
// your list of events
]
});
}
And import the styles in the global stylesheet of your application:
@import '@event-calendar/angular/index.css';
All options are passed as one object. To change them, pass a new object: the calendar is updated with the options that are different in it.
The calendar is destroyed gracefully when the component containing it is destroyed.
Rendering content with templates
The following options can be given as templates with the ecContent directive:
- allDayContent
- dayCellContent
- eventContent
- moreLinkContent
- noEventsContent
- resourceLabelContent
- weekNumberContent
- the
contentproperty of customButtons: the template is namedcustomButtonfollowed by the name of the button with the first letter capitalized
<event-calendar [plugins]="plugins" [options]="options()">
<ng-template ecContent="eventContent" let-event="event" let-timeText="timeText">
<app-event-body [event]="event" [time]="timeText"/>
</ng-template>
<ng-template ecContent="customButtonFilter">
<input [(ngModel)]="query">
</ng-template>
</event-calendar>
The variables of the template are described in the documentation of each option, as the argument of its function.
Calling methods in Angular
The methods of the calendar are the methods of the component:
<event-calendar #calendar [plugins]="plugins" [options]="options()"/>
<button (click)="calendar.next()">Next</button>
Standalone bundle
This bundle contains a version of the calendar that includes all plugins and is prepared for use in the browser via the <script> tag.
The first step is to include the following lines of code in the <head> section of your page:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/[email protected]/dist/event-calendar.min.css">
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/[email protected]/dist/event-calendar.min.js"></script>
Note
Please note that the file paths contain an indication of a specific version of the library. You can remove this indication, then the latest version will be loaded:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build/dist/event-calendar.min.css"> <script src="https://cdn.jsdelivr.net/npm/@event-calendar/build/dist/event-calendar.min.js"></script>But it is recommended to always specify the version and explicitly update it if necessary, in order to avoid unpredictable problems when a new version of the library is released.
Then initialize the calendar like this:
let ec = EventCalendar.create(document.getElementById('ec'), {
view: 'timeGridWeek',
events: [
// your list of events
]
});
// If you later need to destroy the calendar then use
EventCalendar.destroy(ec);
Modifying options after initialization
You can modify the calendar options after initialization using the setOption method, or the setOptions method to set several options at once.
ec.setOption('slotDuration', '01:00');
In Svelte, you can simply update the original options object.
<script>
import {Calendar, TimeGrid} from '@event-calendar/core';
let options = $state({
view: 'timeGridWeek'
});
function updateOptions() {
options.slotDuration = '01:00';
}
</script>
<button onclick={updateOptions}>Change slot duration</button>
<Calendar plugins={[TimeGrid]} {options} />
Options
allDayContent
- Type
Contentorfunction - Default
'all-day'
The title of the all-day row.
The value is a Content, or a function that returns it:
let options = {
allDayContent: ({text}) => ({html: `<i>${text}</i>`})
};
The function receives an object with the following properties:
|
The default text |
In Svelte, React, Vue and Angular this content can be rendered by the framework itself: with a snippet, JSX, a slot or a template.
allDaySlot
- Type
boolean - Default
true
Shows the all-day row at the top of the timeGrid and resourceTimeGrid views.
let options = {
allDaySlot: false
};
Without the row there is no place for all-day events in these views, so they are not shown.
buttonText
- Type
objectorfunction
-
Default
{collapse: 'Collapse', close: 'Close', dayGridDay: 'day', dayGridMonth: 'month', dayGridWeek: 'week', expand: 'Expand', listDay: 'day', listMonth: 'month', listWeek: 'week', listYear: 'year', resourceTimeGridDay: 'day', resourceTimeGridWeek: 'week', resourceTimelineDay: 'day', resourceTimelineMonth: 'month', resourceTimelineWeek: 'week', resourceTimelineYear: 'year', timeGridDay: 'day', timeGridWeek: 'week', today: 'today'}Views override the default value as follows:
- dayGridDay
text => ({...text, next: 'Next day', prev: 'Previous day'}) - dayGridMonth
text => ({...text, next: 'Next month', prev: 'Previous month'}) - dayGridWeek
text => ({...text, next: 'Next week', prev: 'Previous week'}) - listDay
text => ({...text, next: 'Next day', prev: 'Previous day'}) - listMonth
text => ({...text, next: 'Next month', prev: 'Previous month'}) - listWeek
text => ({...text, next: 'Next week', prev: 'Previous week'}) - listYear
text => ({...text, next: 'Next year', prev: 'Previous year'}) - resourceTimeGridDay
text => ({...text, next: 'Next day', prev: 'Previous day'}) - resourceTimeGridWeek
text => ({...text, next: 'Next week', prev: 'Previous week'}) - resourceTimelineDay
text => ({...text, next: 'Next day', prev: 'Previous day'}) - resourceTimelineMonth
text => ({...text, next: 'Next month', prev: 'Previous month'}) - resourceTimelineWeek
text => ({...text, next: 'Next week', prev: 'Previous week'}) - resourceTimelineYear
text => ({...text, next: 'Next year', prev: 'Previous year'}) - timeGridDay
text => ({...text, next: 'Next day', prev: 'Previous day'}) - timeGridWeek
text => ({...text, next: 'Next week', prev: 'Previous week'})
- dayGridDay
The texts of the buttons of the calendar. For the buttons without a text — prev and next in the toolbar, close in the popup, expand and collapse at the nested resources — these are the labels for screen readers and the tooltips.
The value is an object with the texts, or a function that receives the default texts and returns the new ones. A function is the way to change some texts and keep the others:
let options = {
buttonText: text => ({...text, today: 'This week', dayGridMonth: 'Month'})
};
An object replaces the default texts completely, so it has to contain every text the calendar needs.
columnWidth
- Type
string - Default
undefined
The width of the day columns in the timeGrid and resourceTimeGrid views, and in the resourceTimeline views whose slots are days, such as resourceTimelineMonth.
By default the columns share the width of the calendar. With this option each column gets the given width, and the calendar is scrolled horizontally when the columns do not fit.
The value is a CSS length, so include the unit:
let options = {
columnWidth: '150px'
};
customButtons
- Type
objectorfunction - Default
{}
Your own buttons and other items for the headerToolbar.
Define the items under any names, then put the names into headerToolbar:
let options = {
customButtons: {
myCustomButton: {
text: 'custom!',
click: function() {
alert('clicked the custom button!');
}
}
},
headerToolbar: {
start: 'title myCustomButton',
center: '',
end: 'today prev,next'
}
};
An item accepts the following properties:
|
The text to be displayed on the button itself. See Content |
|
A callback function that is called when the button is clicked. Accepts one argument mouseEvent |
|
If |
|
Arbitrary content displayed in place of the button. See Content This value can be either a Content or a function that returns content:
|
An item with content is rendered as a <div> instead of a <button>, so it can hold any widget, such as an input or a select. It needs neither text nor click, and if both content and text are given, content is used.
let input = document.createElement('input');
let options = {
customButtons: {
myFilter: {
content: {domNodes: [input]}
}
},
headerToolbar: {
start: 'prev,next today',
center: 'title',
end: 'myFilter'
}
};
In Svelte, React, Vue and Angular this content can be rendered by the framework itself: with a snippet, JSX, a slot or a template.
The option can also be a function that receives the default items and returns the new ones:
let options = {
customButtons: buttons => ({...buttons, myCustomButton: {text: 'custom!', click: () => alert('clicked!')}})
};
customScrollbars
- Type
boolean - Default
false
Styles the scrollbars of the calendar, which also keeps them always visible in the browsers that support it.
It is useful on macOS, where the scrollbars are hidden until you scroll: in a resourceTimeline view nothing would tell the user that the calendar can be scrolled horizontally.
let options = {
customScrollbars: true
};
date
- Type
Date,stringorundefined - Default
undefined
The date the calendar shows. The view displays the period that contains this date: its week, its month and so on.
The value is a JavaScript Date object or an ISO8601 date string. Without a value it is today in the calendar's timeZone.
let options = {
date: '2026-12-31'
};
The option follows the navigation, so getOption('date') returns the date that is shown at the moment.
dateClick
- Type
function - Default
undefined - Requires
Interactionplugin
Called when the user clicks a day or a time slot.
let options = {
dateClick: ({date, allDay, resource}) => {
console.log(date, allDay, resource?.title);
}
};
The function receives an object with the following properties:
|
JavaScript Date object for the clicked date and time |
|
ISO8601 string representation of the date |
|
|
|
HTML element that represents the whole-day that was clicked on |
|
JavaScript native event object with low-level information such as click coordinates |
|
The current View object |
|
If the current view is a resource view, the Resource object that owns this date |
dateIncrement
- Type
string,integerorobject - Default
undefined
How far the calendar moves when the prev and next buttons are clicked, or the prev() and next() methods are called. By default it moves by the whole view, that is by its duration.
The value is anything that can be parsed into a Duration object.
let options = {
view: 'timeGridWeek',
// Show a week, but move two weeks at a time
dateIncrement: {weeks: 2}
};
datesAboveResources
- Type
boolean - Default
false
Puts the days above the resources in the resourceTimeGrid views: the columns are grouped by day, and each day holds a column per resource.
By default it is the other way around: the columns are grouped by resource, and each resource holds its days.
let options = {
view: 'resourceTimeGridWeek',
datesAboveResources: true
};
datesSet
- Type
function - Default
undefined
Called when the period the calendar shows is set or changed: when the calendar is created and each time it moves to other dates, by navigation or by switching to a view of another period.
let options = {
datesSet: ({start, end, view}) => {
console.log(view.type, start, end);
}
};
The function receives an object with the following properties:
|
JavaScript Date object for the beginning of the range the calendar needs events for |
|
JavaScript Date object for the end of the range the calendar needs events for. Note: This value is exclusive |
|
ISO8601 string representation of the start date |
|
ISO8601 string representation of the end date |
|
The current View object |
dayCellContent
- Type
Contentorfunction - Default
undefined
The content of the day cells. In the dayGrid views it replaces the number of the day and in the list views the name of the day. In the other views the cells have no content by default.
The value is a Content, or a function that returns it:
let options = {
dayCellContent: ({date, isToday}) => ({html: isToday ? '<b>Today</b>' : String(date.getDate())})
};
The function receives an object with the following properties:
|
|
|
JavaScript Date object corresponding to the day |
|
|
|
If the current view is a resource view, the Resource object that owns this cell |
In Svelte, React, Vue and Angular this content can be rendered by the framework itself: with a snippet, JSX, a slot or a template.
dayCellFormat
- Type
objectorfunction - Default
{day: 'numeric'}
The format of the day number in the cells of the dayGrid views.
The value is an object with the options of the native JavaScript Intl.DateTimeFormat object, or a function that returns the formatted Content.
let options = {
dayCellFormat: {day: '2-digit'}
// or as a function
// dayCellFormat: date => String(date.getDate())
};
The function receives the JavaScript Date object to format.
dayHeaderAriaLabelFormat
- Type
objectorfunction - Default
{dateStyle: 'full'}
Views override the default value as follows:
- dayGridMonth
{weekday: 'long'}
The format of the aria-label attribute of the column headings, which is what screen readers announce instead of the short visible text.
The value is an object with the options of the native JavaScript Intl.DateTimeFormat object, or a function that returns the formatted string.
let options = {
dayHeaderAriaLabelFormat: {weekday: 'long', month: 'long', day: 'numeric'}
// or as a function
// dayHeaderAriaLabelFormat: date => date.toDateString()
};
The function receives the JavaScript Date object to format.
dayHeaderFormat
- Type
objectorfunction - Default
{weekday: 'short', month: 'numeric', day: 'numeric'}
Views override the default value as follows:
- dayGridDay
{weekday: 'long'}- dayGridMonth
{weekday: 'short'}- resourceTimeGridDay
{weekday: 'long'}- resourceTimelineDay
{weekday: 'long'}- resourceTimelineMonth
{weekday: 'short', day: 'numeric'}- resourceTimelineYear
{weekday: 'short', day: 'numeric'}- timeGridDay
{weekday: 'long'}
The format of the column headings.
The value is an object with the options of the native JavaScript Intl.DateTimeFormat object, or a function that returns the formatted Content.
let options = {
dayHeaderFormat: {weekday: 'long'}
// or as a function
// dayHeaderFormat: date => date.toDateString()
};
The function receives the JavaScript Date object to format.
dayMaxEvents
- Type
boolean - Default
false
Limits the events of a day in the dayGrid views to those that fit into the height of the day cell. The rest are collected under a link like +2 more, which opens them in a popup.
It needs the calendar to have a height: without one, as well as without this option, the rows of the grid grow to show all the events.
let options = {
view: 'dayGridMonth',
height: '600px',
dayMaxEvents: true
};
Only true is supported: the limit is set by the height of the cell, not by a number.
dayPopoverFormat
- Type
objectorfunction - Default
{month: 'long', day: 'numeric', year: 'numeric'}
The format of the date in the title of the popup that the +more link opens, see dayMaxEvents.
The value is an object with the options of the native JavaScript Intl.DateTimeFormat object, or a function that returns the formatted Content.
let options = {
dayPopoverFormat: {weekday: 'long', month: 'long', day: 'numeric'}
// or as a function
// dayPopoverFormat: date => date.toDateString()
};
The function receives the JavaScript Date object to format.
displayEventEnd
- Type
boolean - Default
true
Views override the default value as follows:
- dayGridDay
false- dayGridMonth
false- dayGridWeek
false- resourceTimelineDay
false- resourceTimelineMonth
false- resourceTimelineWeek
false- resourceTimelineYear
false
Shows the end time of an event next to its start time: 10:00 - 11:30 instead of 10:00.
let options = {
displayEventEnd: false
};
dragConstraint
- Type
function - Default
undefined - Requires
Interactionplugin
Limits where an event can be dragged.
The function is called on every move of the pointer while an event is dragged. It receives the same argument as eventDrop, with the event as it would be at the new position, and returns false to forbid dropping the event there.
let options = {
// No events on the weekend
dragConstraint: ({event}) => ![0, 6].includes(event.start.getDay())
};
While the position is not allowed, the event stays at the last allowed position and the cursor changes to not-allowed. Releasing the pointer there cancels the dragging.
dragScroll
- Type
boolean - Default
true - Requires
Interactionplugin
Scrolls the calendar when an event is dragged to its edge, so that the event can be moved to a time that is not visible.
let options = {
dragScroll: false
};
duration
- Type
string,integerorobject - Default
{weeks: 1}
Views override the default value as follows:
- dayGridDay
{days: 1}- dayGridMonth
{months: 1}- listDay
{days: 1}- listMonth
{months: 1}- listYear
{years: 1}- resourceTimeGridDay
{days: 1}- resourceTimelineDay
{days: 1}- resourceTimelineMonth
{months: 1}- resourceTimelineYear
{years: 1}- timeGridDay
{days: 1}
The period of time a view shows.
The value is anything that can be parsed into a Duration object.
let options = {
view: 'timeGridWeek',
// Four days instead of a week
duration: {days: 4}
};
Usually it is set for a view of your own in the views option.
editable
- Type
boolean - Default
false - Requires
Interactionplugin
Lets the user drag and resize the events, where the more specific options do not decide it.
Dragging is controlled by eventStartEditable and resizing by eventDurationEditable. Both are true by default, so with the Interaction plugin the events can be dragged and resized even while editable is false. This option is used for the action whose own option is set to null:
let options = {
// Both dragging and resizing are decided by `editable`
eventStartEditable: null,
eventDurationEditable: null,
editable: true
};
For each event the first value that is set is taken, in this order: the startEditable (or durationEditable) property of the event, the eventStartEditable (or eventDurationEditable) option, the editable property of the event, and this option.
events
- Type
array - Default
[]
The events of the calendar: an array of plain objects that are parsed into Event objects.
let options = {
events: [
{id: 1, title: 'Meeting', start: '2026-12-01 10:00', end: '2026-12-01 11:30'},
{id: 2, title: 'Conference', start: '2026-12-02', end: '2026-12-04', allDay: true}
]
};
To load the events from a server, use eventSources instead. If eventSources is given, this option is not used.
eventAllUpdated
- Type
function - Default
undefined
Called when the calendar has finished rendering the events after they change: when they are loaded, added, changed or removed, and when the view is switched.
let options = {
eventAllUpdated: ({view}) => {
console.log('The events are rendered in', view.type);
}
};
The function receives an object with the following properties:
|
The current View object |
This is an experimental feature, and its behavior may change in the future.
eventBackgroundColor
- Type
string - Default
undefined
The default background color of the events.
The value is any CSS color, such as '#f00', 'rgb(255,0,0)' or 'red':
let options = {
eventBackgroundColor: '#0ea5e9'
};
The color of a resource and the color of the event itself take precedence over this option.
eventClassNames
- Type
string,arrayorfunction - Default
undefined
Additional CSS classes for the elements of the events.
The value is a string with the class names, an array of them, or a function that returns either:
let options = {
eventClassNames: ({event}) => event.extendedProps.urgent ? ['urgent', 'bold'] : 'regular'
};
The function receives an object with the following properties:
|
The associated Event object |
|
The current View object |
eventClick
- Type
function - Default
undefined
Called when the user clicks an event, or presses Enter or Space on a focused one.
let options = {
eventClick: ({event, el}) => {
console.log(event.id, el);
}
};
The function receives an object with the following properties:
|
The HTML element for the event |
|
The associated Event object |
|
JavaScript native event object with low-level information such as click coordinates |
|
The current View object |
With this option the events become buttons for the keyboard and screen readers: they can be focused and activated.
eventColor
- Type
string - Default
undefined
An alias for eventBackgroundColor. It is used when eventBackgroundColor is not set.
let options = {
eventColor: '#0ea5e9'
};
eventContent
- Type
Contentorfunction - Default
undefined
The content of an event, in place of the default time and title.
The value is a Content, or a function that returns it:
let options = {
eventContent: ({event, timeText}) => ({
html: `<div class="ec-event-time">${timeText}</div><div class="ec-event-title">★ ${event.title}</div>`
})
};
The function receives an object with the following properties:
|
The associated Event object |
|
Formatted time of the event |
|
The current View object |
If the function returns undefined, the event gets the default content, so the content can be changed for some events only.
The event itself does not clip its content: the default time and title are clipped by their own ec-event-time and ec-event-title classes. Use the same classes for your content, as in the example, so that it does not stick out of an event that is too small for it.
In Svelte, React, Vue and Angular this content can be rendered by the framework itself: with a snippet, JSX, a slot or a template.
eventDidMount
- Type
function - Default
undefined
Called right after the element of an event is added to the page. This is the place to attach something to the element: a tooltip, for example.
let options = {
eventDidMount: ({event, el}) => {
el.title = event.title;
}
};
The function receives an object with the following properties:
|
The HTML element for the event |
|
The associated Event object |
|
Formatted time of the event |
|
The current View object |
It is called once for each element. An element is created again, and the function is called again, when the event is replaced with updateEvent(), loaded again, or moved to another day or resource.
eventDragMinDistance
- Type
integer - Default
5 - Requires
Interactionplugin
How many pixels the pointer has to move before an event starts to be dragged. It keeps a click with a slightly moved mouse from being taken as dragging.
let options = {
eventDragMinDistance: 10
};
eventDragStart
- Type
function - Default
undefined - Requires
Interactionplugin
Called when the user starts dragging an event.
let options = {
eventDragStart: ({event}) => {
console.log('Dragging', event.title);
}
};
The function receives an object with the following properties:
|
The associated Event object |
|
JavaScript native event object with low-level information such as click coordinates |
|
The current View object |
eventDragStop
- Type
function - Default
undefined - Requires
Interactionplugin
Called when the user stops dragging an event, wherever it is released.
let options = {
eventDragStop: ({event}) => {
console.log('Released', event.title);
}
};
The function receives an object with the following properties:
|
The associated Event object |
|
JavaScript native event object with low-level information such as click coordinates |
|
The current View object |
At this moment the event is not changed yet. Unless the drop is refused, the event is changed after this call, and then eventDrop is called.
eventDrop
- Type
function - Default
undefined - Requires
Interactionplugin
Called when the user has dropped an event and the drop is accepted. The event is already changed at this moment. It is called even if the event is dropped where it was.
let options = {
eventDrop: async ({event, oldEvent, revert}) => {
let saved = await save(event.id, event.start, event.end);
if (!saved) {
// Put the event back
revert();
}
}
};
The function receives an object with the following properties:
|
The associated Event object |
|
An Event object that holds information about the event before the drop |
|
If the resource has changed, this is the Resource object the event came from. If the resource has not changed, this will be undefined |
|
If the resource has changed, this is the Resource object the event went to. If the resource has not changed, this will be undefined |
|
A Duration object that represents the amount of time the event was moved by |
|
A function that, if called, reverts the event’s start/end date to the values before the drag |
|
JavaScript native event object with low-level information such as click coordinates |
|
The current View object |
It is called after eventDragStop.
eventDurationEditable
- Type
boolean - Default
true - Requires
Interactionplugin
Lets the user resize the events. Set it to false to forbid resizing:
let options = {
eventDurationEditable: false
};
An event can override it with its own durationEditable property. With null, the editable option decides.
eventFilter
- Type
function - Default
undefined
Decides which events are shown, without changing the events themselves. The function is called for each event and returns true to show it:
let options = {
// Only the events of the selected category
eventFilter: ({event}) => event.extendedProps.category === 'work'
};
The function receives an object with the following properties:
|
The current Event object being processed in the array |
|
The index of the current event being processed in the array |
|
The array of all events |
|
The current View object |
The filter is applied again when the view changes, so the events can be different in each view.
eventGap
- Type
integer - Default
1
The vertical gap in pixels between the events that are stacked one under another: in the dayGrid views, in the all-day row of the timeGrid and resourceTimeGrid views, and in the resourceTimeline views.
let options = {
eventGap: 4
};
eventLongPressDelay
- Type
integer - Default
undefined - Requires
Interactionplugin
On touch devices, how many milliseconds the user has to hold a finger on an event before it can be dragged or resized. A shorter touch scrolls the calendar.
let options = {
eventLongPressDelay: 500
};
Without a value, longPressDelay is used.
eventMouseEnter
- Type
function - Default
undefined
Called when the mouse pointer enters an event.
let options = {
eventMouseEnter: ({event, el}) => {
showTooltip(el, event.title);
}
};
The function receives an object with the following properties:
|
The HTML element for the event |
|
The associated Event object |
|
JavaScript native event object with low-level information such as click coordinates |
|
The current View object |
eventMouseLeave
- Type
function - Default
undefined
Called when the mouse pointer leaves an event.
let options = {
eventMouseLeave: ({event, el}) => {
hideTooltip(el);
}
};
The function receives an object with the following properties:
|
The HTML element for the event |
|
The associated Event object |
|
JavaScript native event object with low-level information such as click coordinates |
|
The current View object |
eventOrder
- Type
function - Default
undefined
The order of the events that are shown at the same place: which one is higher in a day of the month view, or to the left in a time slot.
The value is a function that compares two Event objects, like the function of Array.sort(): it returns a negative number if the first event comes before the second, a positive one if it comes after, and zero if they are equal.
let options = {
// By title
eventOrder: (a, b) => a.title.localeCompare(b.title)
};
By default the events are ordered by their start time, and of the events that start at the same time the all-day ones come first.
eventOrderStrict
- Type
boolean - Default
false
Makes the resourceTimeline views keep the order of the events vertically, even if it takes more space.
By default the layout is compact: an event is placed into the topmost free line, so it can end up above an event that comes before it in the order, when there is free space above that one. With true, an event is never placed above another event that comes before it in eventOrder and overlaps it.
let options = {
eventOrderStrict: true
};
It is useful when a parent event has to stay above its children: order them so that the parent comes first, and enable this option.
The events that do not overlap are still laid out independently. To keep related events on the same line, give them the same layoutGroup.
eventResizableFromStart
- Type
boolean - Default
false - Requires
Interactionplugin
Lets the user resize an event from its start as well: by the top edge in the time grid, and by the left edge in the other views.
let options = {
editable: true,
eventResizableFromStart: true
};
eventResize
- Type
function - Default
undefined - Requires
Interactionplugin
Called when the user has finished resizing an event and the new size is accepted. The event is already changed at this moment.
let options = {
eventResize: async ({event, revert}) => {
let saved = await save(event.id, event.start, event.end);
if (!saved) {
// Put the event back
revert();
}
}
};
The function receives an object with the following properties:
|
The associated Event object |
|
An Event object that holds information about the event before the resize |
|
A Duration object that represents the amount of time the event’s start date was moved by |
|
A Duration object that represents the amount of time the event’s end date was moved by |
|
A function that, if called, reverts the event’s end date to the values before the resize |
|
JavaScript native event object with low-level information such as click coordinates |
|
The current View object |
It is called after eventResizeStop.
eventResizeStart
- Type
function - Default
undefined - Requires
Interactionplugin
Called when the user starts resizing an event.
let options = {
eventResizeStart: ({event}) => {
console.log('Resizing', event.title);
}
};
The function receives an object with the following properties:
|
The associated Event object |
|
JavaScript native event object with low-level information such as click coordinates |
|
The current View object |
eventResizeStop
- Type
function - Default
undefined - Requires
Interactionplugin
Called when the user stops resizing an event.
let options = {
eventResizeStop: ({event}) => {
console.log('Released', event.title);
}
};
The function receives an object with the following properties:
|
The associated Event object |
|
JavaScript native event object with low-level information such as click coordinates |
|
The current View object |
At this moment the event is not changed yet. Unless the new size is refused, the event is changed after this call, and then eventResize is called.
eventSources
- Type
EventSource[] - Default
[]
The sources the calendar loads its events from: URLs or functions. The events are requested for the period the calendar shows, and again when it moves outside of the loaded period, see lazyFetching.
let options = {
eventSources: [
// The calendar requests /events?start=...&end=...
{url: '/events'},
// Or loads them with your function
{events: async ({startStr, endStr}) => (await fetch(`/api/events?from=${startStr}&to=${endStr}`)).json()}
]
};
If this option is given, the events option is not used. The start and the end of the loading are reported to the loading callback.
A source is an object with one of the following sets of properties:
1. Fetch events from a URL
|
A URL from which the calendar will fetch an array of parsable Event objects in JSON format. HTTP requests with the following parameters will be sent to this URL whenever the calendar needs new event data:
|
||||||
|
HTTP request method. Default |
||||||
|
Other GET/POST data you want to send to the server. Can be a plain object or a function that returns an object. Default |
2. Execute custom function
|
A custom function that is executed whenever EventCalendar needs new event data.
The If there is any failure (e.g., if an AJAX request fails), then call the Instead of calling |
eventStartEditable
- Type
boolean - Default
true - Requires
Interactionplugin
Lets the user drag the events. Set it to false to forbid dragging:
let options = {
eventStartEditable: false
};
An event can override it with its own startEditable property. With null, the editable option decides.
eventTimeFormat
- Type
objectorfunction - Default
{hour: 'numeric', minute: '2-digit'}
The format of the time shown on an event.
The value is an object with the options of the native JavaScript Intl.DateTimeFormat object, or a function that returns the formatted Content.
let options = {
eventTimeFormat: {hour: '2-digit', minute: '2-digit', hour12: false}
// or as a function
// eventTimeFormat: (start, end) => start.toLocaleTimeString()
};
The function receives the following arguments:
|
JavaScript Date object containing the beginning of the time span to be formatted |
|
JavaScript Date object containing the end of the time span to be formatted, or `null` if the end time is not displayed (see [displayEventEnd](#displayeventend)) |
eventTextColor
- Type
string - Default
undefined
The default text color of the events. It is not used in the list views.
The value is any CSS color, such as '#f00', 'rgb(255,0,0)' or 'red':
let options = {
eventTextColor: '#fff'
};
The color of a resource and the color of the event itself take precedence over this option.
filterEventsWithResources
- Type
boolean - Default
false
Hides the events that do not belong to any of the resources in the dayGrid, timeGrid and list views. These views do not show the resources themselves, so by default they show all the events.
let options = {
view: 'timeGridWeek',
resources: [{id: 1, title: 'Room A'}],
// Only the events of Room A are shown
filterEventsWithResources: true
};
filterResourcesWithEvents
- Type
boolean - Default
false
Hides the resources that have no events in the period the resource view shows. Background events do not count.
let options = {
filterResourcesWithEvents: true
};
firstDay
- Type
integer - Default
0
The day the week starts on: 0 is Sunday, 1 is Monday, and so on up to 6, Saturday.
let options = {
// The week starts on Monday
firstDay: 1
};
flexibleSlotTimeLimits
- Type
booleanorobject - Default
false
Extends slotMinTime and slotMaxTime automatically when an event of the shown period is outside of them, so that no event is cut off or hidden.
let options = {
slotMinTime: '09:00',
slotMaxTime: '18:00',
// An event at 7:30 makes the day start at 7:30
flexibleSlotTimeLimits: true
};
With true, all the shown events are taken into account except the background ones. To decide it yourself, pass an object with the following properties instead:
|
A function to determine whether a given event should be taken into account or not.
|
let options = {
// Background events count as well
flexibleSlotTimeLimits: {eventFilter: event => true}
};
headerToolbar
- Type
object - Default
{start: 'title', center: '', end: 'today prev,next'}
What the toolbar at the top of the calendar contains: the title and the buttons.
The value is an object with the start, center and end properties for the three parts of the toolbar. Each one is a string with the names of the items. The items separated by a comma are joined into a group, and the items separated by a space have a gap between them.
let options = {
headerToolbar: {
start: 'prev,next today',
center: 'title',
end: 'dayGridMonth,timeGridWeek,timeGridDay'
}
};
The following items are available, as well as the ones defined in customButtons:
|
A text containing the current month/week/day |
|
A button for moving the calendar back one month/week/day |
|
A button for moving the calendar forward one month/week/day |
|
A button for moving the calendar to the current month/week/day |
a view name like |
A button that will switch the calendar to a specific view |
The texts of the buttons are set with buttonText.
height
- Type
string - Default
undefined
The height of the whole calendar. With a height the calendar scrolls inside itself, without one it is as tall as its content.
The value is any CSS height:
let options = {
height: '600px'
};
A percentage, like '100%', works when the element that contains the calendar has a height itself.
hiddenDays
- Type
array - Default
[]
The days of the week that are not shown: 0 is Sunday, 1 is Monday, and so on up to 6, Saturday.
let options = {
// Without the weekend
hiddenDays: [0, 6]
};
highlightedDates
- Type
array - Default
[]
The dates that are highlighted in the calendar: holidays, for example.
Each date is an ISO8601 date string or a JavaScript Date object:
let options = {
highlightedDates: ['2026-12-25', '2026-12-26', new Date(2027, 0, 1)]
};
icons
- Type
object - Default
{collapse: {html: '−'}, expand: {html: '+'}}
The icons of the buttons that have no text: currently, the buttons that collapse and expand nested resources in the resourceTimeline views.
The value is an object where each icon is a Content, or a function that receives the default icons and returns the new ones:
let options = {
icons: icons => ({...icons, collapse: {html: '▾'}, expand: {html: '▸'}})
};
An object replaces the default icons completely, so it has to contain all of them.
lazyFetching
- Type
boolean - Default
true
Makes the calendar skip loading when the period it moves to is inside the period it has loaded last, which keeps the number of requests low.
For example, the calendar starts in the month view and loads the events of February. When the user switches to the week view and browses the weeks of February, nothing is loaded: the calendar already has these events.
let options = {
// Load the events again on every change of the period
lazyFetching: false
};
With false, the events are loaded each time the shown period changes: on prev and next, for example.
The same applies to the resources when refetchResourcesOnNavigate is enabled.
listDayFormat
- Type
objectorfunction - Default
{weekday: 'long'}
The format of the text on the left side of the day headings in the list views.
The value is an object with the options of the native JavaScript Intl.DateTimeFormat object, or a function that returns the formatted Content.
let options = {
listDayFormat: {weekday: 'short'}
// or as a function
// listDayFormat: date => date.toDateString()
};
The function receives the JavaScript Date object to format.
listDaySideFormat
- Type
objectorfunction - Default
{year: 'numeric', month: 'long', day: 'numeric'}
The format of the text on the right side of the day headings in the list views.
The value is an object with the options of the native JavaScript Intl.DateTimeFormat object, or a function that returns the formatted Content.
let options = {
listDaySideFormat: {month: 'short', day: 'numeric'}
// or as a function
// listDaySideFormat: date => date.toDateString()
};
The function receives the JavaScript Date object to format.
loading
- Type
function - Default
undefined
Called when the calendar starts and when it finishes loading events or resources from their sources. It is the place to show and hide a spinner.
let options = {
loading: isLoading => {
spinner.hidden = !isLoading;
}
};
The function receives true when the loading starts, and false when it is done.
locale
- Type
string - Default
undefined
The language and the regional format of the dates and times in the calendar: of the title, the headings, the time of the events and so on.
The value is a locale for the native JavaScript Intl.DateTimeFormat object. Without a value the locale of the browser is used.
let options = {
locale: 'de'
};
Only the dates and times follow the locale. The texts of the buttons are set with buttonText, the other texts, such as all-day and No events, with the content options, and the first day of the week with firstDay.
longPressDelay
- Type
integer - Default
1000
On touch devices, how many milliseconds the user has to hold a finger before an event can be dragged or resized, or a date range can be selected. A shorter touch scrolls the calendar.
let options = {
longPressDelay: 500
};
To set it separately for the events and for the selection, use eventLongPressDelay and selectLongPressDelay.
monthHeaderFormat
- Type
objectorfunction - Default
{month: 'long'}
The format of the month headings in the resourceTimelineMonth and resourceTimelineYear views.
The value is an object with the options of the native JavaScript Intl.DateTimeFormat object, or a function that returns the formatted Content.
let options = {
monthHeaderFormat: {month: 'short', year: 'numeric'}
// or as a function
// monthHeaderFormat: date => date.toDateString()
};
The function receives the JavaScript Date object to format.
The row of the month headings is hidden when the view shows exactly one whole month, since the month is already in the title of the calendar.
moreLinkContent
- Type
Contentorfunction - Default
undefined
The content of the link that replaces the events that do not fit into a day, instead of the default +2 more. See dayMaxEvents.
The value is a Content, or a function that returns it:
let options = {
moreLinkContent: ({num}) => `${num} hidden`
};
The function receives an object with the following properties:
|
The number of hidden events |
|
The default text like |
In Svelte, React, Vue and Angular this content can be rendered by the framework itself: with a snippet, JSX, a slot or a template.
noEventsClick
- Type
function - Default
undefined
Called when the user clicks the empty area of a list view that has no events to show.
let options = {
noEventsClick: ({view}) => {
console.log('Nothing in', view.title);
}
};
The function receives an object with the following properties:
|
JavaScript native event object with low-level information such as click coordinates |
|
The current View object |
noEventsContent
- Type
Contentorfunction - Default
'No events'
What a list view shows when it has no events.
The value is a Content, or a function that returns it:
let options = {
noEventsContent: {html: '<i>Nothing is planned</i>'}
};
In Svelte, React, Vue and Angular this content can be rendered by the framework itself: with a snippet, JSX, a slot or a template.
nowIndicator
- Type
boolean - Default
false
Shows a line at the current time in the timeGrid, resourceTimeGrid and resourceTimeline views. The timeline views whose slots are days, such as resourceTimelineMonth, do not show it.
let options = {
nowIndicator: true
};
pointer
- Type
boolean - Default
false - Requires
Interactionplugin
Highlights the time slot or the day under the mouse pointer, which shows where a click will land.
let options = {
pointer: true
};
refetchResourcesOnNavigate
- Type
boolean - Default
false
Loads the resources again when the calendar moves to another period, so that each period can have its own resources. By default the resources are loaded once.
let options = {
resources: {url: '/resources'},
refetchResourcesOnNavigate: true
};
The request then contains the period the resources are needed for. Whether a period that is already loaded is requested again depends on lazyFetching.
resizeConstraint
- Type
function - Default
undefined - Requires
Interactionplugin
Limits how an event can be resized.
The function is called on every move of the pointer while an event is resized. It receives the same argument as eventResize, with the event as it would be with the new size, and returns false to forbid this size.
let options = {
// Not longer than 3 hours
resizeConstraint: ({event}) => event.end - event.start <= 3 * 60 * 60 * 1000
};
While the size is not allowed, the event keeps the last allowed size and the cursor changes to not-allowed. Releasing the pointer there cancels the resizing.
resourceExpand
- Type
function - Default
undefined
Called when the user expands or collapses a resource with nested children in the resourceTimeline views.
let options = {
resourceExpand: ({resource}) => {
console.log(resource.title, resource.expanded);
}
};
The function receives an object with the following properties:
|
The associated Resource object |
|
JavaScript native event object with low-level information such as click coordinates |
|
The current View object |
resources
- Type
array,objectorfunction - Default
[]
The resources of the resource views: rooms, people, machines, or anything else the events belong to. An event refers to its resources with the resourceId or resourceIds property.
They can be given in one of three ways:
1. Array of plain objects
If the resources are known in advance, pass them as an array of plain objects, which are parsed into Resource objects:
let options = {
resources: [
{id: 1, title: 'Room A'},
{id: 2, title: 'Room B', children: [
{id: 3, title: 'Room B1'}
]}
]
};
2. Fetch resources from a URL
To load the resources from a server, pass an object with the following properties:
|
A URL from which the calendar will fetch an array of parsable Resource objects in JSON format. If refetchResourcesOnNavigate is enabled then HTTP requests with the following parameters will be sent to the URL whenever the user navigates to a different date:
|
||||
|
HTTP request method. Default |
||||
|
Other GET/POST data you want to send to the server. Can be a plain object or a function that returns an object. Default |
let options = {
resources: {url: '/resources'}
};
3. Execute custom function
The resources can also be provided by your own function:
let options = {
resources: async fetchInfo => (await fetch('/api/resources')).json()
};
The function receives fetchInfo, successCallback and failureCallback. If refetchResourcesOnNavigate is enabled, the function is called each time the calendar moves to another period, and fetchInfo is an object with the following properties. Otherwise it is an empty object.
|
JavaScript Date object for the beginning of the range the calendar needs resources for |
|
JavaScript Date object for the end of the range the calendar needs resources for. Note: This value is exclusive |
|
ISO8601 string representation of the start date |
|
ISO8601 string representation of the end date |
|
The value of the calendar's [timeZone](#timezone) option |
The function passes an array of parsable Resource objects to successCallback, or the information about a failure to failureCallback. Instead of calling them, it can return the array or a Promise (or a thenable) of it.
resourcesInitiallyExpanded
- Type
boolean - Default
true
Whether the resources with nested children are expanded or collapsed at first in the resourceTimeline views.
let options = {
// Start with all groups collapsed
resourcesInitiallyExpanded: false
};
It applies to the resources that have no expanded property of their own and that the user has not expanded or collapsed yet.
resourceLabelContent
- Type
string,objectorfunction - Default
undefined
The content of a resource label, in place of the title of the resource.
The value is a Content, or a function that returns it:
let options = {
resourceLabelContent: ({resource}) => ({html: `<b>${resource.title}</b>`})
};
The function receives an object with the following properties:
|
The associated Resource object |
|
If it is a column that is within a specific date, this will be a Date object |
In Svelte, React, Vue and Angular this content can be rendered by the framework itself: with a snippet, JSX, a slot or a template.
resourceLabelDidMount
- Type
function - Default
undefined
Called right after the element of a resource label is added to the page. This is the place to attach something to the element: a tooltip, for example.
let options = {
resourceLabelDidMount: ({resource, el}) => {
el.title = resource.title;
}
};
The function receives an object with the following properties:
|
The HTML element for the label |
|
The associated Resource object |
|
If it is a column that is within a specific date, this will be a Date object |
It is called once for each element. The elements are created again, and the function is called again, when the resources are loaded again.
scrollTime
- Type
string,integerorobject - Default
'06:00:00'
The time the calendar is scrolled to when it is shown and each time it moves to other dates, so that the working hours are visible without scrolling.
The value is anything that can be parsed into a Duration object.
let options = {
scrollTime: '08:00'
};
select
- Type
function - Default
undefined - Requires
Interactionplugin
Called when the user has selected a range of dates or time. The selection is enabled with selectable.
let options = {
selectable: true,
select: ({start, end, allDay, resource}) => {
console.log(start, end, allDay, resource?.title);
}
};
The function receives an object with the following properties:
|
JavaScript Date object indicating the start of the selection |
|
JavaScript Date object indicating the end of the selection |
|
ISO8601 string representation of the start date |
|
ISO8601 string representation of the end date |
|
|
|
JavaScript native event object with low-level information such as click coordinates |
|
The current View object |
|
If the current view is a resource view, the Resource object that was selected |
The selection stays highlighted until the user clicks anywhere on the page or unselect() is called.
selectable
- Type
boolean - Default
false - Requires
Interactionplugin
Lets the user select several days or time slots by pressing and moving the pointer. The result is reported to the select callback.
let options = {
selectable: true
};
selectConstraint
- Type
function - Default
undefined - Requires
Interactionplugin
Limits what can be selected.
The function is called on every move of the pointer during the selection. It receives the same argument as select, with the range as it would be selected, and returns false to forbid this range.
let options = {
selectable: true,
// A selection cannot start on the weekend
selectConstraint: ({start}) => ![0, 6].includes(start.getDay())
};
While the range is not allowed, the selection keeps the last allowed range and the cursor changes to not-allowed. Releasing the pointer there cancels the selection.
selectBackgroundColor
- Type
string - Default
undefined - Requires
Interactionplugin
The background color of the selection, see selectable.
The value is any CSS color, such as '#f00', 'rgb(255,0,0)' or 'red':
let options = {
selectable: true,
selectBackgroundColor: '#93c5fd'
};
selectLongPressDelay
- Type
integer - Default
undefined - Requires
Interactionplugin
On touch devices, how many milliseconds the user has to hold a finger before the selection starts. A shorter touch scrolls the calendar.
let options = {
selectLongPressDelay: 500
};
Without a value, longPressDelay is used.
selectMinDistance
- Type
integer - Default
5 - Requires
Interactionplugin
How many pixels the pointer has to move before the selection starts. It keeps a click with a slightly moved mouse from being taken as a selection.
let options = {
selectMinDistance: 10
};
slotDuration
- Type
string,integerorobject - Default
'00:30:00'
Views override the default value as follows:
- resourceTimelineMonth
{days: 1}- resourceTimelineYear
{days: 1}
The length of one time slot, which is the step of the time grid.
The value is anything that can be parsed into a Duration object.
let options = {
// A slot of 15 minutes
slotDuration: '00:15'
};
How often the slots are labeled is set with slotLabelInterval, and the step of dragging, resizing and selecting with snapDuration.
slotEventOverlap
- Type
boolean - Default
true
Lets the events that happen at the same time overlap each other a little in the timeGrid and resourceTimeGrid views, which leaves more room for each of them.
let options = {
slotEventOverlap: false
};
With false, such events are placed side by side and share the width of the column.
slotHeight
- Type
integer - Default
24
The height of a time slot in pixels in the timeGrid and resourceTimeGrid views.
let options = {
slotHeight: 36
};
slotLabelFormat
- Type
objectorfunction - Default
{hour: 'numeric', minute: '2-digit'}
The format of the time labels of the slots.
The value is an object with the options of the native JavaScript Intl.DateTimeFormat object, or a function that returns the formatted Content.
let options = {
slotLabelFormat: {hour: '2-digit', minute: '2-digit', hour12: false}
// or as a function
// slotLabelFormat: time => time.toLocaleTimeString()
};
The function receives the JavaScript Date object to format.
slotLabelInterval
- Type
string,integerorobject - Default
undefined
How often the time slots are labeled in the timeGrid, resourceTimeGrid and resourceTimeline views.
The value is anything that can be parsed into a Duration object.
let options = {
slotDuration: '00:15',
// A label for each hour
slotLabelInterval: '01:00'
};
Without a value, every slot is labeled, or every other slot if slotDuration is less than an hour.
slotMaxTime
- Type
string,integerorobject - Default
'24:00:00'
The time of the day at which the time slots end. It can be later than midnight to show the night as a part of the previous day.
The value is anything that can be parsed into a Duration object.
let options = {
slotMinTime: '08:00',
slotMaxTime: '18:00'
};
slotMinTime
- Type
string,integerorobject - Default
'00:00:00'
The time of the day at which the time slots start.
The value is anything that can be parsed into a Duration object.
let options = {
slotMinTime: '08:00',
slotMaxTime: '18:00'
};
slotWidth
- Type
integer - Default
32
The width of a time slot in pixels in the resourceTimeline views.
let options = {
slotWidth: 48
};
snapDuration
- Type
string,integerorobject - Default
undefined
The step of time by which an event is dragged and resized, and a range is selected. By default it is equal to slotDuration.
The value is anything that can be parsed into a Duration object.
let options = {
slotDuration: '00:30',
// The events are moved by 5 minutes
snapDuration: '00:05'
};
theme
- Type
objectorfunction
-
Default
{allDay: 'ec-all-day', active: 'ec-active', bgEvent: 'ec-bg-event', bgEvents: 'ec-bg-events', body: 'ec-body', button: 'ec-button', buttonGroup: 'ec-button-group', calendar: 'ec', colHead: 'ec-col-head', day: 'ec-day', dayHead: 'ec-day-head', disabled: 'ec-disabled', endClipped: 'ec-end-clipped', event: 'ec-event', eventBody: 'ec-event-body', eventTime: 'ec-event-time', eventTitle: 'ec-event-title', events: 'ec-events', grid: 'ec-grid', header: 'ec-header', hidden: 'ec-hidden', highlight: 'ec-highlight', icon: 'ec-icon', lines: 'ec-lines', main: 'ec-main', noIeb: 'ec-no-ieb', noBeb: 'ec-no-beb', today: 'ec-today', title: 'ec-title', toolbar: 'ec-toolbar', view: 'ec-list ec-week-view', weekdays: ['ec-sun', ec-mon', ec-tue', ec-wed', ec-thu', ec-fri', ec-sat'], draggable: 'ec-draggable', ghost: 'ec-ghost', preview: 'ec-preview', pointer: 'ec-pointer', resizer: 'ec-resizer', start: 'ec-start', dragging: 'ec-dragging', resizingY: 'ec-resizing-y', resizingX: 'ec-resizing-x', selecting: 'ec-selecting', notAllowed: 'ec-not-allowed', startClipped: 'ec-start-clipped', uniform: 'ec-uniform', dayFoot: 'ec-day-foot', otherMonth: 'ec-other-month', popup: 'ec-popup', weekNumber: 'ec-week-number', daySide: 'ec-day-side', eventTag: 'ec-event-tag', noEvents: 'ec-no-events', nowIndicator: 'ec-now-indicator', sidebar: 'ec-sidebar', slot: 'ec-slot', colGroup: 'ec-col-group', expander: 'ec-expander', row: 'ec-row', rowHead: 'ec-row-head', slots: 'ec-slots'}Views override the default value as follows:
- dayGridDay
theme => ({...theme, view: 'ec-day-grid ec-day-view'}) - dayGridMonth
theme => ({...theme, view: 'ec-day-grid ec-month-view'}) - dayGridWeek
theme => ({...theme, view: 'ec-day-grid ec-week-view'}) - listDay
theme => ({...theme, view: 'ec-list ec-day-view'}) - listMonth
theme => ({...theme, view: 'ec-list ec-month-view'}) - listWeek
theme => ({...theme, view: 'ec-list ec-week-view'}) - listYear
theme => ({...theme, view: 'ec-list ec-year-view'}) - resourceTimeGridDay
theme => ({...theme, view: 'ec-resource ec-time-grid ec-day-view'}) - resourceTimeGridWeek
theme => ({...theme, view: 'ec-resource ec-time-grid ec-week-view'}) - resourceTimelineDay
theme => ({...theme, view: 'ec-resource ec-timeline ec-day-view'}) - resourceTimelineMonth
theme => ({...theme, view: 'ec-resource ec-timeline ec-month-view'}) - resourceTimelineWeek
theme => ({...theme, view: 'ec-resource ec-timeline ec-week-view'}) - resourceTimelineYear
theme => ({...theme, view: 'ec-resource ec-timeline ec-year-view'}) - timeGridDay
theme => ({...theme, view: 'ec-time-grid ec-day-view'}) - timeGridWeek
theme => ({...theme, view: 'ec-time-grid ec-week-view'})
- dayGridDay
The CSS classes the calendar puts on its elements. Change them to style the calendar with the classes of your own or of a CSS framework.
The value is an object with the classes, or a function that receives the default classes and returns the new ones. A function is the way to change some classes and keep the others:
let options = {
theme: theme => ({...theme, button: 'btn btn-outline-primary', today: 'ec-today my-today'})
};
An object replaces the default classes completely, so it has to contain all of them.
timeZone
- Type
string - Default
'local'
The time zone the calendar uses to display dates and times.
The following values are accepted:
'local'— uses the browser's local time zone'UTC'— uses UTC (zero offset)- A UTC offset string in the form
'±HH:MM', e.g.'+05:30'or'-06:00' - An IANA time zone name, e.g.
'America/Los_Angeles'— follows the rules of that zone, including daylight saving time (DST). An unknown name is treated as'local'
Event dates that contain an explicit timezone offset in their ISO string (e.g. '2028-06-01T10:00:00+02:00' or '2028-06-01T08:00:00Z') will be shifted to the calendar's timezone. Event dates without timezone info (e.g. '2028-06-01T10:00:00') are treated as floating — they display their wall-clock time as-is and will be interpreted in the calendar's timezone from that point forward.
JavaScript Date objects in event dates are read as the wall-clock time of the calendar's timezone, the same way the calendar passes dates to callbacks and returns them from methods like getEventById(). So new Date(2028, 5, 1, 10, 0) is displayed as 10:00 in any timezone, and a date from a callback can be passed back to addEvent() or updateEvent() as is. To pass an exact moment in time, use an ISO string with an offset, e.g. date.toISOString().
When the timeZone option changes at runtime, all already-loaded events are automatically shifted to the new timezone. If the date option comes from today (undefined or the today button, also after the prev/next buttons), it moves by the days between today in the old and in the new timezone. An explicitly set date stays the same day. Events from eventSources are re-fetched automatically.
A day always has 24 hours in the views, also on a DST day, as with 'local'. The hour the clocks skip stays in the grid and the hour they repeat is shown once, so an event across the change is drawn longer or shorter than it lasts. A date without an offset in the skipped hour is read like new Date() reads it (02:30 means 03:30) and moves to 03:30 when timeZone changes, in the repeated hour it is read as its first occurrence.
A format option with timeZoneName shows the browser's time zone, not the calendar's.
let options = {
timeZone: '+02:00',
events: [
{
start: '2028-06-01T10:00:00', // floating — displayed as 10:00
end: '2028-06-01T12:00:00',
title: 'Meeting'
},
{
start: '2028-06-01T10:00:00+00:00', // UTC — displayed as 12:00 in +02:00
end: '2028-06-01T12:00:00+00:00',
title: 'Call'
}
]
};
titleFormat
- Type
objectorfunction - Default
{year: 'numeric', month: 'short', day: 'numeric'}
Views override the default value as follows:
- dayGridMonth
{year: 'numeric', month: 'long'}- listDay
{year: 'numeric', month: 'long', day: 'numeric'}- listMonth
{year: 'numeric', month: 'long'}- listYear
{year: 'numeric'}- resourceTimelineDay
{year: 'numeric', month: 'long', day: 'numeric'}- resourceTimelineMonth
{year: 'numeric', month: 'long'}- resourceTimelineYear
{year: 'numeric'}- timeGridDay
{year: 'numeric', month: 'long', day: 'numeric'}
The format of the title in the toolbar, which is the period the calendar shows.
The value is an object with the options of the native JavaScript Intl.DateTimeFormat object, or a function that returns the formatted Content.
let options = {
titleFormat: {year: 'numeric', month: 'long'}
// or as a function
// titleFormat: (start, end) => start.toDateString() + ' – ' + end.toDateString()
};
The function receives the following arguments:
|
JavaScript Date object containing the beginning of the time span to be formatted |
|
JavaScript Date object containing the end of the time span to be formatted |
unselect
- Type
function - Default
undefined - Requires
Interactionplugin
Called when the current selection is cleared. It happens when:
- the user clicks anywhere on the page, unless unselectAuto is
false, - the user makes a new selection, in which case it is called before the new selection is made,
- the calendar moves to another period or the view is switched,
- the unselect() method is called.
let options = {
selectable: true,
unselect: ({view}) => {
console.log('The selection is cleared in', view.type);
}
};
The function receives an object with the following properties:
|
JavaScript native event object with low-level information such as click coordinates. If unselect has been triggered via the unselect method, jsEvent will be |
|
The current View object |
unselectAuto
- Type
boolean - Default
true - Requires
Interactionplugin
Clears the current selection when the user clicks anywhere on the page. See selectable.
let options = {
selectable: true,
// The selection stays until unselect() is called
unselectAuto: false
};
unselectCancel
- Type
string - Default
'' - Requires
Interactionplugin
A CSS selector for the elements that do not clear the selection when clicked, while unselectAuto is on. For example, a form where the user enters the details of the selected time.
let options = {
selectable: true,
unselectCancel: '.event-form'
};
validRange
- Type
object - Default
undefined
The range of dates the user can navigate within. The prev, next and today buttons are disabled when the whole period they lead to is outside of the range, and the days outside of it are disabled.
The value is an object with the following properties:
|
|
|
|
let options = {
validRange: {start: '2026-12-01', end: '2026-12-31'}
};
Either of the properties can be omitted, which leaves the range open on that side. The end date itself is inside the range.
The range limits the buttons only: methods like gotoDate() and next() can still move the calendar outside of it.
view
- Type
string - Default
'timeGridWeek'
The view the calendar shows.
let options = {
view: 'dayGridMonth'
};
The following views are available, each provided by the plugin of the same name:
'dayGridDay''dayGridWeek''dayGridMonth''listDay''listWeek''listMonth''listYear''resourceTimeGridDay''resourceTimeGridWeek''resourceTimelineDay''resourceTimelineWeek''resourceTimelineMonth''resourceTimelineYear''timeGridDay''timeGridWeek'
As well as the views of your own that are defined in views.
viewDidMount
- Type
function - Default
undefined
Called right after a view is added to the page: when the calendar is created and each time the view is switched.
let options = {
viewDidMount: ({view}) => {
console.log('Now showing', view.type);
}
};
The function receives an object with the following properties:
|
The mounted View object |
views
- Type
object - Default
{}
The options that apply to one view only, and the views of your own.
The value is an object where each key is the name of a view and each value is an object with the options for it:
let options = {
views: {
// Another format of the time in the month view
dayGridMonth: {eventTimeFormat: {hour: 'numeric'}},
// A new view: three days of the timeline
resourceTimelineThreeDays: {
type: 'resourceTimelineDay',
duration: {days: 3}
}
}
};
A name that is not a standard view defines a new view. Its type is the standard view it is based on and takes the options from. The new view is then used like any other: in the view option and in the headerToolbar. The text of its button is set in buttonText under the name of the view.
This option is only read when the calendar is created. Changing it afterwards, either with setOption or reactively in Svelte, has no effect.
weekNumberContent
- Type
Contentorfunction - Default
undefined
The content shown in place of the week number, which is W01 by default. See weekNumbers.
The value is a Content, or a function that returns it:
let options = {
weekNumbers: true,
weekNumberContent: ({week}) => `Week ${week}`
};
The function receives an object with the following properties:
|
JavaScript Date object containing the day within which the week number will be displayed |
|
Calculated week number |
In Svelte, React, Vue and Angular this content can be rendered by the framework itself: with a snippet, JSX, a slot or a template.
weekNumbers
- Type
boolean - Default
false
Shows the numbers of the weeks in the dayGrid and resourceTimeline views. A timeline of exactly one week does not show it.
let options = {
weekNumbers: true
};
The numbering depends on firstDay: with 0 the Western system is used, and with any other value the ISO one.
Methods
Methods allow you to manipulate EventCalendar after initialization. They are accessible from the calendar instance.
In Svelte, methods are available from a component instance:
<script>
import {Calendar, TimeGrid} from '@event-calendar/core';
let ec = $state();
let options = $state({
view: 'timeGridWeek',
eventSources: [{events: function() {
console.log('fetching...');
return [];
}}]
});
function invokeMethod() {
ec.refetchEvents();
}
</script>
<button onclick={invokeMethod}>Refetch events</button>
<Calendar bind:this={ec} plugins={[TimeGrid]} {options} />
getOption( name )
- Parameters
namestringThe option name
- Return value
mixedorundefined
This method allows you to get the current value of any calendar option.
// E.g. Get current date
let date = ec.getOption('date');
setOption( name, value )
- Parameters
namestringThe option namevaluemixedThe new option value
- Return value
EventCalendarThe calendar instance for chaining
This method allows you to set new value to any calendar option. If value is undefined, the option is reset to its default value.
// E.g. Change the current date
ec.setOption('date', new Date());
setOptions( options )
- Parameters
optionsobjectThe option names and their new values
- Return value
EventCalendarThe calendar instance for chaining
This method allows you to set several calendar options at once. An option with the undefined value is reset to its default value.
ec.setOptions({
view: 'timeGridDay',
slotDuration: '00:15'
});
addEvent( event )
- Parameters
- Return value Event object or
nullif theeventcan't be parsed
Adds a new event to the calendar.
getEventById( id )
- Parameters
idstring|integerThe ID of the event
- Return value Event object or
null
Returns a single event with the matching id.
getEvents()
- Return value
Event[]Array of Event objects
Returns an array of events that the calendar has in memory.
removeEventById( id )
- Parameters
idstring|integerThe ID of the event
- Return value
EventCalendarThe calendar instance for chaining
Removes a single event with the matching id.
updateEvent( event )
Updates a single event with the matching event.id. Returns null if there is no such event or the event can't be parsed.
refetchEvents()
- Return value
EventCalendarThe calendar instance for chaining
Refetches events from all sources.
refetchResources()
- Return value
EventCalendarThe calendar instance for chaining
Refetches resources from URL or custom function.
dateFromPoint( x, y )
- Return value
objectornull
Returns an info object with data as if the dateClick event had fired for that point.
info object contains the following properties:
|
JavaScript Date object for the date and time |
|
|
|
HTML element that represents the whole-day that contains the point |
|
If the current view is a resource view, the Resource object that owns this date |
Using this method, you can, for example, find out on which day a click occurred inside a multi-day event. To do this, inside eventClick, pass the jsEvent.clientX and jsEvent.clientY coordinates to dateFromPoint and get the desired date.
getView()
- Return value
View
Returns the View object for the current view.
gotoDate( date )
- Parameters
dateDate,stringorundefinedThis value can be either a JavaScript Date object, or an ISO8601 date string like'2026-12-31'.undefinedmeans today in the calendar's timeZone
- Return value
EventCalendarThe calendar instance for chaining
Moves the current calendar date to the given date and, in views with horizontal scrolling (resourceTimeline views and resourceTimeGrid views with datesAboveResources enabled), additionally scrolls the view to make this date visible.
Unlike setOption('date', date), which scrolls the view to today whenever today is inside the new visible period, this method always scrolls to the given date.
// E.g. Scroll to the date of the found event
ec.gotoDate(event.start);
next()
- Return value
EventCalendarThe calendar instance for chaining
Moves the current calendar date forward by 1 day/week/month (depending on the current view).
prev()
- Return value
EventCalendarThe calendar instance for chaining
Moves the current calendar date backward by 1 day/week/month (depending on the current view).
unselect()
- Return value
EventCalendarThe calendar instance for chaining
Clears the current selection. See selectable.
Content
The content value can be presented in the following forms:
- a string containing text
'some text' - an object containing the HTML string
{html: '<p>some HTML</p>'} - an object containing an array of DOM nodes
{domNodes: [node1, node2, ...]}
A function that defines content can also return another function, which renders the content by itself. It receives the element and can return a function that is called when the content is no longer needed:
function (info) {
return el => {
let chart = createChart(el, info.event.extendedProps.data);
return () => chart.destroy();
};
}
The calendar takes the changes in the size of such content into account.
Event object
This is a JavaScript object that EventCalendar uses to store information about a calendar event.
Here are all properties that exist in Event object:
|
A unique string identifier of the event |
|
An array of resource IDs that the event is associated with |
|
|
|
JavaScript Date object holding the event’s start time |
|
JavaScript Date object holding the event’s end time |
|
|
|
|
|
|
|
|
|
The rendering type of the event. Can be In month-based views such as In addition, in your callback functions, you may get the |
|
The layout group the event belongs to Events of the same layout group within a resource row are laid out as a unit, at the place of the first of them in |
|
The eventBackgroundColor override for this specific event |
|
The eventTextColor override for this specific event |
|
An array of additional CSS classes for this specific event |
|
An array of additional inline styling declarations for this specific event |
|
A plain object holding miscellaneous properties specified during parsing in the explicitly given |
Parsing event from a plain object
When EventCalendar receives an array of plain event’s objects either from the events option or as a result of an HTTP request to a URL of an event source, it parses the input objects into proper Event objects.
An input object without start can't be parsed, such an event is not added to the calendar.
Here are all admissible fields for the event’s input object:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In month-based views such as |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Duration object
This is a JavaScript object that EventCalendar uses to store information about a period of time, like 30 minutes or 1 day and 6 hours.
Here are all properties that exist in Duration object:
|
The number of years in duration |
|
The number of months in duration |
|
The number of days in duration |
|
The number of seconds in duration. If you want hours and minutes, you need to do division on this property |
|
Determines whether the duration represents a time period in weeks. This value is set during parsing the input data |
Parsing duration from input values
When EventCalendar receives a value for options like duration, scrollTime, slotDuration and others, it parses it into a proper Duration object.
The admissible input value can be specified in one of three formats:
- an object with any of the following keys:
year,years,month,months,day,days,minute,minutes,second,seconds - a string in the format
hh:mm:ssorhh:mm. For example,'05:00'specifies 5 hours - an integer specifying the total number of seconds
Resource object
This is a JavaScript object that EventCalendar uses to store information about a resource. Calendar events can be associated with resources and displayed separately using the resource view.
Here are all properties that exist in Resource object:
|
The unique string identifier for the resource |
|
The title of the resource. See Content |
|
Default background color for this resource's events |
|
Default text color for this resource's events |
|
A flag indicating whether the resource is expanded or collapsed if it has nested children. |
|
A plain object holding miscellaneous properties specified during parsing in the explicitly given |
Parsing resource from a plain object
When EventCalendar receives an array of plain resource’s objects for the resources option, it parses the input objects into proper Resource objects.
Here are all admissible fields for the resource’s input object:
|
|
|
|
|
|
|
|
|
|
|
|
|
Nested resources. See below |
The resourceTimeline views support displaying nested resources. Nested resources can be collapsed or expanded using an additional button that appears before the parent resource name. To pass nested resources, use the children field:
resources: [
{
id: 1,
title: 'Resource A',
children: [
{
id: 11,
title: 'Resource A1'
},
{
id: 12,
title: 'Resource A2'
}
]
}
]
View object
A View object contains information about a calendar view, such as title and date range.
Here are all properties that exist in View object:
|
Name of the view |
|
Title text that is displayed at the top of the header toolbar |
|
JavaScript Date that is the start of the interval the view is trying to represent. For example, in month view, this will be the first day of the month. This value disregards hidden days |
|
JavaScript Date that is the end of the interval the view is trying to represent. Note: This value is exclusive. For example, in month view, this will be the day after the last day of the month. This value disregards hidden days |
|
JavaScript Date that is the first visible day. In month view, this value is often before the 1st day of the month, because most months do not begin on the first day-of-week |
|
JavaScript Date that is the last visible day. Note: This value is exclusive |
Theming
The library provides a built-in dark theme. You can activate it by adding the ec-dark CSS class to any parent element of the calendar, e.g. <body class="ec-dark">.
If you want the dark theme to be activated automatically based on the preferred color scheme, then use the ec-auto-dark CSS class instead.
You can also customize the colors in the calendar by overriding CSS variables, for example:
.ec {
--ec-bg-color: #22272e;
--ec-text-color: #adbac7;
}
A list of all available CSS variables can be found here.
Browser support
The latest versions of Chrome, Firefox, Safari, and Edge are supported.
Explorer des projets similaires
Chargement…