Credit card components

FREE

Free and open-source React credit card components built for modern applications and websites. These credit cards are built using React Aria and styled with Tailwind CSS.

Untitled.

OLIVIA RHYE

06/28

1234 1234 1234 1234

Installation

You can add this credit card component using our CLI or manually:

npx untitledui@latest add credit-card

Customization

The credit card component has props like type, company, cardNumber, cardHolder, and cardExpiration that can be used to customize the card.

Brex

PEDRO FRANCESCHI

12/28

5678 9012 3456 7890
Apple Inc.

TIM COOK

06/29

0987 6543 2109 8765

Sizes

The credit card component has a width prop that can be used to set the width of the card. Based on the width, the height will be automatically adjusted to maintain the aspect ratio.

Untitled.

OLIVIA RHYE

06/28

1234 1234 1234 1234
Untitled.

OLIVIA RHYE

06/28

1234 1234 1234 1234

Credit card types

Below are examples and variations of the credit card component:

Untitled.

OLIVIA RHYE

06/28

1234 1234 1234 1234
Untitled.

OLIVIA RHYE

06/28

1234 1234 1234 1234
Untitled.

OLIVIA RHYE

06/28

1234 1234 1234 1234
Untitled.

OLIVIA RHYE

06/28

1234 1234 1234 1234
Untitled.

OLIVIA RHYE

06/28

1234 1234 1234 1234
Untitled.

OLIVIA RHYE

06/28

1234 1234 1234 1234
Untitled.

OLIVIA RHYE

06/28

1234 1234 1234 1234
Untitled.

OLIVIA RHYE

06/28

1234 1234 1234 1234
Untitled.

OLIVIA RHYE

06/28

1234 1234 1234 1234
Untitled.

OLIVIA RHYE

06/28

1234 1234 1234 1234
Untitled.

OLIVIA RHYE

06/28

1234 1234 1234 1234
Untitled.

OLIVIA RHYE

06/28

1234 1234 1234 1234
Untitled.

OLIVIA RHYE

06/28

1234 1234 1234 1234

API reference

CreditCard

Import CreditCard from @/components/shared-assets/credit-card/credit-card. Renders a <div> element.

CreditCard props
PropTypeDefaultDescription
companystring"Untitled."The issuer name printed in the top left corner of the card.
cardNumberstring"1234 1234 1234 1234"The card number printed along the bottom of the card.
cardHolderstring"OLIVIA RHYE"The cardholder name printed above the card number. Rendered in uppercase.
cardExpirationstring"06/28"The expiry date printed to the right of the cardholder name.
type
"transparent""transparent-gradient""brand-dark""brand-light""gray-dark""gray-light""transparent-strip""gray-strip""gradient-strip""salmon-strip""gray-strip-vertical""gradient-strip-vertical""salmon-strip-vertical"
"brand-dark"The visual style of the card, which sets its background, text colors and any decorative strip.
classNamestring—The class name applied to the outer wrapper of the card.
widthnumber—The rendered width of the card in pixels. The card is scaled proportionally from its intrinsic 316×190 size.

FAQs

Please refer to our frequently asked questions page for more.

Set type to one of 13 styles: "transparent", "transparent-gradient", "brand-dark", "brand-light", "gray-dark" and "gray-light"; the horizontal strip styles "transparent-strip", "gray-strip", "gradient-strip" and "salmon-strip"; and the vertical strip styles "gray-strip-vertical", "gradient-strip-vertical" and "salmon-strip-vertical". The default is "brand-dark".

Pass company, cardNumber, cardHolder and cardExpiration as strings. Without them the card shows placeholder data: "Untitled.", "1234 1234 1234 1234", "OLIVIA RHYE" and "06/28".

No. It is a visual card, not a payment input, and the strings you pass are rendered as-is. Format or mask the card number before passing it in. The cardholder name is uppercased with CSS.

Pass width in pixels. The card is designed at 316px × 190px and scaled with a CSS transform, so the height keeps the same aspect ratio and the text scales with it.

No, there is no prop for the network mark. The component imports the Mastercard icon directly, so every card shows a Mastercard logo; to show another network, swap the icon import in your copy of the component. The "brand-dark", "brand-light", "gray-dark" and "gray-light" types render the full-color mark, and every other type renders the white mark.