biletiki.store — a website example for searching for flight tickets and hotels using vanilla-calendar.
DOM Templates
DOM templates allow you to customize the DOM structure of the calendar almost entirely and add your own HTML elements, such as buttons. Each calendar type has its own default template, and you can customize each of them.
Tags containing the «#» symbol are registered calendar components and should have a closing forward slash at the end of the tag, except for the <#Multiple><#/Multiple> tag, which wraps a single month. The default templates list all possible components for that template.
DOMTemplates.default
Type: String
Default: string
Options: string
new VanillaCalendar('#calendar', {
DOMTemplates: {
default: `
<div class="vanilla-calendar-header">
<#ArrowPrev />
<div class="vanilla-calendar-header__content">
<#Month />
<#Year />
</div>
<#ArrowNext />
</div>
<div class="vanilla-calendar-wrapper">
<#WeekNumbers />
<div class="vanilla-calendar-content">
<#Week />
<#Days />
</div>
</div>
<#ControlTime />
`
}
});
new VanillaCalendar('#calendar', {
DOMTemplates: {
default: `
<div class="vanilla-calendar-header">
<#ArrowPrev />
<div class="vanilla-calendar-header__content">
<#Month />
<#Year />
</div>
<#ArrowNext />
</div>
<div class="vanilla-calendar-wrapper">
<#WeekNumbers />
<div class="vanilla-calendar-content">
<#Week />
<#Days />
</div>
</div>
<#ControlTime />
`
}
});
This is the default template for displaying a single month and its dates.
DOMTemplates.multiple
Type: String
Default: string
Options: string
new VanillaCalendar('#calendar', {
DOMTemplates: {
multiple: `
<div class="vanilla-calendar-controls">
<#ArrowPrev />
<#ArrowNext />
</div>
<div class="vanilla-calendar-grid">
<#Multiple>
<div class="vanilla-calendar-column">
<div class="vanilla-calendar-header">
<div class="vanilla-calendar-header__content">
<#Month />
<#Year />
</div>
</div>
<div class="vanilla-calendar-wrapper">
<#WeekNumbers />
<div class="vanilla-calendar-content">
<#Week />
<#Days />
</div>
</div>
</div>
<#/Multiple>
</div>
<#ControlTime />
`
}
});
new VanillaCalendar('#calendar', {
DOMTemplates: {
multiple: `
<div class="vanilla-calendar-controls">
<#ArrowPrev />
<#ArrowNext />
</div>
<div class="vanilla-calendar-grid">
<#Multiple>
<div class="vanilla-calendar-column">
<div class="vanilla-calendar-header">
<div class="vanilla-calendar-header__content">
<#Month />
<#Year />
</div>
</div>
<div class="vanilla-calendar-wrapper">
<#WeekNumbers />
<div class="vanilla-calendar-content">
<#Week />
<#Days />
</div>
</div>
</div>
<#/Multiple>
</div>
<#ControlTime />
`
}
});
This is the default template for displaying multiple months and their dates.
DOMTemplates.month
Type: String
Default: string
Options: string
new VanillaCalendar('#calendar', {
DOMTemplates: {
month: `
<div class="vanilla-calendar-header">
<div class="vanilla-calendar-header__content">
<#Month />
<#Year />
</div>
</div>
<div class="vanilla-calendar-wrapper">
<div class="vanilla-calendar-content">
<#Months />
</div>
</div>
`
}
});
new VanillaCalendar('#calendar', {
DOMTemplates: {
month: `
<div class="vanilla-calendar-header">
<div class="vanilla-calendar-header__content">
<#Month />
<#Year />
</div>
</div>
<div class="vanilla-calendar-wrapper">
<div class="vanilla-calendar-content">
<#Months />
</div>
</div>
`
}
});
This is the default template for selecting a month.
DOMTemplates.year
Type: String
Default: string
Options: string
new VanillaCalendar('#calendar', {
DOMTemplates: {
year: `
<div class="vanilla-calendar-header">
<#ArrowPrev />
<div class="vanilla-calendar-header__content">
<#Month />
<#Year />
</div>
<#ArrowNext />
</div>
<div class="vanilla-calendar-wrapper">
<div class="vanilla-calendar-content">
<#Years />
</div>
</div>
`
}
});
new VanillaCalendar('#calendar', {
DOMTemplates: {
year: `
<div class="vanilla-calendar-header">
<#ArrowPrev />
<div class="vanilla-calendar-header__content">
<#Month />
<#Year />
</div>
<#ArrowNext />
</div>
<div class="vanilla-calendar-wrapper">
<div class="vanilla-calendar-content">
<#Years />
</div>
</div>
`
}
});
This is the default template for selecting a year.