Litopis GitHub

Use Litopis with daisyUI

Add the Litopis calendar to your daisyUI input.

Try it

Both fields use daisyUI's native input class.

No date selected

Installation

Start with an app that uses daisyUI 5.

sh
npm install @litopis/dom

Import the Litopis adapter in your JavaScript entry file. It styles the calendar and maps it to daisyUI theme variables. Put daisyUI's input class on a slotted input to use the native field style. Add input-lg for a larger field or validator for the native invalid-state color.

The adapter is maintained by Litopis. It needs your app's daisyUI styles.

Complete example

Add this form to your page.

html
<form id="booking">
  <div id="appointment">
    <input
      slot="input"
      class="input"
      type="text"
      placeholder="Choose a date"
    />
  </div>
  <button class="btn btn-neutral">Read form value</button>
  <output id="booking-value">No date selected</output>
</form>

Add this code to main.js.

js
import { createDatePicker } from "@litopis/dom";
import "@litopis/dom/styles/daisyui.css";

const form = document.querySelector("#booking");
const root = document.querySelector("#appointment");
const output = document.querySelector("#booking-value");

if (form && root && output) {
  createDatePicker(root, {
    label: "Appointment date",
    name: "appointment",
    mode: "popover",
    format: "yyyy-mm-dd",
  });

  form.addEventListener("submit", (event) => {
    event.preventDefault();
    const value = new FormData(form).get("appointment");
    output.textContent = value || "No date selected";
  });
}

The field displays an ISO date. The form submits the same YYYY-MM-DD value.

Themes

The calendar adapter reads daisyUI variables from its parent. Your existing data-theme setting applies to it. DaisyUI styles the slotted field through its native input class.

html
<div data-theme="business">
  <div id="appointment"></div>
</div>

See framework guides for React, Vue, Solid, Svelte or Web Components. Use the daisyUI stylesheet in place of the base stylesheet.