Relative Date Input

Relative Date Input is a copy-paste React component that stops next friday lands on the wrong day 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/relative-date-input
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 3 extra npm packages
  • A11y guidance in docs

StopsNext Friday lands on the wrong day

Was this component page useful?

How do I install Relative Date Input?

pnpm dlx shadcn@latest add @bollard/relative-date-input

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

How do I use Relative Date Input in React?

relative-date-input-usage.tsx
import { RelativeDateInput } from "@/components/ui/relative-date-input"

<RelativeDateInput label="Invoice due" today={TODAY} expect="future" defaultValue="next Friday" onDateChange={setDue} />

What input mistakes does Relative Date Input catch?

  • Phrases with two honest readings (next/this weekday, next weekend early in the week)
  • Day-of-month that has already passed ("the 10th")
  • Read-back of the resolved date with its relative distance
  • One-tap rewrite of the field to an unambiguous date

What props does Relative Date Input accept?

RelativeDateInput props
PropTypeDefault
label

Visible label.

string"Date"
value

Controlled text.

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called with the field's text.

(value: string) => void—
onDateChange

Called with `YYYY-MM-DD`, or null while the text is unreadable or still ambiguous.

(date: string | null) => void—
today

"Today" as `YYYY-MM-DD`. Defaults to the device's date once mounted.

string—
weekStartsOn

First day of the week: 1 = Monday, 0 = Sunday. Decides what "this week" covers.

Day1
expect

Only future (bookings, deadlines) or only past (expenses) dates make sense here.

"future" | "past"—
locale

BCP 47 locale for the read-back.

string"en-GB"
messages

Override any text (see `RELATIVE_DATE_MESSAGES`).

Partial<RelativeDateMessages>—

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

How is Relative Date Input accessible?

  • Visible <label> on the input; aria-invalid and status via aria-describedby
  • Two readings form a roving-tabindex radiogroup operated with arrow keys
  • Read-back renders in a polite live region
  • Animations respect reduced motion (useReducedMotion)
  • After the rewrite, focus returns to the input

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

What are the limitations and server boundaries?

  • English phrases only; other languages are not parsed
  • Uses the today you pass (or the device clock) and its time zone
  • Covers common everyday phrases, not every natural-language form

What expensive mistakes does Relative Date Input stop?

Next Friday lands on the wrong day

Also known as

natural language date · relative date · next friday · due date · chrono · date-fns · reminder · task due

Field type

What dependencies does Relative Date Input require?

Relative Date Input facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameRelative Date Input
Registry identifier@bollard/relative-date-input
Install commandnpx shadcn@latest add @bollard/relative-date-input
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, date-fns, motion
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 Relative Date Input

How does Relative Date Input handle date and time accuracy?

Relative Date Input catches next Friday lands on the wrong day. Validates calendar constraints: Phrases with two honest readings (next/this weekday, next weekend early in the week), Day-of-month that has already passed ("the 10th"), Read-back of the resolved date with its relative distance, One-tap rewrite of the field to an unambiguous date. Limitation: match relative-date-input with server timezone.

How do I install relative-date-input with shadcn?

Run `npx shadcn@latest add @bollard/relative-date-input`. Sources added: registry/default/relative-date-input/relative-date-input.tsx, registry/default/relative-date-input/relative-date.ts. Package requirements: lucide-react, date-fns, motion.

What props customize Relative Date Input?

Relative Date Input accepts `label`, `value`, `defaultValue`, `onValueChange`, `onDateChange`. Configures natural language date, relative date, next friday behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of relative-date-input?

English phrases only; other languages are not parsed. Uses the today you pass (or the device clock) and its time zone. Covers common everyday phrases, not every natural-language form Server requirement: backend verification for relative-date-input.

How does Relative Date Input meet accessibility guidelines?

Visible <label> on the input; aria-invalid and status via aria-describedby. Two readings form a roving-tabindex radiogroup operated with arrow keys. Read-back renders in a polite live region. Animations respect reduced motion (useReducedMotion). After the rewrite, focus returns to the input. Minimizes errors: next friday ambiguous, natural language date.

Which components pair with Relative Date Input?