Pick a day, then a time. The grid is rendered on the server, days and times are native radio inputs, months switch through hidden radios and :checked, and the times of the chosen day appear through a sibling selector. Inside a <form> the choice is sent as date and time with no JavaScript at all. A small client island loads only when you pass onBook or onDateChange: it runs the callback, shows the pending state and clears a time left over from another day.
Browser Support
Styles elements based on their contents
Adapts the layout to container width
Colors the day cell focus ring
Preview
Keyboard: Tab reaches the month switch, the days and the times; arrows move inside each group like any radio buttons.
November 2026
Pick a highlighted day to see free times.
December 2026
Pick a highlighted day to see free times.
January 2027
Pick a highlighted day to see free times.
Installation
Usage
"use client"
import { BookingCalendar } from "@/components/ui/booking-calendar"
const slots = {
"2026-03-16": ["09:00", "10:30", "14:00"],
"2026-03-17": ["12:00", "15:30"],
}
export default function Example() {
return (
<BookingCalendar
slots={slots}
minDate={new Date()}
onBook={async (date, time) => {
await fetch("/api/book", {
method: "POST",
body: JSON.stringify({ date, time }),
})
}}
/>
)
}Examples
In a form, without JavaScript
Without onBook the calendar is a pure server component. Put it in a <form>: the Book button submits it and FormData gets date and time. Rename the fields with name and timeName.
// Server Component, no client JavaScript
<form action={bookAction}>
<BookingCalendar slots={slots} minDate={new Date()} />
</form>
async function bookAction(formData: FormData) {
"use server"
const date = formData.get("date") // "2026-03-16"
const time = formData.get("time") // "10:30"
}Week starts on Sunday
weekStartsOn takes 0 for Sunday through 6 for Saturday. The default is Monday.
November 2026
Pick a highlighted day to see free times.
December 2026
Pick a highlighted day to see free times.
January 2027
Pick a highlighted day to see free times.
<BookingCalendar slots={slots} locale="en-US" weekStartsOn={0} />Limited range
minDate and maxDate limit both the grid and the month buttons. In a narrow container the times panel moves under the grid.
November 2026
Pick a highlighted day to see free times.
December 2026
Pick a highlighted day to see free times.
const today = new Date()
const inTwoWeeks = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 14)
<BookingCalendar
className="max-w-sm"
slots={slots}
minDate={today}
maxDate={inTwoWeeks}
note="Booking is open for the next two weeks"
/>Async booking and errors
onBook may return a promise. While it is pending the button is locked and shows a spinner. If the promise rejects, the error label is shown and the selected time stays.
November 2026
Pick a highlighted day to see free times.
December 2026
Pick a highlighted day to see free times.
<BookingCalendar
slots={slots}
labels={{ error: "This time was just taken. Pick another one." }}
onBook={async (date, time) => {
const res = await fetch("/api/book", {
method: "POST",
body: JSON.stringify({ date, time }),
})
if (!res.ok) throw new Error("Slot taken")
}}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| slots | Record<string, string[]> | - | Free times keyed by day in "YYYY-MM-DD" format |
| onBook | (date, time) => void | Promise<void> | - | Called with the chosen day and time, may be async. Loads the client island |
| onDateChange | (date: string) => void | - | Called when the selected day changes. Loads the client island |
| name | string | "date" | Form field name of the day |
| timeName | string | "time" | Form field name of the time |
| locale | string | "en-US" | Locale for month and weekday names |
| weekStartsOn | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 1 | First day of the week, 0 is Sunday |
| minDate | string | Date | - | Earliest bookable day |
| maxDate | string | Date | - | Latest bookable day |
| defaultDate | string | - | Day selected on first render |
| formatTime | (time: string) => string | - | Formats a time string for display |
| note | ReactNode | - | Small note under the times heading, e.g. a time zone |
| labels | Partial<BookingCalendarLabels> | - | Overrides for every built-in text |
| className | string | - | Additional CSS classes |
Features
- No JavaScript: the grid, month switch, day and time choice work in a Server Component
- Native form: date and time go to FormData through name and timeName
- Native keyboard: months, days and times are radio groups: one Tab stop each, arrows inside
- Pending state: the island locks the button while onBook runs
- Animation: CSS transitions respect reduced-motion preferences
- Container queries: the layout reacts to the card width, not the viewport
- Any locale: names and full dates for screen readers come from Intl