timepicker-ui
4.6.0GitHub
timepicker-ui
Basic Examples / Getting Started

Getting Started

Two small date picker examples built with @pglejzer/datepicker-ui, the companion of timepicker-ui.

Default picker

#

Pass a selector and call create(). A bare <input> is wrapped in a div.dp-ui host. With no options the picker selects a single date and opens as a docked popover, or as a modal on small windows.

Default
import DatepickerUI from "@pglejzer/datepicker-ui";
import "@pglejzer/datepicker-ui/index.css";
new DatepickerUI("#date").create();

Read the confirmed value

#

callbacks.onConfirm receives { value, autoCommit }. In single mode value.value is the ISO date YYYY-MM-DD, whatever format the input shows. value is null when the field was cleared.

onConfirm
Nothing confirmed yet
import DatepickerUI from "@pglejzer/datepicker-ui";
import "@pglejzer/datepicker-ui/index.css";
const output = document.querySelector("#confirmed");
new DatepickerUI("#date", {
callbacks: {
onConfirm: ({ value }) => {
output.textContent = value && "value" in value ? value.value : "";
},
},
}).create();

Docs: Quick Start · Events · Options

Esc