Skip to content

Card Expiry Input

Pro

A field for the card expiry date as MM/YY. It accepts months 01 to 12, fixes pasted dates, and marks a card that has expired.

  • React 19
  • Tailwind CSS 4

Added Nov 9, 2026 · Pro license

Playground

Loading the preview

Props

Needs your Pro API key in GELATIN_UI_PRO_TOKEN. Set it up

Pro itemAPI key required

Card Expiry Input needs a Pro API key

Try the live preview for free. With Pro, the add command above puts the source in your project.

Files it adds
24
More Pro items, one API key
+327
Your coding agent runs it
1 cmd

$79$129once, for life

Already have Pro? Sign in to set up your API key.

Put the input in a Field with a label and an error; details.expired tells you when to show the error.

The sample also uses Field. One command adds them with this item:

card-expiry.tsx

CardExpiryInput

<div>
PropTypeDefaultDescription
classNamestring—
rounded"default""full""default"
size"default""lg""sm""xs""default"
variant"dashed""default"—
disabledbooleanfalseTurns the control off; the frame fades to 50% with it (the Base UI name).
readOnlybooleanfalseThe date shows and can be copied, but not changed (the Base UI name).
valuestring—The shown expiry (controlled). "0829" shows "08/29".
defaultValuestring""The first shown expiry (uncontrolled).
onValueChange—Runs on every change with the text, { month, year }, the checks, and expired.
nowDisplayNow—"Now" for the expired check (tests, stories). Default: the display now, else the mount time.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

CardExpiryInputControl

<div>
PropTypeDefaultDescription
classNamestring—
guideboolean—The ghost guide of the slots still to fill, while the input has focus. Default true.
rawNamestring—Also submit the raw value under this name (a hidden input), next to the shown one.
rejectFeedbackboolean—Nudge the field 2px when the mask rejects a key. Default true.
onReject—Runs when the mask rejects a key (a letter in a number, a 13th month).
refRef<HTMLInputElement>—
rounded"default""full"—
size"default""lg""sm""xs"—
...props<div> attributes—Every other attribute goes to the <div>.
  • Use it when the expiry has its own label, next to the number and the code.
  • Use details.expired from onValueChange to say why a full date is not valid.
  • For the number, expiry, and code in one frame, use a Card Field.
  • For a full date with a calendar, use a Date Picker.

It is a native input with autocomplete="cc-exp" and a number keypad.

The "MM/YY" guide shows the slots still to fill while the input has focus.

Rejected key
indicator · the frame moves 2px to each side and back when the mask rejects a key

Built with

Installs with Card Expiry Input

  1. AddedCard Expiry Input, with Input Group, Masked Input.
Open the release