Credit Card Input
Card number, expiry and CVC with brand detection and Luhn validation.
Import
import { CreditCardInput } from "@cronus-ui/ui";
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.
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">
| Prop | Type | Default | Description |
|---|---|---|---|
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 | boolean | false | Forces the invalid styling and sets `aria-invalid` on every field. |
disabled | boolean | false | Disables 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
| Prop | Type | Default | Description |
|---|---|---|---|
number* | string | — | — |
expiry* | string | — | — |
cvc* | (digits: number) => string | — | — |
brand* | (name: string) => string | — | — |