---
title: "Credit Card"
description: "Shows a payment card as a real card: the holder, the number, the expiry, and the network. The number stays hidden until the person asks to see it."
url: https://gelatinui.com/components/credit-card
markdown_url: https://gelatinui.com/components/credit-card.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/credit-card"
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Credit Card

> Shows a payment card as a real card: the holder, the number, the expiry, and the network. The number stays hidden until the person asks to see it.

Page: https://gelatinui.com/components/credit-card

## When to use it

Best for: Show a payment card as a real card: the holder, the masked number, the expiry, and the network.

- Use it to show a card that people already have, such as a virtual card or a saved card.
- Use `CreditCardRevealToggle` or `revealed` to show the full number and CVV.
- Use `CreditCardFlip` to turn the card over to its back, and `CreditCardFolder` to slide it out of a sleeve.
- Use `CreditCardWallet` to pick one card from a stack or a fan of cards.
- Use `variant="empty"` for a card with no data yet.

## When not to use it

- For a small network badge in a list, use a [Card Brand](https://gelatinui.com/components/card-brand.md).
- To pick a plan or an option from cards with text, use a [Choice Card](https://gelatinui.com/components/choice-card.md).

## Notes for agents

- It is display only: it does not read, check, or send card data.
- A full number in a prop reaches the client. Pass only the last four digits when you can: dots stand in for the rest.
- The network mark is a slot: put a `CardBrand` or your own logo in `CreditCardNetwork`.
- Each `CreditCardWalletItem` needs a `value` and an `aria-label` that names the card ("Visa ending in 4242").
- A Flip face must hold no controls: the turn button covers it.
- `tint` sets the base color of the `glass` finish.

## Anatomy

```text
CreditCard
├─ CreditCardHeader (0..n)
├─ CreditCardFooter (0..n)
├─ CreditCardGroup (0..n)
├─ CreditCardPattern (0..n)
├─ CreditCardChip (0..n)
├─ CreditCardNetwork (0..n)
├─ CreditCardLabel (0..n)
├─ CreditCardHolder (0..n)
├─ CreditCardNumber (0..n)
├─ CreditCardExpiry (0..n)
├─ CreditCardCvv (0..n)
├─ CreditCardRevealToggle (0..n)
├─ CreditCardStripe (0..n)
├─ CreditCardSignature (0..n)
├─ CreditCardFolder (0..n)
│  ├─ CreditCardFolderCard (0..n)
│  └─ CreditCardSleeve (0..n)
├─ CreditCardFlip (0..n)
├─ CreditCardFlipFront (0..n)
├─ CreditCardFlipBack (0..n)
├─ CreditCardWallet (0..n)
│  └─ CreditCardWalletItem (0..n)
└─ CreditCardWalletIndicator (0..n)
```

## API reference

### CreditCard

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `orientation` | `"horizontal" \| "vertical"` | "horizontal" |  |
| `size` | `"default" \| "lg" \| "sm"` |  |  |
| `variant` | `"empty" \| "glass" \| "metal" \| "midnight" \| "outline" \| "primary"` |  |  |
| `tint` | `string` |  | The base color under the `glass` finish (a data color). |
| `revealed` | `boolean` |  | Show the full number and CVV (controlled). A Folder sets it for the card inside. |
| `defaultRevealed` | `boolean` | false |  |
| `onRevealedChange` | `function` |  |  |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| CreditCard | `credit-card` |  | `--border`, `--card`, `--credit-card-ink`, `--credit-card-ink-muted`, `--credit-card-line`, `--credit-card-tint`, `--credit-card-width`, `--foreground`, `--muted`, `--muted-foreground`, `--primary`, `--primary-foreground` |  |
| CreditCardHeader | `credit-card-header` |  |  |  |
| CreditCardFooter | `credit-card-footer` | `data-orientation` |  |  |
| CreditCardGroup | `credit-card-group` |  |  |  |
| CreditCardPattern | `credit-card-pattern` |  | `--credit-card-line` |  |
| CreditCardChip | `credit-card-chip` | `data-size` |  |  |
| CreditCardNetwork | `credit-card-network` | `data-orientation`, `data-size` |  |  |
| CreditCardLabel | `credit-card-label` |  | `--credit-card-caption-size`, `--credit-card-ink-muted` |  |
| CreditCardHolder | `credit-card-holder` |  | `--credit-card-caption-size`, `--credit-card-ink-muted` |  |
| CreditCardNumber | `credit-card-number` |  | `--credit-card-ink`, `--credit-card-number-size` |  |
| CreditCardExpiry | `credit-card-expiry` |  | `--credit-card-caption-size`, `--credit-card-ink-muted` |  |
| CreditCardCvv | `credit-card-cvv` |  |  |  |
| CreditCardRevealToggle | `credit-card-reveal-toggle` | `data-disabled`, `data-pressed`, `data-size` | `--credit-card-ink`, `--credit-card-ink-muted`, `--credit-card-line` | `hit-area`, `motion-timing` |
| CreditCardStripe | `credit-card-stripe` | `data-size` |  |  |
| CreditCardSignature | `credit-card-signature` |  |  |  |
| CreditCardFolder | `credit-card-folder` |  | `--credit-card-caption-size`, `--credit-card-number-size`, `--credit-card-width` |  |
| CreditCardFolderCard | `credit-card-folder-card` |  | `--credit-card-width` |  |
| CreditCardSleeve | `credit-card-sleeve` |  | `--credit-card-width` |  |
| CreditCardFlip | `credit-card-flip` | `data-disabled` | `--credit-card-caption-size`, `--credit-card-number-size`, `--credit-card-width` |  |
| CreditCardFlipFront | `credit-card-flip-front` |  |  |  |
| CreditCardFlipBack | `credit-card-flip-back` |  |  |  |
| CreditCardWallet | `credit-card-wallet` |  | `--credit-card-caption-size`, `--credit-card-number-size`, `--credit-card-wallet-count`, `--credit-card-width` |  |
| CreditCardWalletItem | `credit-card-wallet-item` | `data-disabled` | `--credit-card-wallet-z` |  |
| CreditCardWalletIndicator | `credit-card-wallet-indicator` | `data-ending-style`, `data-starting-style` |  | `motion-timing` |

## Usage

Compose the face from parts. Pass only the last four digits when you can, and put the network mark in `CreditCardNetwork`.

The sample also uses `card-brand`, which this add does not write. One command adds them with this item:

```bash
npx shadcn@latest add @gelatin-ui-pro/credit-card @gelatin-ui-pro/card-brand
```

```tsx title="virtual-card.tsx"
import {
  CreditCard, CreditCardChip, CreditCardExpiry, CreditCardFooter, CreditCardGroup,
  CreditCardHeader, CreditCardHolder, CreditCardNetwork, CreditCardNumber, CreditCardPattern,
} from "@/components/pro/cards/credit-card";
import { CardBrand } from "@/components/ui/pro/card-brand";

export function VirtualCard() {
  return (
    <CreditCard variant="midnight">
      <CreditCardPattern />
      <CreditCardHeader>
        <CreditCardHolder>Mira Okafor</CreditCardHolder>
        <CreditCardChip />
      </CreditCardHeader>
      <CreditCardFooter>
        <CreditCardGroup>
          <CreditCardNumber number="4242" />
          <CreditCardExpiry>08/29</CreditCardExpiry>
        </CreditCardGroup>
        <CreditCardNetwork>
          <CardBrand brand="visa" />
        </CreditCardNetwork>
      </CreditCardFooter>
    </CreditCard>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui-pro/credit-card
```

It adds 27 registry items: 25 files, 5099 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `@xstate/react`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`, `xstate`.

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Card Brand](https://gelatinui.com/components/card-brand.md)
- [Choice Card](https://gelatinui.com/components/choice-card.md)
- [Radio Group](https://gelatinui.com/components/radio-group.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Enter, Space | On a reveal toggle: shows or hides the number and CVV. On a Flip: turns the card over. |
| Arrow keys | In a Wallet: picks the next or the previous card. |

## Accessibility

The card is a group named "Payment card" (change it with `aria-label`). Screen readers read the holder, the number, and the expiry in order.

While the number is masked, the dots are hidden from screen readers, so they hear only the last four digits.

The reveal toggle is a Base UI Toggle named "Show card details". A Flip is a Toggle named "Show card back", and the face that does not show is `aria-hidden`.

A Wallet is a radio group: Tab goes to the chosen card and the arrow keys pick another.

## Motion

| Part | Motion |
| --- | --- |
| Reveal digits | popup · 150ms · ease-panel (0.2, 0.4, 0.2, 1) · each hidden digit rolls in after the one before it |
| Flip | sheet · 300ms · ease-panel (0.2, 0.4, 0.2, 1) · the card turns over and shrinks to 95% at 90° |
| Folder | sheet · 300ms · ease-panel (0.2, 0.4, 0.2, 1) · the card rises out of the sleeve |
| Wallet | toast · 300ms · ease-panel (0.2, 0.4, 0.2, 1) · the chosen card moves to the front |
