Skip to content

Card Field

Pro

Take a card number, expiry date, and security code in one row. The brand sets the groups and the code length, and one line names the first problem.

  • 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 Field 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
36
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.

Import Card Field and compose its parts.

card-field.tsx

CardField

<fieldset>
PropTypeDefaultDescription
disabledbooleanfalse
valueCardValue—The three parts as shown (controlled). Raw digits are formatted: "0829" shows "08/29".
defaultValuePartial<CardValue>—The three parts at first (uncontrolled).
onValueChange—Runs on every change with the shown parts and the details (brand, raw parts, problems).
nowDisplayNow—"Now" for the expiry check (tests, stories). Default: the time the field mounts.
labels—The words (CARD_LABELS): the accessible names of the three inputs and the error texts, to translate them. {length} in cvcIncomplete is the code length of the brand.
placeholdersPartial<Record<CardPart, string>>—
readOnlybooleanfalse
showErrorsbooleanfalseShow the problems of every part now, as after a submit (a declined payment, a server check).
...props<fieldset> attributes—Every other attribute goes to the <fieldset>, with a ref.

CardFieldLabel

<label>
PropTypeDefaultDescription
...props<label> attributes—Every other attribute goes to the <label>, with a ref.

CardFieldGroup

<div>
PropTypeDefaultDescription
rounded"default""full"—
size"default""lg""sm""xs"—
variant"dashed""default"—
classNamestring—
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

CardFieldBrand

<div>
PropTypeDefaultDescription
classNamestring—
align"block-end""block-start""inline-end""inline-start"—
children—Your own mark (a logo set of your own) in place of the badge; a function gets the brand.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

CardFieldNumber

<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>.

CardFieldExpiry

<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>.

CardFieldCvc

<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>.

CardFieldError

<p>
PropTypeDefaultDescription
...props<p> attributes—Every other attribute goes to the <p>, with a ref.
  • Use it when the card number, the expiry, and the code belong together, as in a checkout.
  • Use showErrors after a submit or a decline, so every problem shows at once.
  • Use labels to translate the input names and the error texts.
TabMoves between the number, the expiry, and the code.
BackspaceIn an empty expiry or code, moves to the end of the part before it.

The parts are native inputs in a fieldset, each with its own name (labels translates them).

Each input has its autocomplete value (cc-number, cc-exp, cc-csc), so the browser can fill the card.

The error line names the first problem, and the input with the problem is marked invalid.

Brand badge
popup · 150ms · ease-panel (0.2, 0.4, 0.2, 1) · a new brand badge fades in and scales from 90%

Built with

Installs with Card Field

  1. AddedCard Field, with Card Brand, Input Group, Masked Input.
Open the release