Overview
Lean, UX-driven, and extensible, yet it doesn’t depend on any libraries. There’s minimal UI but many themes. Rich, exposed APIs and event system make it suitable for any environment. For full documentation please check the
plugin's site .
Usage
Flatpickr's CSS and Javascript files are bundled in the global plugin bundles and globally included in all pages:
copy
<link href="assets/plugins/global/plugins.bundle.css" rel="stylesheet" type="text/css"/>
<script src="assets/plugins/global/plugins.bundle.js"></script>
Initialization
Flatpickr's CSS is highly customized in
sass/vendors/plugins/_flatpickr.scss
SCSS file in order to use it as native component within the design system. The SCSS code is compiled into
assets/plugins/global/plugins.bundle.css
and globally included in all pages.
To start usin Flatpckr right away, check the official
Getting Started guide.
Basic Examples
Basic examples of Flatpickr on default and solid background input styles:
copy
$("#kt_datepicker_1").flatpickr();
$("#kt_datepicker_2").flatpickr();
<div class="mb-10">
<label for="" class="form-label">Default input style</label>
<input class="form-control" placeholder="Pick a date" id="kt_datepicker_1"/>
</div>
<div class="mb-0">
<label for="" class="form-label">Solid background style</label>
<input class="form-control form-control-solid" placeholder="Pick a date" id="kt_datepicker_2"/>
</div>
DateTime
Specify datetime format through
dateFormat
parameter to enable date and time selection.
copy
$("#kt_datepicker_3").flatpickr({
enableTime: true,
dateFormat: "Y-m-d H:i",
});
<div class="mb-0">
<label for="" class="form-label">Select date and time</label>
<input class="form-control form-control-solid" placeholder="Pick date & time" id="kt_datepicker_3"/>
</div>
Disabling Dates
Use
disable
option to make certain dates or range of dates unavailable for selection:
copy
$("#kt_datepicker_4").flatpickr({
onReady: function () {
this.jumpToDate("2025-01")
},
disable: ["2025-01-10", "22025-01-11", "2025-01-12", "2025-01-13", "2025-01-14", "2025-01-15", "2025-01-16", "2025-01-17"],
dateFormat: "Y-m-d",
});
$("#kt_datepicker_5").flatpickr({
onReady: function () {
this.jumpToDate("2025-01")
},
dateFormat: "Y-m-d",
disable: [
{
from: "2025-01-05",
to: "2025-01-25"
},
{
from: "2025-02-03",
to: "2025-02-15"
}
]
});
Selecting Multiple Dates
It is possible to select multiple dates at once:
copy
$("#kt_datepicker_6").flatpickr({
onReady: function () {
this.jumpToDate("2025-01")
},
mode: "multiple",
dateFormat: "Y-m-d",
defaultDate: ["2025-01-05", "2025-01-10"]
});
Range Selections
Select a range of dates using the range calendar. Note that disabled dates (by either minDate, maxDate, enable or disable) will not be allowed in selections.
copy
$("#kt_datepicker_7").flatpickr({
altInput: true,
altFormat: "F j, Y",
dateFormat: "Y-m-d",
mode: "range"
});
Time Picker
Hide date picker and allow only time picker:
copy
$("#kt_datepicker_8").flatpickr({
enableTime: true,
noCalendar: true,
dateFormat: "H:i",
});
Week Numbers
Enable the weekNumbers option to display the week number in a column left to the calendar.
copy
$("#kt_datepicker_9").flatpickr({
weekNumbers: true
});
Modal Example
Use Flatpickr within Bootstrap Modal:
Add
data-bs-focus="false"
to disable setting the focus on the modal inputs when initialized.
copy
$("#kt_datepicker_10").flatpickr();
<!--begin::Modal-->
<div class="modal fade" tabindex="-1" data-bs-focus="false" id="kt_modal_1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Modal title</h5>
<!--begin::Close-->
<div class="btn btn-icon btn-sm btn-active-light-primary ms-2" data-bs-dismiss="modal" aria-label="Close">
<span class="svg-icon fs-2x"></span>
</div>
<!--end::Close-->
</div>
<div class="modal-body">
<div class="mb-0">
<label for="" class="form-label">Select date</label>
<input class="form-control form-control-solid" placeholder="Pick date" id="kt_datepicker_10"/>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<!--end::Modal-->