EL MAHDI Bouzkoura
EL MAHDI Bouzkoura

Reputation: 445

How do I show only years on flowbite datepicker

I want the user to select only the year from flowbite-datepicker

But I don't know how do that. I tried to add the datepicker-format attribute with the value yyyy like this:

<div id="date-range-picker" date-rangepicker datepicker-format="yyyy"
class="w-full flex items-center">

but it is still show me the full calender, when a date selected it takes the year only.

Upvotes: 0

Views: 315

Answers (1)

EL MAHDI Bouzkoura
EL MAHDI Bouzkoura

Reputation: 445

flowbite-datepicker is a fork from the vanillajs-datepicker . I just had to add the pick level option provided on the vanillajs-datepicker docs:

const dateRangePickerEl = document.getElementById("date-range-picker");
    new DateRangePicker(dateRangePickerEl, {
        pickLevel: 2,
    });

The level that the date picker allows to pick. 0:date,1: month or 2:year.

checkout this documentation

Upvotes: 1

Related Questions