Documentation v8.0.36

Preview Downloads Purchase

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:
<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.scssSCSS file in order to use it as native component within the design system. The SCSS code is compiled into assets/plugins/global/plugins.bundle.cssand globally included in all pages.
  • Flatpickr's Javascript is globally initialized with some predefined settings in src/js/vendors/plugins/flatpickr.init.jsand the initialization code is bundled within assets/plugins/global/plugins.bundle.jsand 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:
$("#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 dateFormatparameter to enable date and time selection.
$("#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 disableoption to make certain dates or range of dates unavailable for selection:
$("#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:
$("#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.
$("#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:
$("#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.
$("#kt_datepicker_9").flatpickr({
    weekNumbers: true
});

Modal Example

Use Flatpickr within Bootstrap Modal:
$("#kt_datepicker_10").flatpickr();
<!--begin::Modal-->
<div class="modal fade" tabindex="-1" 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 svg-icon-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-->

Explore

Metronic Licenses

License FAQs
Regular License
For single end product used by you or one client
$ 39
Extended License
For single SaaS app with paying users
$ 939
Custom License
Reach us for custom license offers.
Buy Now
Learn & Get Inspired

Support at devs.keenthemes.com

Join our developers community to find answer to your question and help others. FAQs
Get Support
Documentation & Videos
From guides and video tutorials, to live demos and code examples to get started.
Plugins & Components
Check out our 300+ in-house components and customized 3rd-party plugins.
Layout Builder
Build your layout, preview it and export the HTML for server side integration.
Metronic Downloads
Download your prefered framework and demo with one click.
What's New
Latest features and improvements added with our users feedback in mind.
Buy now