Tailwind CSS Datepicker JavaScript Plugin
Build functional Tailwind CSS datepickers with Preline UI, including single dates, ranges, time selection, inline calendars, presets, and JavaScript methods.
Requires Additional Installation
Note that this component requires the use of the third-party Vanilla Calendar Pro plugin.
Requires JS
Note that this component requires the use of our Advanced Datepicker plugin, else you can skip this message if you are already using Preline UI as a package.
Installation
-
Install Vanilla Calendar Pro
Install
Vanilla Calendar Provia npmTerminalnpm i vanilla-calendar-pro -
Add Preline CSS for an Advanced Datepicker
Import the Preline UI Datepciker CSS file into your Tailwind CSS file. Here's how the full CSS file should look like:
CSS@import "tailwindcss"; /* Preline UI */ @import "./node_modules/preline/variants.css"; @import "./node_modules/preline/src/plugins/datepicker/styles.css"; /* Preline Themes */ @import "./themes/theme.css";If you plan to use Preline with utility-based classes, you should replace
styles.csswithstyles-utility.css. -
Add the Vanilla Calendar Pro JavaScript
Include the JavaScript
<script>near the end of your</body>tag:HTMLCertain JavaScript Helpers in Preline UI make use of Lodash plugin. Don't forget to install it, if you haven't done so already:
npm i lodash
Single-calendar preset ranges
Provide preset ranges while keeping the selection inside a single calendar view.
Forced light theme
Force the calendar UI to use its light theme regardless of the surrounding page theme.
Preset ranges
Offer predefined ranges for quick selection alongside manual date-range picking.
Date range with time
Combine date-range selection with time inputs for both start and end values.
Inline datepicker
Render the calendar inline instead of inside a popover, with range and time controls visible.
Default calendar controls
Use the built-in month and year controls provided by the calendar.
Custom select styling
Apply custom styles to the month and year select controls inside the calendar.
Datepicker in modal
Use the advanced datepicker inside a modal without changing the interaction pattern.
Destroy and reinitialize
Use the destroy method to remove a datepicker instance, then initialize it again when needed.