Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Appointment Booking

ProNew

A booking flow with services, specialists, a day strip or month calendar, time slots, a details form and a confirmation, inline or in a dialog.

Installation

pnpm dlx shadcn@latest add @viewport/appointment-booking

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

<AppointmentBooking>

PropTypeDefault
services*BookingService[]

What can be booked. One service skips the list and opens on the date.

—
staffBookingStaff[]

People to book with. Adds a specialist picker with an "Any available" choice.

—
businessBookingBusiness

Profile card shown beside the form (above it in narrow containers). Leave out for the form only.

—
layout"inline" | "button" | "floating"

`inline` renders in place; `button` and `floating` render a trigger that opens the widget in a dialog.

"inline"
calendar"week" | "month"

`week` is a swipeable strip of days; `month` is a full calendar grid.

"week"
getSlots(date: Date, context: { service: BookingService; staff?: BookingStaff }) => string[] | Promise<string[]>

Returns the free start times ("HH:MM", 24 hour) for a day. May return a promise; a skeleton shows while it resolves and a retry if it rejects. Defaults to Monday to Saturday, 9:00 to 17:00.

defaultSlots
isDateDisabled(date: Date) => boolean

Days that cannot be picked, e.g. `(d) => d.getDay() === 0`. Past days never can.

—
maxDaysnumber

How many days ahead can be booked.

60
onConfirm(booking: Booking) => void | Promise<void>

Called on confirm. Return a promise to show the pending state; reject it to show the error.

—
requiredDetailField[]

Which of name, phone and email must be filled.

["name", "email"]
accentstring

Accent color for the selected day, links and buttons. Any CSS color.

"var(--primary)"
accentForegroundstring

Text color on top of the accent.

"var(--primary-foreground)"
localestring

BCP 47 locale for dates and times.

"en-US"
weekStart0 | 1

First day of the week in the month calendar: 0 is Sunday, 1 is Monday.

0
formatDuration(minutes: number) => string

Formats a length in minutes, e.g. `(m) => `${m} min``.

defaultDuration
labelsPartial<typeof LABELS>

Override any of the built-in strings.

—
triggerClassNamestring

Class for the trigger of the `button` and `floating` layouts, e.g. to reposition it.

—
classNamestring—

<Flow>

PropTypeDefault
text*Labels—
title*React.ReactNode—
onClose() => void—

<Picker>

PropTypeDefault
today*Date—
value*Date—
onChange*(d: Date) => void—
blocked*(d: Date) => boolean—
locale*string"en-US"
text*Labels—

Accessibility

  • The day strip is a radio group and the month grid moves with the arrow keys, Page Up and Page Down; unavailable days are announced as such.
  • Focus moves to each new step, and times load into a polite live region with a named skeleton.
  • Fields keep real labels, mark errors with aria-invalid and a message, and the first invalid field takes focus.
  • The button and floating layouts open a dialog that traps focus and returns it to the trigger.
  • Steps fade without sliding, and the check mark does not draw, under reduced motion.