Siteplane UI

Credit Card

Show a payment card with its issuer, cardholder, number, expiry date and network mark, in one of thirteen looks.

Markdown

Northlight

"use client";

import { CreditCard } from "@/siteplane/components/credit-card";

export default function Example() {
  return (
    <CreditCard
      brand="Northlight"
      expiry="09/28"
      name="Mara Ellis"
      number="•••• •••• •••• 4242"
    />
  );
}

Installation

pnpm dlx shadcn@4.18.0 add @siteplane/credit-card

Complete the one-time setup first. Registry JSON lists source files and dependencies.

Usage

import { CreditCard } from "@/siteplane/components/credit-card";

<CreditCard
  brand="Northlight"
  expiry="09/28"
  name="Mara Ellis"
  number="•••• •••• •••• 4242"
/>;

Content

A credit card is a picture of a card made of text. brand is the issuer's wordmark at the top start, and the contactless symbol stands at the top end. At the bottom, name sets the cardholder in capitals with expiry at the end of its line, above number. The network mark stands in a tile at the bottom end. Every prop is optional.

Faces

variant picks one of thirteen looks. Six are a full face: brand-dark, the default, and brand-light in shades of the accent, gray-dark and gray-light in the kit's neutrals, and the two clear glass looks below. The brand shades follow the accent of your theme, so a card matches the application it sits in.

Northlight

Northlight

Northlight

Northlight

"use client";

import {
  CreditCard,
  type CreditCardVariant,
} from "@/siteplane/components/credit-card";

const variants: CreditCardVariant[] = [
  "brand-dark",
  "brand-light",
  "gray-dark",
  "gray-light",
];

export default function Example() {
  return (
    <div className="flex flex-wrap justify-center gap-6">
      {variants.map((variant) => (
        <CreditCard
          brand="Northlight"
          expiry="09/28"
          key={variant}
          name="Mara Ellis"
          number="•••• •••• •••• 4242"
          variant={variant}
        />
      ))}
    </div>
  );
}

Strips

Four looks lay a dark strip across the lower half of the card, under a light gray (gray-strip), a soft brand gradient (gradient-strip), a warm tint (salmon-strip) or clear glass (transparent-strip). Three lay the dark strip over the start of the card and leave a column at the end, where the network mark stands: a translucent wash in gray-strip-vertical, a gradient in gradient-strip-vertical and the warm tint in salmon-strip-vertical. The gradients derive from the accent and the warm tint from the orange color tint.

Northlight

Northlight

Northlight

Northlight

Northlight

"use client";

import {
  CreditCard,
  type CreditCardVariant,
} from "@/siteplane/components/credit-card";

const variants: CreditCardVariant[] = [
  "gray-strip",
  "gradient-strip",
  "salmon-strip",
  "gradient-strip-vertical",
  "salmon-strip-vertical",
];

export default function Example() {
  return (
    <div className="flex flex-wrap justify-center gap-6">
      {variants.map((variant) => (
        <CreditCard
          brand="Northlight"
          expiry="09/28"
          key={variant}
          name="Mara Ellis"
          number="•••• •••• •••• 4242"
          variant={variant}
        />
      ))}
    </div>
  );
}

Clear glass

transparent, transparent-gradient and transparent-strip are the kit's clear glass, which takes its look from what lies behind it: set them on a photo, an illustration or a gradient, never on a plain page. transparent-gradient adds a soft glow in its top start corner. The column of gray-strip-vertical lets the background through as well, so it needs the same backdrop.

The gradient only makes the glass visible. It is not part of the component.

Northlight

Northlight

Northlight

Northlight

"use client";

import {
  CreditCard,
  type CreditCardVariant,
} from "@/siteplane/components/credit-card";

const variants: CreditCardVariant[] = [
  "transparent",
  "transparent-gradient",
  "transparent-strip",
  "gray-strip-vertical",
];

export default function Example() {
  return (
    <div className="flex flex-wrap justify-center gap-6 rounded-2xl bg-linear-to-br from-(--sp-rw-bg-accent) to-(--chart-4) p-6">
      {variants.map((variant) => (
        <CreditCard
          brand="Northlight"
          expiry="09/28"
          key={variant}
          name="Mara Ellis"
          number="•••• •••• •••• 4242"
          variant={variant}
        />
      ))}
    </div>
  );
}

Width

A card is 316 px wide and 190 px high, and never wider than its container. It draws its text, its padding and its corners in units of its own width, so a width class such as w-60 scales the whole card with them.

Northlight

Northlight

"use client";

import { CreditCard } from "@/siteplane/components/credit-card";

export default function Example() {
  return (
    <div className="flex flex-wrap items-end justify-center gap-6">
      <CreditCard
        brand="Northlight"
        className="w-60"
        expiry="09/28"
        name="Mara Ellis"
        number="•••• •••• •••• 4242"
      />
      <CreditCard
        brand="Northlight"
        expiry="09/28"
        name="Mara Ellis"
        number="•••• •••• •••• 4242"
      />
    </div>
  );
}

Network mark

The kit ships no card network's logo. The tile at the bottom end shows a generic mark of two overlapping circles in the ink of the look, which says only that a network mark stands there. Pass the network's own mark as mark: the tile centers it, so give it a size that fits the tile, 46 by 32 px on a card of the default width. mark={null} leaves the tile out.

<CreditCard
  brand="Northlight"
  expiry="09/28"
  mark={null}
  name="Mara Ellis"
  number="•••• •••• •••• 4242"
  variant="gray-dark"
/>

API reference

Component properties
PropTypeDefaultDescription
CreditCard.varianttransparent | 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-verticalbrand-darkOne of the thirteen looks: six full faces, four with a dark strip across the lower half and three with a dark strip over the start and a column at the end. The transparent looks are clear glass.
CreditCard.brandReactNodeunsetThe issuer's name, set as the wordmark at the top start.
CreditCard.namestringunsetThe cardholder's name, set in capitals above the number.
CreditCard.numberstringunsetThe card number as it is to read, such as •••• •••• •••• 4242.
CreditCard.expirystringunsetThe expiry date, at the end of the cardholder's line.
CreditCard.markReactNodegeneric markThe card network's mark, in the tile at the bottom end. Without it, the tile shows a generic mark of two circles; null leaves the tile out.
CreditCard.classNamestringunsetClasses for the card, such as a width.

CreditCardProps extends the props of a div, except children, and accepts a ref. The root carries data-slot="credit-card" and data-variant, and its parts credit-card-face, credit-card-header, credit-card-brand, credit-card-footer, credit-card-details, credit-card-line, credit-card-name, credit-card-expiry, credit-card-number and credit-card-mark, with credit-card-strip and credit-card-glow on the looks that draw them. The type CreditCardVariant is exported.

Read the installed source.

Usage notes

Use a credit card to show a saved payment method, such as on a billing page or in a list of cards to choose from. Show only the last four digits outside a payment form, as the examples do. The card shows details and takes no input: to collect card details, use the fields of a Form.

Assistive technology reads the card as its text: the issuer, the cardholder, the expiry date and the number, in that order. The contactless symbol and the generic mark are decoration and are hidden from it. When the network matters, pass a mark with an accessible name, such as an image with alt text, or name the network in the text around the card.

A card keeps its colors in Light and Dark, as a picture of a real card does. The brand looks and the gradients follow your accent color, the salmon looks take the hue of the orange color tint (--sp-rw-bg-orange), the gray looks stay the kit's fixed neutrals, and the clear glass looks take the color of what lies behind them. The card owns no interaction. To let people choose one of several saved cards, pair each card with an item of a Radio Group.