Card Expiry Input

Card Expiry Input is a copy-paste React component that stops payment declined on card expiry 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/card-expiry-input
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

StopsPayment declined on card expiry

Was this component page useful?

How do I install Card Expiry Input?

pnpm dlx shadcn@latest add @bollard/card-expiry-input

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

How do I use Card Expiry Input in React?

card-expiry-input-usage.tsx
import { CardExpiryInput } from "@/components/ui/card-expiry-input"

<CardExpiryInput label="Expiry date" defaultValue="28/10" today={today} />

What input mistakes does Card Expiry Input catch?

  • Impossible months (13, 00) and the year typed first
  • A four-digit year, and YYYY-MM autofill
  • An expired card
  • A card that expires before the next renewal date you pass
  • Expiries implausibly far in the future (maxYears)

What props does Card Expiry Input accept?

CardExpiryInput props
PropTypeDefault
label

Visible label.

string"Expiry date"
value

Controlled value, as shown (MM/YY).

string—
defaultValue

Initial value when uncontrolled.

string""
onValueChange

Called with the formatted text, plus `{ month, year }` once it is a valid, unexpired date.

(value: string, expiry: { month: number; year: number } | null) => void—
today

"Today" for the expiry checks. Defaults to the visitor's clock, read after mount.

Date—
renewsOn

Next date the saved card will be charged. A card that runs out first gets a warning.

Date—
maxYears

Expiries further out than this many years are flagged as a likely wrong year.

number20
locale

Locale for the dates read back.

string"en-GB"
messages

Override any of the default messages.

Partial<typeof CARD_EXPIRY_MESSAGES>—

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

How is Card Expiry Input accessible?

  • Visible <label>; aria-invalid when invalid and aria-describedby to an aria-live="polite" status
  • Errors use role="alert"
  • Fix buttons have visible text

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

What are the limitations and server boundaries?

  • Checks the date only; the issuer decides whether the card is valid
  • "Today" is the visitor's clock unless you pass `today`

What expensive mistakes does Card Expiry Input stop?

Payment declined on card expiry

Also known as

card expiry · expiry date · mm/yy · credit card · debit card · checkout · payment form · valid thru

Field type

What dependencies does Card Expiry Input require?

Card Expiry Input facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameCard Expiry Input
Registry identifier@bollard/card-expiry-input
Install commandnpx shadcn@latest add @bollard/card-expiry-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
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 Card Expiry Input

How does Card Expiry Input prevent financial transaction errors?

Card Expiry Input prevents payment declined on card expiry. Blocks Impossible months (13, 00) and the year typed first, A four-digit year, and YYYY-MM autofill, An expired card, A card that expires before the next renewal date you pass, Expiries implausibly far in the future (maxYears) before processing. Limitation: apply idempotency keys for card-expiry-input.

How do I install card-expiry-input with shadcn?

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

What props customize Card Expiry Input?

Card Expiry Input accepts `label`, `value`, `defaultValue`, `onValueChange`, `today`. Configures card expiry, expiry date, mm/yy behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of card-expiry-input?

Checks the date only; the issuer decides whether the card is valid. "Today" is the visitor's clock unless you pass `today` Server requirement: backend verification for card-expiry-input.

How does Card Expiry Input meet accessibility guidelines?

Visible <label>; aria-invalid when invalid and aria-describedby to an aria-live="polite" status. Errors use role="alert". Fix buttons have visible text. Minimizes errors: card expiry format mm yy, expired card checkout.

Which components pair with Card Expiry Input?