Skip to content
Forms

Credit Card Input

Card number, expiry and CVC with brand detection and Luhn validation.

Import

tsx
import { CreditCardInput } from "@cronus-ui/ui";
bash
npx cronus-ui add credit-card-input

Examples

.cronus

The same component declared in Cronus. Emitted at build time from the audit fixtures — the kernel renders it as HTML with no React.

PortedParity: MatchGeometry 1/1Pixel diff 0 pxLogic 1/1Parity scoreboard
default.cronus
app "audit-fixtures" {
  port 5176
}

style {
  preset aurora
  theme dark
}

component CreditCardInputDefault layout:inline style:credit-card-input {
  value:"4242424242424242"
  label "Credit card"
}

page "/audit/credit-card-input/default" type:custom {
  use CreditCardInputDefault
}

API Reference

Generated from the component's exported types.

CreditCardInputProps

Extends Omit<HTMLAttributes<HTMLDivElement>, "onChange">

Skip CreditCardInputProps props table
PropTypeDefaultDescription
label
string"Credit card"Accessible group label announced to assistive tech.
defaultNumber
string—Uncontrolled initial card number (digits or already-spaced).
onValueChange
(value: CreditCardValue) => void—Fires on every keystroke with the parsed, validated card value. Display-side only — do not persist, log, or transmit the raw PAN/CVC.
onChange
(value: CreditCardValue) => void—Called when the value changes.
invalid
booleanfalseForces the invalid styling and sets `aria-invalid` on every field.
disabled
booleanfalseDisables all three fields.
error
string—Optional error message rendered under the group with `role="alert"`.
labels
Partial<CreditCardInputLabels>—Override default English strings.
className
string—Additional class names merged onto the root.
children
ReactNode—Contents of the component.
id
string—DOM id of the root element.

CreditCardInputLabels

Skip CreditCardInputLabels props table
PropTypeDefaultDescription
number*
string——
expiry*
string——
cvc*
(digits: number) => string——
brand*
(name: string) => string——