Stay Length

Reads a date range back as nights and days so bookings and leave requests aren't off by one.

StopsBooked one night too few

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/stay-length.json

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

Usage

stay-length-usage.tsx
import { StayLength } from "@/components/ui/stay-length"

<StayLength defaultValue={{ start: "2026-11-02", end: "2026-11-08" }} />

What it catches

  • End date before start date
  • Nights versus days confusion against the expected count
  • A check-out date entered as the last night
  • Weekend days and holidays inside the range (for leave)

Props

StayLength props
PropTypeDefault
mode

"stay" counts nights between check-in and check-out; "leave" counts the days off, both inclusive.

"stay" | "leave""stay"
value

Controlled range.

DateRange—
defaultValue

Initial range when uncontrolled.

DateRange{ start: "", end: "" }
onValueChange

Called with the date range after every change.

(range: DateRange) => void—
expected

The length the person asked for elsewhere ("7 nights" in search), to catch an off-by-one.

number—
weekend

Week days that aren't working days, 0 = Sunday.

number[][0, 6]
holidays

Public holidays, from your calendar source.

Holiday[][]
locale

Locale for date formatting.

string"en-GB"
startLabel

Label of the start date.

stringmode === "stay" ? "Check-in" : "First day off"
endLabel

Label of the end date.

stringmode === "stay" ? "Check-out" : "Last day off"
messages

Overrides any of the sentences in `STAY_LENGTH_MESSAGES`, e.g. to translate them.

Partial<StayLengthMessages>—

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

Accessibility

  • Start and end inputs have <label>s; aria-invalid on errors
  • Readback in a polite live region via aria-describedby; errors use role=alert
  • Fix and keep are labelled buttons

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

Limitations

  • Works on calendar dates only, never times
  • Holidays are yours to pass; weekend days default to Saturday–Sunday unless you set weekend

What it stops

Booked one night too few

Also known as

date range · check-in check-out · hotel booking · leave request · nights · holidays · date picker · oyo

Field type

Dependencies

Pairs well with