CreditCard

A live, flippable card visual — front number/name/expiry, back magstripe/CVC — with automatic network detection. Powers `CreditCardInput`'s preview but also usable standalone to just display a card.

html
<UiCreditCard />

Number

number is the card number, and the only prop the card reads for itself: the network is detected from it on every render, which is what sets the digit grouping, the logo and the expected CVC length. Spacing in the string doesn't matter — grouping is derived from the digits, so raw and pre-formatted values both come out right.

Visa

4242 4242 4242 4242

NameAda Lovelace
Valid Thru12/29
•••

Mastercard

5555 5555 5555 4444

NameGrace Hopper
Valid Thru08/28
•••

American Express

3782 822463 10005

NameAlan Turing
Valid Thru03/27
••••

Discover

6011 1111 1111 1117

NameKatherine Johnson
Valid Thru05/30
•••

Diners Club

Diners Club

3056 930902 5904

NameMargaret Hamilton
Valid Thru11/26
•••
Diners Club

JCB

JCB

3566 0020 2036 0505

NameHedy Lamarr
Valid Thru09/29
•••
JCB

UnionPay

UnionPay

6212 3456 7890 1232

NameRadia Perlman
Valid Thru01/28
•••
UnionPay

Purely a display component — number/name/expiry/cvc are plain strings with no formatting/validation of their own; pass already-formatted values (or raw digits, which still group correctly since grouping is derived from number regardless of spacing).

The card network is detected fresh from number on every render via exported detectCardBrand() — there's no separate brand prop, so an Amex-prefixed number automatically gets 4-6-5 grouping and a 4-digit cvc placeholder even when used standalone.

Name

name is the cardholder, printed on the front exactly as you pass it — there's no upper-casing or truncation of its own. Left empty it falls back to a “Your Name” placeholder, so a card being filled in live still looks like a card.

4242 4242 4242 4242

NameYour Name
Valid Thru12/29
•••

4242 4242 4242 4242

NameAda Lovelace
Valid Thru12/29
•••

Expiry

expiry is the expiry date and is expected already formatted as MM/YY — the card prints the string rather than parsing it. Omitted, it shows an MM/YY placeholder in the same slot.

4242 4242 4242 4242

NameAda Lovelace
Valid ThruMM/YY
•••

4242 4242 4242 4242

NameAda Lovelace
Valid Thru12/29
•••

CVC

cvc is printed on the back of the card, so it only becomes visible once flipped is set. It's padded with placeholders up to the length the detected brand expects — four for Amex, three for everything else.

4242 4242 4242 4242

NameAda Lovelace
Valid Thru12/29
123

Digits/CVC beyond what's actually passed are padded with placeholders up to the detected brand's full length — an empty number renders as a full row of dots rather than nothing, so the card always looks like a card.

Flipped

flipped turns the card over to its back face — magnetic stripe and cvc instead of number, name and expiry. It's an ordinary boolean rather than internal state, so the card never flips on its own: drive it from a button, or from a CVC field's focus the way CreditCardInput does.

4242 4242 4242 4242

NameAda Lovelace
Valid Thru12/29
123

flipped is a plain boolean prop, not internal state — animate it yourself (e.g. on a button click, or CreditCardInput's CVC focus/blur) rather than expecting a built-in trigger.

The flip is a real CSS 3D transform (perspective/transform-style: preserve-3d/backface-visibility) on a fixed-aspect-ratio (85.6/54, the ISO/IEC 7810 ID-1 card ratio) box, not a cross-fade — expect the edge-on skew mid-transition if you screenshot during the 500ms animation.

Empty state — every prop omitted

•••• •••• •••• ••••

NameYour Name
Valid ThruMM/YY
•••

API Reference

Generated from the component's source — props, slots and emits as the component actually declares them.

Props

Prop
Type
Default
Description
string
''
The card number. Digits beyond what's typed are shown as `•` placeholders, padded out to the detected brand's full length.
string
''
The cardholder's name, rendered as typed. Shows a 'Your Name' placeholder when empty.
string
''
The expiry date, expected as 'MM/YY'. Shows a 'MM/YY' placeholder when empty.
string
''
The card security code, shown on the back face. Padded with `•` placeholders up to the detected brand's CVC length.
boolean
false
Shows the back face (magnetic stripe and CVC) via a 3D flip instead of the front.

Types

ts
type CardBrand = "visa" | "mastercard" | "amex" | "discover" | "dinersclub" | "jcb" | "unionpay" | "unknown";