A dark cabin-booking bar that uses the Bootstrap 6 Datepicker in range mode. One two-month calendar fills both the check-in and check-out fields. The bar also counts nights, has a guest stepper and works out the total price before a simulated reservation. It fits hotel, rental or campsite pages.
How it works
The trigger is a <button class="drp-trigger"> with data-bs-toggle="datepicker", data-bs-selection-mode="multiple-ranged" and data-bs-display-element="false", so Bootstrap does not overwrite its two .drp-half blocks. script.js imports Datepicker from the Bootstrap 6 bundle and creates the instance with:
displayMonthsCount: 2 on screens 640px and wider, 1 on phones.dateMin(today) anddateMax(one year ahead), computed when the page loads.selectedDates: a sample stay from 7 to 11 days ahead, passed as two separate ISO dates. The range string format crashes in alpha.1.vcpOptions.styles.calendar: adds thedrp-calclass. Bootstrap attaches the popup to<body>, so this class is the only way to theme it.
The trigger's change.bs.datepicker event passes the selected dates. render() sorts them, writes the first into .drp-in and the last into .drp-out, and counts the nights. It then prints rate × nights + cleaning fee in .drp-total. After one click only check-in is set and the summary asks for the check-out day. The calendar closes by itself once both ends are chosen. The guest stepper clamps between 1 and 4, disabling the buttons at the limits. Reserve without a full range reopens the calendar; with one it shows a spinner, then the .drp-done alert. Swap that setTimeout for a fetch() call.
Customization
data-drp-rateanddata-drp-feeon.drp-root: the nightly rate and the one-off cleaning fee used in the total.currency: 'USD'in themoneyformatter inscript.js: change it to'EUR','GBP'and so on.maxGuestsinscript.js: the upper limit of the guest stepper.- Remove
data-drp-demo-openfrom.drp-rootin production. It only opens the calendar on page load for the preview. --bs-datepicker-day-selected-bgand the other variables in.drp-cal: popup colors. The[data-vc-date-selected="middle"]rule styles the nights in between.--drp-gold,--drp-nightand--drp-lineon.drp-root: accent, background and border colors.
Use cases
- Cabins and vacation rentals: guests pick check-in and check-out in one two-month calendar
- Hotel booking forms: the picker counts nights and adds a guest count
- Travel sites: the booking card totals the price as the dates change
- Equipment or room reservations: range mode selects a start and end date in a dark calendar
Accessibility
The trigger is a native button, so Enter and Space open the calendar, and its visible text reads the current check-in and check-out. aria-describedby links it to the .drp-summary live region, which announces nights and total price as they change. The guest stepper is a labelled group: its buttons have aria-labels, and the <output> count is announced politely. The .drp-done alert uses role="status". Focus outlines use the gold accent on the dark background.
Bootstrap 6 notes
Bootstrap 5 needed a third-party range picker. Bootstrap 6 includes Datepicker with multiple-ranged selection and a multi-month view. Buttons use btn-solid theme-warning and btn-icon btn-subtle theme-secondary instead of btn-warning, and the success message is alert theme-success. The block is pinned to dark mode with data-bs-theme="dark", and the popup inherits it. Built on 6.0.0-alpha.1, so the Datepicker options may still change. Icons come from Bootstrap Icons.