Skip to content

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.

Also known as: date picker input, delivery date picker, datepicker with min max date, date input calendar, time slot picker

Datepicker Input live demo

Open in new tab

Bootstrap 6 code (HTML, CSS, JS)

A delivery scheduling card that attaches the new Bootstrap 6 Datepicker to a text input. Dates before tomorrow and after 45 days are blocked, and Sundays are closed. The card also has a time-window picker, an optional note and a simulated booking. Use it for checkout steps, appointment forms or any input where only some dates are allowed.

How it works

The input .dpi-input sits inside a label.form-control.form-adorn with a calendar icon and carries data-bs-toggle="datepicker". Because the wrapper is a .form-adorn, the popup aligns to the whole field. script.js imports Datepicker from the Bootstrap 6 bundle and creates the instance before the data API does, so the limits apply on the very first open:

  • dateMin and dateMax are computed relative to today from data-dpi-min-days and data-dpi-max-days on .dpi-root, so the demo never shows stale dates. The hint .dpi-range prints the same range.
  • vcpOptions.disableWeekdays takes CLOSED_WEEKDAYS (Sunday) and greys those days out. vcpOptions.styles.calendar adds the dpi-cal class to the popup, which Bootstrap attaches to <body>, so it can be themed.
  • dateFormat shows the choice as "Mon, Nov 2, 2026" in the visitor's locale.
  • With data-dpi-suggest, the first open weekday two days after the minimum is preselected.

The change.bs.datepicker event clears errors. Typed ISO dates such as 2026-11-20 are checked against the same rules and passed to setSelectedDates(). On submit, getSelectedDates() must return a date, otherwise the field gets .dpi-field--invalid and aria-invalid="true". A valid submit shows a spinner, then the .dpi-done success alert. Replace the setTimeout with a fetch() call to your API.

Customization

  • data-dpi-min-days / data-dpi-max-days on .dpi-root: the first and last bookable day, counted from today.
  • CLOSED_WEEKDAYS in script.js: weekday numbers to disable, for example [0, 6] for weekends.
  • Remove data-dpi-demo-open from .dpi-root in production. It only opens the calendar on page load for the preview.
  • Remove data-dpi-suggest to start with an empty field.
  • --bs-datepicker-day-selected-bg and the other variables in .dpi-cal: recolor the popup calendar.
  • --dpi-pine, --dpi-orange and --dpi-cream on .dpi-root: the side panel, accent and text colors.
  • Add or remove time windows by editing the .dpi-slot labels in .dpi-slot-group.

Use cases

  • Delivery and order forms: customers choose a date within a window relative to today
  • Service booking: Sundays are closed and a time-window picker completes the slot
  • Appointment pages: minimum and maximum dates prevent choosing past or distant days
  • Checkout flows: validation and a simulated booking confirm the chosen date

Accessibility

The input has a visible <label> and aria-describedby pointing to the range hint and the error. Errors set aria-invalid and show a text message, not only a red border. Time windows are native radios inside .btn-check labels, so arrow keys move between them. Keyboard users can also type a date instead of using the calendar. The success alert is a polite live region. Disabled days use a strikethrough as well as a lighter color.

Bootstrap 6 notes

Bootstrap 5 had no datepicker. Bootstrap 6 ships one (built on Vanilla Calendar Pro, included in the bundle), so you no longer need a third-party plugin. input-group icons become form-adorn with form-ghost, toggle buttons use <label class="btn-check"> with the input inside, and spinner-border-sm is spinner-sm. Built on 6.0.0-alpha.1. The Datepicker API is new and may still change. Icons come from Bootstrap Icons.

Datepicker Input at a glance

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

Questions about this template

Can I use the Datepicker Input 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 Bootstrap 6 and Bootstrap Icons 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):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@6.0.0-alpha.1/dist/css/bootstrap.min.css">
  • <script type="module" src="https://cdn.jsdelivr.net/npm/bootstrap@6.0.0-alpha.1/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">

Built for Bootstrap 6.0.0-alpha.1. Bootstrap 6 ships as an ES module, so its script and this component's JavaScript load with type="module". Alpha releases can still change before the stable version.

Datepicker Input – free Bootstrap 6 date picker template
Datepicker Input · free Bootstrap 6 date picker template

More Date Pickers

Date Picker Dropdown – free Tailwind CSS date picker template

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.