Hi,
I’m working with a Tailwind CSS / Metronic date picker and I have a problem with preselecting a date and opening the calendar on the correct month.
Current HTML:
<!--begin::Input with Calendar-->
<div class="kt-input w-64">
<i class="ki-outline ki-calendar"></i>
<input
class="grow"
type="text"
id="input-date-picker"
value="2026-01-02"
placeholder="Select a date"
readonly
data-kt-date-picker="true"
data-kt-date-picker-input-mode="true"
data-kt-date-picker-position-to-input="left"
/>
</div>
<!--end::Input with Calendar--> Hi
The Metronic date picker (and the underlying Vanilla Calendar Pro) does not read the input’s value when it initializes. It only uses explicit options. To open on the correct month and have the date selected, pass the initial state via data attributes on the same element that has data-kt-date-picker="true" (your input):
1. Selected date – use data-kt-date-picker-selected-dates with a JSON array of date strings in YYYY-MM-DD (your 2026-01-02 is already in the right format).
2. Month and year shown – use data-kt-date-picker-selected-month and data-kt-date-picker-selected-year so the calendar opens on that month. Month is 0âindexed (0 = January, 11 = December).
Example for 2 Jan 2026:
<input
class="grow"
type="text"
value="2026-01-02"
placeholder="Select a date"
readonly
data-kt-date-picker="true"
data-kt-date-picker-input-mode="true"
data-kt-date-picker-position-to-input="left"
data-kt-date-picker-selected-dates="["2026-01-02"]"
data-kt-date-picker-selected-month="0"
data-kt-date-picker-selected-year="2026"
/>