A restaurant table booking form built with Bootstrap 6. An always-visible Datepicker calendar sits next to a guest counter, a time select and a seating choice, and a live summary line repeats the booking before the guest confirms. It also fits salons, studios and tours.
How it works
The root .bkf-root holds a two-column .bkf-grid. The left column wraps the calendar in .bkf-cal. The script creates the Bootstrap 6 Datepicker on the inner [data-bkf-calendar] element with inline: true, so no popup is needed. All dates are computed from today: dateMin is today, dateMax is today plus data-bkf-days-ahead, and the first open day two days from now is preselected. The weekday in data-bkf-closed (1 = Monday) is passed to Vanilla Calendar Pro as disableWeekdays, which greys out every Monday.
When a date is clicked, the Datepicker fires change.bs.datepicker. The handler writes the ISO date into the hidden .bkf-date-value input, calls markFullSlots() and refreshes .bkf-summary-text. markFullSlots() is demo logic that disables a few options in the .bkf-time select per date and labels them "fully booked". If the chosen time is taken, the next free slot is selected.
The guest field is an .input-group with two .bkf-step buttons. setGuests() clamps the value between data-bkf-min and data-bkf-max on .bkf-guests and disables the button at each limit. Seating uses Bootstrap 6 radio toggle buttons (label.btn-check with the input inside).
The form has data-bs-validate novalidate, so Bootstrap 6 shows .invalid-feedback through :user-invalid without extra JavaScript. On submit the script checks for a date, focuses the first invalid field, then shows a spinner, waits briefly and reveals .bkf-success with a confirmation code.
Customization
--bkf-brandand--bkf-brand-darkon.bkf-root: change the terracotta accent. The scoped--bs-primary-*overrides pass it to the buttons, the seating toggles and the selected calendar day.data-bkf-days-aheadon[data-bkf-calendar]: how far ahead guests can book (60 days by default).data-bkf-closedon[data-bkf-calendar]: the closed weekday (0 = Sunday … 6 = Saturday). Leave it empty to allow every day.data-bkf-min/data-bkf-maxon.bkf-guests: party size limits for the stepper.- Edit the
<optgroup>blocks in.bkf-timeto set your lunch and dinner slots. - Replace
markFullSlots()with real availability from your booking API. - Replace the
setTimeoutin the submit handler withfetch()to postnew FormData(form).
Use cases
- Restaurants and cafes: guests choose a date within the next 60 days and a party size
- Table reservations: a time select marks booked slots so they cannot be picked
- Event venues: a live summary repeats the date, time and guests before booking
- Spa and salon bookings: an inline calendar and stepper keep the whole form on one screen
Accessibility
The calendar box is a labelled role="group", and the day buttons come from Vanilla Calendar Pro with full date aria-labels. Fields have real labels, the stepper buttons have aria-labels, and seating is a fieldset with a legend. The summary is an aria-live="polite" region, and the success alert has role="status". Focus rings use the brand color.
Bootstrap 6 notes
The Datepicker is new in Bootstrap 6, and the bundle includes Vanilla Calendar Pro. form-select is gone, so the time picker is a select.form-control. mb-3 wrappers become .form-field, btn-primary becomes btn-solid theme-primary, and radio buttons use label.btn-check. Built on 6.0.0-alpha.1, so the APIs can still change. Icons come from Bootstrap Icons.