Credit Card

A visual credit card component with 13 style variants, optional scaling, and a card-network detection utility.

Credits

This component was designed by Untitled UI. I just made it compatible with UI Thing.

Source code

Click to see the source code for this component on GitHub. Feel free to copy it and adjust it for your own use.

Installation

Usage

Import getCardType alongside the component when you need to detect the card network from a number entered by the user.

import { getCardType } from "~/components/Ui/CreditCard.vue";

const network = getCardType("4111 1111 1111 1111"); // "visa"

Variants

Normal

UI Thing.

JOHN DOE

06/36

1234 1234 1234 1234
UI Thing.

JOHN DOE

06/36

1234 1234 1234 1234
UI Thing.

JOHN DOE

06/36

1234 1234 1234 1234
UI Thing.

JOHN DOE

06/36

1234 1234 1234 1234
UI Thing.

JOHN DOE

06/36

1234 1234 1234 1234
UI Thing.

JOHN DOE

06/36

1234 1234 1234 1234

Horizontal Strip

The bottom half of the card becomes a dark strip — common in designs that separate the number area from the brand area.

UI Thing.

JOHN DOE

06/36

1234 1234 1234 1234
UI Thing.

JOHN DOE

06/36

1234 1234 1234 1234
UI Thing.

JOHN DOE

06/36

1234 1234 1234 1234
UI Thing.

JOHN DOE

06/36

1234 1234 1234 1234

Vertical Strip

A dark panel occupies the left portion of the card, leaving a coloured accent stripe on the right.

UI Thing.

JOHN DOE

06/36

1234 1234 1234 1234
UI Thing.

JOHN DOE

06/36

1234 1234 1234 1234
UI Thing.

JOHN DOE

06/36

1234 1234 1234 1234

Scaled

Pass a width prop to scale the card proportionally from its native 316 × 190 px dimensions.

UI Thing.

JOHN DOE

06/36

1234 1234 1234 1234
UI Thing.

JOHN DOE

06/36

1234 1234 1234 1234
UI Thing.

JOHN DOE

06/36

1234 1234 1234 1234

Props

PropTypeDefaultDescription
variantCreditCardVariant"brand-dark"Visual style of the card.
companystring"UI Thing."Brand or company name shown at the top-left.
cardNumberstring"1234 1234 1234 1234"Formatted card number.
cardHolderstring"JOHN DOE"Cardholder name shown in the footer.
cardExpirationstring"06/36"Expiration date shown in the footer.
widthnumberTarget render width in px. The card scales proportionally when provided.
networkIconstringIcon name for the network logo (e.g. "logos:visa"). Falls back to Mastercard based on variant. Overridden by the network-icon slot.
contactlessIconstringIcon name for the contactless symbol. Defaults to "mdi:contactless-payment". Overridden by the contactless-icon slot.
classHTMLAttributes["class"]Extra classes applied to the outer wrapper element.

Slots

SlotDescription
companyReplaces the company name in the top-left corner.
contactless-iconReplaces the contactless symbol in the top-right corner. Takes precedence over contactlessIcon.
card-holderReplaces the cardholder name in the footer.
card-expirationReplaces the expiration date in the footer.
card-numberReplaces the card number in the footer.
network-iconReplaces the network logo in the bottom-right corner. Takes precedence over networkIcon.

Variants reference

VariantStyle
brand-darkSolid primary gradient
brand-lightLight primary tint
gray-darkDark gray gradient
gray-lightLight gray
transparentFrosted-glass (blur + white overlay)
transparent-gradientFrosted-glass with coloured diffuse glows
gray-stripLight gray top, dark strip bottom
gradient-stripBlue→pink gradient top, dark strip bottom
salmon-stripSalmon top, dark strip bottom
transparent-stripFrosted top, dark strip bottom
gray-strip-verticalDark panel left, glass right
gradient-strip-verticalDark panel left, pink→purple gradient right
salmon-strip-verticalDark panel left, salmon right