Skip to content

Date Picker Dropdown

Accessible Tailwind CSS date picker: a text input with a calendar popup, keyboard grid navigation, locale-aware labels and min/max dates.

Also known as: date picker, calendar dropdown, datepicker input, date selection popup, calendar popup input

Date Picker Dropdown live demo

Open in new tab

Tailwind CSS code (HTML, CSS, JS)

A date picker dropdown built with Tailwind CSS and dependency-free JavaScript: a text input with a calendar button that opens a month grid in a popup. It is shown as a delivery scheduler that blocks past days, and works just as well for booking forms, filters, due dates and checkout flows.

How it works

The root is .tdp-datepicker. Inside it, data-tdp-field wraps the #tdp-input text field, the calendar button marked data-tdp-toggle and the hidden #tdp-dialog popup (.tdp-popup). The popup contains previous/next month buttons, a month heading (data-tdp-month), a table role="grid" and the Today and Clear buttons. A readout paragraph (data-tdp-readout) shows the chosen date in long form.

On DOMContentLoaded the script builds the weekday headers and the 6 × 7 day grid with Intl.DateTimeFormat, so month and day names follow the locale. Each day is a button with a full-date aria-label; only the focused day has tabindex="0" (roving tabindex). Today gets aria-current="date" and a ring, the selected day is filled teal, days from neighbouring months are muted and days outside the allowed range are struck through and marked aria-disabled.

Opening the popup moves focus to the selected date (or today). Clicking a day, pressing Enter or Space, or choosing Today writes an ISO value such as 2026-10-15 into the input, updates the readout and closes the popup. Typed values are parsed on change; invalid or out-of-range dates set aria-invalid="true", turn the field ring red through .tdp-control:has([aria-invalid="true"]) and explain the problem in the readout. A pointerdown listener closes the popup when you click elsewhere.

Customization

  • data-tdp-week-start on .tdp-datepicker: 1 starts weeks on Monday, 0 on Sunday.
  • data-tdp-locale: any BCP 47 tag such as de-DE or fr-FR translates month names, weekday letters and labels.
  • data-tdp-min and data-tdp-max: an ISO date or today; remove data-tdp-min="today" to allow past dates.
  • DAY_SELECTED, DAY_TODAY and the other class strings at the top of script.js: restyle the day states, for example square cells with rounded-lg.
  • The teal utilities in index.html (bg-teal-600, ring-teal-600): swap for indigo or orange to rebrand.
  • sm:w-80 on .tdp-popup: widen the calendar, or add right-0 and remove left-0 to align it to the button.

Use cases

  • Delivery scheduling: past days are blocked so customers only choose valid dates
  • Booking forms: a text input with a calendar button opens a month grid in a popup
  • Filters: use min and max dates to limit reports to an allowed range
  • Due dates and checkout flows: navigate the day grid with the keyboard and locale-aware labels

Accessibility

The toggle uses aria-haspopup="dialog", aria-controls and aria-expanded. The popup is a role="dialog" with aria-modal="true", labelled by the live month heading so month changes are announced. Arrow keys move by day and week, Home and End jump to the week edges, Page Up and Page Down change month (with Shift: year), Escape closes and returns focus to the button, and Tab cycles inside the popup. Alt + Arrow Down opens the calendar from the input. Each day reads as its full date, and the entrance animation is removed under prefers-reduced-motion: reduce.

Usage notes

For several pickers on one page, give each input, dialog and month heading unique id values and update for, aria-controls and aria-labelledby.

Date Picker Dropdown at a glance

Framework
Tailwind CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Tailwind CSS
Layout
Responsive, works on mobile
Category
Date Pickers
License
Free for personal and commercial use

Questions about this template

Can I use the Date Picker Dropdown code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Tailwind CSS from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

The Tailwind browser build is for prototyping. In production, compile Tailwind with its CLI or your bundler.

Date Picker Dropdown – free Tailwind CSS date picker template
Date Picker Dropdown · free Tailwind CSS date picker template

More Date Pickers

Booking Form with Datepicker – free Bootstrap 6 date picker template

Booking Form with Datepicker

Bootstrap 6 restaurant booking form with an inline Datepicker limited to the next 60 days, a guest stepper, a time select with booked slots and a live summary.

Inline Calendar Datepicker – free Bootstrap 6 date picker template

Inline Calendar Datepicker

Always-visible Bootstrap 6 inline Datepicker for booking a consultation, with closed weekends, fully booked days, a preselected date and time slots for the chosen day.

Date Range Picker – free Bootstrap 6 date picker template

Date Range Picker

Dark Bootstrap 6 Datepicker in range mode for cabin bookings: a two-month calendar fills check-in and check-out, counts nights, adds guests and totals the price.

Datepicker Input – free Bootstrap 6 date picker template

Datepicker Input

Bootstrap 6 Datepicker on a delivery form input with min and max dates relative to today, closed Sundays, a time-window picker, validation and a simulated booking.