Litopis date picker
Date fields and calendars for JavaScript apps.
Try it
Open the date field and select a date. Its form value appears below.
No period selected
Copy this setup
This playground uses daisyUI. Follow the daisyUI setup and add this markup.
<form id="travel-form">
<div id="travel-date">
<input slot="input" class="input w-full" />
</div>
<button type="submit">Read form values</button>
</form>
<output id="travel-value"></output>
Add this code to your TypeScript entry file.
Add it to your app
Use this setup in a JavaScript app with a bundler such as Vite.
npm install @litopis/dom
Put the container inside your form.
<form>
<div id="travel-date"></div>
</form>
Add the picker to your JavaScript entry file.
import { createDatePicker } from "@litopis/dom";
import "@litopis/dom/styles/base.css";
const root = document.querySelector("#travel-date");
if (root) {
createDatePicker(root, {
mode: "popover",
format: "dd.mm.yyyy",
label: "Travel date",
name: "travelDate",
});
}
The form submits travelDate as YYYY-MM-DD. Framework
components handle mounting and cleanup for you.
Choose a framework guide.
Read form values in a working example.
Keyboard interaction
Use the keyboard to select days, months or years.
Native form support
Submit one date or separate start and end values through a native form.
Headless core
Use date math and selection state with your own markup.
Optional CSS
Choose base styles, a UI theme adapter or your own CSS.
Bundle size
Gzipped size from a production build.
JavaScript
-
Core3.9 kB
Headless state, date math and keyboard navigation.
-
DOM bindings+11.2 kB
Accessible fields, form values and calendar DOM.
-
Web Components+2.0 kB
Custom-element API over the DOM bindings.
-
Framework bindings+0.2–1.2 kB
React, Vue, Solid and Svelte bindings.
+ is added size. Frameworks are peer dependencies.
CSS
-
Foundation2.7 kB
CSS variables and calendar anatomy.
-
Base styles+0.3 kB
Neutral default styles.
-
Theme adapters+0.2–0.3 kB
daisyUI, shadcn and Bootstrap.
Import one CSS entry point.
Integrations
Styling
Import foundation, base, daisyUI, shadcn or Bootstrap styles from
@litopis/dom/styles.
/* Example: use the host shadcn tokens */
@import "@litopis/dom/styles/shadcn.css";
.litopis {
--litopis-control-size: 44px;
--litopis-width: 22rem;
}