Skip to content

Card Code Input

Pro

A field for the card security code: 3 digits, or 4 for American Express. An optional card mark shows where the code is on the card.

  • 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 Code 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
23
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 Code Input and compose its parts.

card-code-input.tsx

CardCodeInput

<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 code shows and can be copied, but not changed (the Base UI name).
valuestring—The shown code (controlled).
defaultValuestring""The first shown code (uncontrolled).
onValueChange—Runs on every change with the digits and the checks.
brandnull"amex""diners""discover""elo""hipercard""jcb""maestro""mastercard""mir""rupay""troy""unionpay""verve""visa"nullThe brand of the card number: Amex takes 4 digits, printed on the front.
length34—A fixed length, when you do not know the brand. Wins over brand.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

CardCodeInputControl

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

CardCodeInputHint

<div>
PropTypeDefaultDescription
classNamestring—
...props<div> attributes—Every other attribute goes to the <div>, with a ref.
  • Use it when the code has its own label, next to the number and the expiry.
  • Pass brand from the card number, so the length follows it.
  • Add CardCodeInputHint to show where the code is printed.
  • For the number, expiry, and code in one frame, use a Card Field.
  • For a one-time code from a text message, use an Input OTP.

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

The hint is decorative. The words in the help text tell where the code is.

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

Built with

Installs with Card Code Input

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