Getting started
Add the files
From a CDN
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flow-datepicker@1.0.0/dist/flow-datepicker.min.css">
<script src="https://cdn.jsdelivr.net/npm/flow-datepicker@1.0.0/dist/flow-datepicker.min.js"></script>unpkg works too: https://unpkg.com/flow-datepicker@1.0.0/dist/flow-datepicker.min.js.
From npm
npm install flow-datepickerimport { FlowDatepicker } from 'flow-datepicker';
import 'flow-datepicker/css';
FlowDatepicker.init(document);The ES module does not start anything by itself; call FlowDatepicker.init() or FlowDatepicker.autoInit().
Download
The files are also attached to every GitHub release. Download flow-datepicker.min.js and flow-datepicker.min.css from the latest release (the zip has every build and the source maps), or build them yourself:
git clone https://github.com/waqasahmaddev/flow-datepicker.git
cd flow-datepicker
npm install
npm run buildThe files land in dist/. Put both in the <head>:
<link rel="stylesheet" href="/css/flow-datepicker.min.css">
<script src="/js/flow-datepicker.min.js"></script>Loading the script in the <head> (without defer) lets it enhance each input while the page is parsed, so nothing moves on screen.
Mark the inputs
<input type="date" name="publishDate" data-flow-datepicker>
<input type="time" name="startTime" step="300" data-flow-datepicker>
<input type="datetime-local" name="meetingAt" data-flow-datepicker>
<div data-flow-datepicker="range">
<input type="date" name="from">
<input type="date" name="to">
</div>That is all. Every input with data-flow-datepicker starts by itself, also inputs added later by htmx.
Start inputs yourself
Use data-flow-datepicker="manual" to skip the automatic start and create the picker in your own code:
const picker = new FlowDatepicker('#publishDate', { min: 'today' });See JavaScript and modules for the ES module build.