Calendar
Bootstrap 5 Calendar plugin
MDB calendar is a plugin that allows you to efficiently manage tasks. Thanks to this extension you will be able to easily create new events, manage current events, move existing events between other days, and store all data in an easily readable array.
Responsive Calendar plugin built with the latest Bootstrap 5. Various customization options like default view, event formats, customizable captions, and much more.Note: Read the API tab to find all available options and advanced customization
Note: Currently, the plugin is only compatible with the basic MDB package imported in UMD format. More about import MDB formats.
Basic example
Several predefined events provide a visual representation of how the plugin appears."
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 Angular Meetup | 16 | 17 | 18 JS Conference | 19 Vue Meetup Meeting |
20 Angular Meetup Vue Meetup Call | 21 | 22 | 23 React Meetup | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
Event formats
Calendar events can be added with time in two different formats - 12h or 24h. Optionally, you can also use the dayjs static getter which returns the current date object. We recommend reading the dayjs library documentation before using this method.
Monday first
Set the data-mdb-monday-first
attribute to true
to designate Monday as the first day of the week
Mon | Tue | Wed | Thu | Fri | Sat | Sun |
---|---|---|---|---|---|---|
31 | 1 | 2 | 3 | 4 | 5 | 6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 Angular Meetup | 16 | 17 | 18 JS Conference | 19 Vue Meetup Meeting | 20 Call |
21 Angular Meetup Vue Meetup | 22 | 23 React Meetup | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 |
Default view
Set the data-mdb-default-view
attribute to week
or
list
to change the start view. By default, it is a month
.
Sun 13 | Mon 14 | Tue 15 | Wed 16 | Thu 17 | Fri 18 | Sat 19 | |
---|---|---|---|---|---|---|---|
Angular Meetup | JS Conference | Vue Meetup Meeting | |||||
1:00 | |||||||
2:00 | |||||||
3:00 | |||||||
4:00 | |||||||
5:00 | |||||||
6:00 | |||||||
7:00 | |||||||
8:00 | Meeting | ||||||
9:00 | Meeting | ||||||
10:00 | Meeting | ||||||
11:00 | Meeting | ||||||
12:00 | |||||||
13:00 | |||||||
14:00 | |||||||
15:00 | |||||||
16:00 | |||||||
17:00 | |||||||
18:00 | |||||||
19:00 | |||||||
20:00 | |||||||
21:00 | |||||||
22:00 | |||||||
23:00 |
Twelve hour
By setting the data-mdb-twelve-hour
attribute to true
, you get a 12-hour
schedule.
Sun 13 | Mon 14 | Tue 15 | Wed 16 | Thu 17 | Fri 18 | Sat 19 | |
---|---|---|---|---|---|---|---|
Angular Meetup | JS Conference | Vue Meetup Meeting | |||||
1:00 am | |||||||
2:00 am | |||||||
3:00 am | |||||||
4:00 am | |||||||
5:00 am | |||||||
6:00 am | |||||||
7:00 am | |||||||
8:00 am | Meeting | ||||||
9:00 am | Meeting | ||||||
10:00 am | Meeting | ||||||
11:00 am | Meeting | ||||||
12:00 pm | |||||||
1:00 pm | |||||||
2:00 pm | |||||||
3:00 pm | |||||||
4:00 pm | |||||||
5:00 pm | |||||||
6:00 pm | |||||||
7:00 pm | |||||||
8:00 pm | |||||||
9:00 pm | |||||||
10:00 pm | |||||||
11:00 pm |
Customize captions
You can effortlessly customize all captions using data attributes. Available options are listed in the API tab.
Nd | Pon | Wt | Śr | Czw | Pt | Sb |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 Angular Meetup | 16 | 17 | 18 JS Conference | 19 Vue Meetup Meeting |
20 Angular Meetup Vue Meetup Call | 21 | 22 | 23 React Meetup | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
Customize pickers
You can customize datepicker
and timepicker
displayed in the calendar changing options
availible in the API tab of respected pickers.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 Angular Meetup | 16 | 17 | 18 JS Conference | 19 Vue Meetup Meeting |
20 Angular Meetup Vue Meetup Call | 21 | 22 | 23 React Meetup | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
Default date
A starting day can be easily set using the
data-mdb-default-date
attribute.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 |
Readonly
The editable mode can be easily disabled using the
data-mdb-readonly
attribute.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 Angular Meetup | 16 | 17 | 18 JS Conference | 19 Vue Meetup Meeting |
20 Angular Meetup Vue Meetup Call | 21 | 22 | 23 React Meetup | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
Readonly events
The editable mode for any event can be easily disabled by adding
readonly
attribute in the event's dataset.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 Readonly event | 16 | 17 | 18 Readonly event | 19 Vue Meetup Meeting |
20 Readonly event Vue Meetup Readonly event | 21 | 22 | 23 React Meetup | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
Disabled modules
Some of the modules can be disabled via data attributes or JavaScript. Here's an example without tooltips and some toolbar action elements.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 Angular Meetup | 16 | 17 | 18 JS Conference | 19 Vue Meetup Meeting |
20 Angular Meetup Vue Meetup Call | 21 | 22 | 23 React Meetup | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
Blur
Past events can be blurred with the data-mdb-blur
attribute.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 Angular Meetup | 16 | 17 | 18 JS Conference | 19 Vue Meetup Meeting |
20 Angular Meetup Vue Meetup Call | 21 | 22 | 23 React Meetup | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
Custom attributes
You can add your own attributes to existing and new events. Below is an example
with the id
attribute.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 Angular Meetup | 16 | 17 | 18 JS Conference | 19 Vue Meetup Meeting |
20 Angular Meetup Vue Meetup Call | 21 | 22 | 23 React Meetup | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
Custom modal
This example demonstrates a calendar with a custom modal that allows users to add, edit, and remove events, including fields not available in the default modal. For simplicity, the example uses only dates without specifying hours.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 SUNDAY EVENT | 14 | 15 Angular Meetup | 16 | 17 | 18 JS Conference | 19 Vue Meetup Meeting |
20 Angular Meetup Vue Meetup Call | 21 | 22 | 23 React Meetup | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
Calendar - API
Import
Usage
Via data attributes
Using the Calendar plugin doesn't require any additional JavaScript code - simply add
data-mdb-calendar-init
attribute to
.calendar
and use other data attributes to set all options.
Via JavaScript
Via jQuery
Note: By default, MDB does not include jQuery and you have to add it to the project on your own.
Options
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to
data-mdb-
, as in data-mdb-readonly=""
.
Name | Type | Default | Description |
---|---|---|---|
weekdays
|
Array | String | ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] |
Defines weekdays displayed names. |
months
|
Array | String |
['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August',
'September', 'October', 'November', 'December']
|
Defines months displayed names. |
monthsShort
|
Array | String | ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] |
Defines shortened months displayed names. |
mondayFirst
|
Boolean | false |
Changes first day of week to monday. |
defaultView
|
String | 'month' |
Defines default view. |
twelveHour
|
Boolean | false |
Changes time mode from 24h to 12h. |
defaultDate
|
Object | String | dayjs() |
Defines the default starting date. |
readonly
|
Boolean | false |
Disables event's edition. |
todayCaption
|
String | 'Today' |
Defines caption for today. |
monthCaption
|
String | 'Month' |
Defines caption for month option. |
weekCaption
|
String | 'Week' |
Defines caption for week option. |
listCaption
|
String | 'List' |
Defines caption for list option. |
allDayCaption
|
String | 'All day event' |
Defines caption for all day event checkbox. |
noEventsCaption
|
String | 'No events' |
Defines caption for empty list view. |
summaryCaption
|
String | 'Summary' |
Defines caption for summary input label. |
descriptionCaption
|
String | 'Description' |
Defines caption for description input label. |
startCaption
|
String | 'Start' |
Defines caption for start input label. |
endCaption
|
String | 'End' |
Defines caption for end input label. |
addCaption
|
String | 'Add' |
Defines caption for add event button. |
deleteCaption
|
String | 'Remove' |
Defines caption for remove event button. |
saveCaption
|
String | 'Save' |
Defines caption for save event button. |
closeCaption
|
String | 'Close' |
Defines caption for close button. |
addEventCaption
|
String | 'Add event' |
Defines caption for button that trigger the add event modal. |
addEventModalCaption
|
String | 'Add an event' |
Defines caption for add event modal title. |
editEventModalCaption
|
String | 'Edit an event' |
Defines caption for edit event modal title. |
events
|
Array of Objects | [] |
Defines calendar events. |
tooltips
|
Boolean | true |
Enables tooltips. |
navigation
|
Boolean | true |
Enables navigation. |
viewSelect
|
Boolean | true |
Enables viewSelect. |
addEventButton
|
Boolean | true |
Enables addEventButton. |
blur
|
Boolean | false |
Enables past events blur style. |
newEventAttributes
|
Function | (event) => event |
Modifies new events attributes. |
datepickerOptions
|
Object | {} |
Allow setting custom options for datepicker displayed in the calendar. |
timepickerOptions
|
Object | {} |
Allow setting custom options for timepicker displayed in the calendar. |
dateFormat
|
String | 'DD/MM/YYY' |
Allow setting custom date format in the calendar. |
Methods
Name | Parameters | Description | Example |
---|---|---|---|
init |
Initializes the calendar. | instance.init() |
|
prev |
Changes the period of time to previous. | instance.prev() |
|
next |
Changes the period of time to next. | instance.next() |
|
today |
Changes the period of time to today. | instance.today() |
|
changeView
|
view | Changes the view. |
instance.changeView('week')
|
refresh
|
Refreshes the calendar. |
instance.refresh()
|
|
addEvents
|
events | Adds new events to the calendar. |
instance.addEvents([...])
|
editEvents
|
event | Updates the details of a specified event. |
instance.editEvents({...})
|
removeEvent
|
event | Removes the specified event from the calendar. |
instance.removeEvent({...})
|
removeEvents
|
Removes all events from the calendar. |
instance.removeEvents()
|
|
dispose
|
Disposes a calendar instance. |
instance.dispose()
|
|
dayjs |
Static method which returns a dayjs function. | Calendar.dayjs() |
|
getInstance
|
Static method which allows you to get the calendar instance associated with a DOM element. |
Calendar.getInstance(calendarElement)
|
Events
Name | Description |
---|---|
prev.mdb.calendar
|
Emitted when the prev method triggers. |
next.mdb.calendar
|
Emitted when the next method triggers. |
today.mdb.calendar
|
Emitted when the today method triggers. |
viewChange.mdb.calendar
|
Emitted when the changeView method triggers. |
update.mdb.calendar
|
Emitted when the refresh method triggers. |
addEvent.mdb.calendar
|
Emitted before the "Add Event" event modal appears. Returns the selected date. Use e.preventDefault()
to prevent the default modal from displaying. |
addedEvent.mdb.calendar
|
Emitted after new events are added. Returns array of newly event objects. |
editEvent.mdb.calendar
|
Emitted before the "Edit Event" modal appears. Returns the event object. Use e.preventDefault()
to prevent the default modal from displaying. |
editedEvent.mdb.calendar
|
Emitted after an event is edited. Returns the updated event object. |
deleteEvent.mdb.calendar
|
Emitted before an event is deleted. Returns the event object that is about to be removed. Use e.preventDefault()
to prevent deletion. |
deletedEvent.mdb.calendar
|
Emitted after an event is deleted. |