Range Pair

Range Pair is a copy-paste React component that stops backwards date or price range before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/range-pair
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsBackwards date or price range

Was this component page useful?

How do I install Range Pair?

pnpm dlx shadcn@latest add @bollard/range-pair

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

How do I use Range Pair in React?

range-pair-usage.tsx
import { RangePair } from "@/components/ui/range-pair"

<RangePair kind="date" label="Trip dates" maxSpan={60} defaultValue={{ from: "2026-12-28", to: "2026-01-03" }} />

What input mistakes does Range Pair catch?

  • Reversed ends, with the likelier repair (next year for Dec → Jan)
  • Empty ranges when the end is exclusive
  • Oversized ranges from a year or extra-zero typo (maxSpan)
  • Plain swap as an alternative fix

What props does Range Pair accept?

RangePair props
PropTypeDefault
kind

Numbers or dates.

RangeKind"number"
label

Legend for the pair.

string—
fromLabel

Labels of the two ends. Default "Min"/"Max" for numbers, "From"/"To" for dates.

stringkind === "date" ? "From" : "Min"
toLabel

Label for the end of the range.

stringkind === "date" ? "To" : "Max"
value

Controlled ends.

RangeValue—
defaultValue

Initial ends when uncontrolled.

RangeValue{ from: "", to: "" }
onValueChange

Called whenever either end changes.

(value: RangeValue) => void—
maxSpan

Spans above this (days for dates) get a "longer than expected" warning.

number—
exclusiveEnd

The end is not part of the range (hotel nights, `[from, to)`), so equal ends mean it's empty.

booleanfalse
locale

BCP 47 locale for numbers and dates.

string"en-IN"
delay

Pause in ms before checking while typing.

number700
reversedMessage

Shown when the ends are reversed.

stringkind === "date" ? "This ends before it starts." : "The ma…
emptyMessage

Shown when an exclusive range is empty.

string"Both ends are the same, so nothing falls in this range."
hugeMessage

Receives the formatted span, e.g. "1 year 31 days" or "49,500".

(span: string) => string(span) => `That's ${span}, longer than expected.`
swapLabel

Button text to swap the ends.

string"Swap"
fixLabel

Fix button text; receives which end changes and its formatted new value.

(side: "from" | "to", value: string) => string(side, v) => (kind === "date" ? `${side === "to" ? "End" …
spanText

Readback of the span; receives it formatted.

(span: string) => string(span) => (kind === "date" ? span : `Range of ${span}`)

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

How is Range Pair accessible?

  • Both ends have visible labels and are described by a polite status region
  • Fix and swap are buttons; icons are aria-hidden
  • Focus returns to the From field after a fix

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

What are the limitations and server boundaries?

  • Dates are YYYY-MM-DD in UTC; times of day aren't handled
  • maxSpan has to be set for size checks to mean anything

What expensive mistakes does Range Pair stop?

Backwards date or price range

Also known as

date range · min max · price range · from to · filter · check in check out · range picker · start end

What dependencies does Range Pair require?

Range Pair facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameRange Pair
Registry identifier@bollard/range-pair
Install commandnpx shadcn@latest add @bollard/range-pair
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Range Pair

How does Range Pair handle date and time accuracy?

Range Pair catches backwards date or price range. Validates calendar constraints: Reversed ends, with the likelier repair (next year for Dec → Jan), Empty ranges when the end is exclusive, Oversized ranges from a year or extra-zero typo (maxSpan), Plain swap as an alternative fix. Limitation: match range-pair with server timezone.

How do I install range-pair with shadcn?

Run `npx shadcn@latest add @bollard/range-pair`. Sources added: registry/default/range-pair/range-pair.tsx. Package requirements: lucide-react.

What props customize Range Pair?

Range Pair accepts `kind`, `label`, `fromLabel`, `toLabel`, `value`. Configures date range, min max, price range behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of range-pair?

Dates are YYYY-MM-DD in UTC; times of day aren't handled. maxSpan has to be set for size checks to mean anything Server requirement: backend verification for range-pair.

How does Range Pair meet accessibility guidelines?

Both ends have visible labels and are described by a polite status region. Fix and swap are buttons; icons are aria-hidden. Focus returns to the From field after a fix. Minimizes errors: end date before start, min greater than max.

Which components pair with Range Pair?