Skip to content

Card Number Input

Pro

A field for a card number. The first digits set the brand badge, the digit groups, and the length, and a checksum finds typing errors.

  • 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 Number 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
28
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 brand badge and the control in the input, inside a Field with a label and an error.

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

card-number.tsx

CardNumberInput

<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 card number shows and can be copied, but not changed (the Base UI name).
valuestring—The shown number (controlled). Raw digits show formatted: "4242424242424242".
defaultValuestring""The first shown number (uncontrolled).
onValueChange—Runs on every change with the shown number, the digits, the checks, and the brand.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

CardNumberInputBrand

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

CardNumberInputControl

<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 number has its own label, as in a checkout with separate fields.
  • Use onValueChange details (brand, complete, valid) to set the code length or show the last four.
  • For the number, expiry, and code in one frame, use a Card Field.
  • For a brand badge with no input, use a Card Brand.

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

The brand badge is decorative. Say the brand in text when it matters.

Brand badge
popup · 150ms · ease-panel (0.2, 0.4, 0.2, 1) · a new brand badge fades in and scales from 90%
Rejected key
indicator · the frame moves 2px to each side and back when the mask rejects a key

Built with

Installs with Card Number Input

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