Guest Count Picker

Asks each child's age and checks the room split, so a hotel booking isn't bounced for an over-age child, a lone infant or an over-full room.

StopsHotel booking bounced over guests

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/guest-count-picker.json

The files land in your project. They're yours to edit.

Usage

guest-count-picker-usage.tsx
import { GuestCountPicker, type GuestIssue } from "@/components/ui/guest-count-picker"

<GuestCountPicker
  aria-label="Guests"
  limits={{ maxChildAge: 12, maxPerRoom: 3 }}
  defaultValue={{ adults: 3, childAges: [13, 6], infants: 1, rooms: [{ adults: 3, children: 1, infants: 1 }, { adults: 0, children: 1, infants: 0 }] }}
  onIssuesChange={setIssues}
/>

What it catches

  • Child older than the hotel's child age limit
  • Child young enough to count as a free infant
  • Infant or child in a room with no adult
  • Room over capacity or more infants than cots
  • Room split that doesn't add up to the party

Props

GuestCountPicker props
PropTypeDefault
value

Controlled value.

GuestValue—
defaultValue

Initial value when uncontrolled. Defaults to 2 adults in 1 room.

Partial<GuestValue>—
onValueChange

Called with a clean value on every change.

(value: GuestValue) => void—
onIssuesChange

Called whenever the list of problems changes, so you can hold the Book button.

(issues: GuestIssue[]) => void—
limits

The property's age and room rules.

GuestLimits—
maxGuests

Most guests of each kind in the party. Default 16.

number16
messages

Every visible string.

Partial<GuestCountMessages>—

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Each counter is a spinbutton with min, max and now values, labelled, and works with arrow keys
  • The +/- buttons have aria-labels and are skipped in tab order (keyboard uses the spinbutton)
  • Age selects are labelled, with aria-invalid until chosen
  • Room split uses table roles with row and column headers

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

  • Defaults (child to 17, infant under 2, 4 per room, 1 cot) are typical, not any hotel's policy; pass your property's limits
  • Does not check live availability or pricing

What it stops

Hotel booking bounced over guests

Also known as

guests · rooms · adults children · hotel booking · occupancy · travellers · child age · booking widget

Field type

Dependencies

Pairs well with