---
title: "Card Folder"
description: "A landscape card tucked into a stitched purse pocket that lifts forward as the purse compresses into its bottom seam, with controlled open and card-detail visibility plus a separate overflow action."
category: "Blocks"
publishedAt: "2026-09-04"
updatedAt: "2026-11-10"
documentation: "https://beui.dev/components/blocks/card-folder"
markdown: "https://beui.dev/components/blocks/card-folder.md"
license: "MIT"
---

# Card Folder

> A landscape card tucked into a stitched purse pocket that lifts forward as the purse compresses into its bottom seam, with controlled open and card-detail visibility plus a separate overflow action.

## Install

```bash
npx shadcn@latest add @beui/card-folder
```

## Dependencies

- `clsx`
- `lucide-react`
- `motion`
- `react`
- `tailwind-merge`

## Usage

```tsx
"use client";

import { useState } from "react";
import { CardFolder } from "@/components/motion/card-folder";
import { DigitSwap } from "@/components/motion/digit-swap";

const CARD_NUMBER = "3745 6987 4096 0806";
const MASKED_CARD_NUMBER = "•••• •••• •••• 0806";
const CONTOUR_RADII = Array.from({ length: 18 }, (_, index) => 72 + index * 24);

function CardArtwork({ detailsVisible }: { detailsVisible: boolean }) {
  return (
    <span className="relative block h-full w-full overflow-hidden bg-[linear-gradient(135deg,#383a38_0%,#202120_48%,#111211_100%)] text-white">
      <svg
        aria-hidden="true"
        viewBox="0 0 640 404"
        className="absolute inset-0 h-full w-full"
      >
        {CONTOUR_RADII.map((radius, index) => (
          <circle
            // The concentric contours deliberately begin outside the card so
            // their cropped curves read like the reference artwork.
            key={radius}
            cx="-20"
            cy="-28"
            r={radius}
            fill="none"
            stroke="currentColor"
            strokeOpacity={0.32 - index * 0.009}
            strokeWidth="1.5"
          />
        ))}
      </svg>

      <span className="absolute inset-0 bg-[radial-gradient(circle_at_78%_8%,rgb(255_255_255/0.11),transparent_32%)]" />

      <span className="absolute left-[6%] top-[8%] flex flex-col gap-2">
        <span className="text-[11px] font-medium uppercase tracking-[0.22em] text-white/55">
          Saurabh Chauhan
        </span>
        <DigitSwap
          value={detailsVisible ? CARD_NUMBER : MASKED_CARD_NUMBER}
          animationKey={detailsVisible ? "revealed" : "masked"}
          direction={detailsVisible ? "up" : "down"}
          suffixLength={4}
          glyphClassName={detailsVisible ? "text-white/90" : "text-white/65"}
          suffixClassName="text-white/90"
          className="font-mono text-xs tracking-[0.13em]"
        />
      </span>

      <span className="absolute top-[8%] right-[7%] h-[20%] w-[13%] overflow-hidden rounded-[18%] border border-black/30 bg-[linear-gradient(135deg,#f2f0ea_0%,#b9b7b1_45%,#e4e1d9_100%)]">
        <span className="absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-black/30" />
        <span className="absolute inset-x-0 top-1/3 h-px bg-black/30" />
        <span className="absolute inset-x-0 bottom-1/3 h-px bg-black/30" />
        <span className="absolute left-0 top-1/2 h-[34%] w-[28%] -translate-y-1/2 rounded-r-[35%] border border-l-0 border-black/30" />
        <span className="absolute right-0 top-1/2 h-[34%] w-[28%] -translate-y-1/2 rounded-l-[35%] border border-r-0 border-black/30" />
      </span>

      <span className="absolute bottom-[9%] left-[6%] flex items-center gap-2 text-lg font-medium tracking-[-0.04em]">
        beUI <span className="block size-2.5 rotate-45 rounded-[2px] bg-white/85" />
      </span>

      <span className="absolute right-[7%] bottom-[10%] flex items-end gap-5">
        <span className="flex flex-col gap-1">
          <span className="text-[11px] font-medium uppercase tracking-[0.16em] text-white/40">
            Expiry
          </span>
          <span className="text-xs font-medium text-white/90 tabular-nums">
            08/29
          </span>
        </span>
        <span className="flex flex-col gap-1">
          <span className="text-[11px] font-medium uppercase tracking-[0.16em] text-white/40">
            CVV
          </span>
          <DigitSwap
            value={detailsVisible ? "123" : "•••"}
            animationKey={detailsVisible ? "revealed" : "masked"}
            direction={detailsVisible ? "up" : "down"}
            className="font-mono text-xs font-medium text-white/90"
          />
        </span>
      </span>
    </span>
  );
}

export function CardFolderPreview() {
  const [detailsVisible, setDetailsVisible] = useState(false);

  return (
    <div className="flex min-h-72 w-full items-center justify-center px-6 py-9">
      <CardFolder
        title="Saurabh Chauhan"
        cardNumber={CARD_NUMBER}
        expiry="08/29"
        cvv="123"
        detailsVisible={detailsVisible}
        onDetailsVisibleChange={setDetailsVisible}
        card={<CardArtwork detailsVisible={detailsVisible} />}
      />
    </div>
  );
}
```

## API Reference

### CardFolder

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `title` | `string` |  | Yes | Card name shown on the folder front and used in labels. |
| `cardNumber` | `string` |  | Yes | Full card number. Non-digits are stripped; only the last 4 show until revealed. |
| `expiry` | `string` |  | Yes | Expiry date text shown on the folder, e.g. "08/29". |
| `cvv` | `string` |  | Yes | Security code, masked until details are revealed. |
| `card` | `ReactNode` |  | Yes | The card face that lifts out of the folder. |
| `open` | `boolean` |  | No | Whether the card is lifted out, for controlled use. |
| `defaultOpen` | `boolean` | `false` | No | Whether the card starts lifted out when uncontrolled. Default: false |
| `onOpenChange` | `((open: boolean) => void)` |  | No | Called with the next state when the folder opens or closes. |
| `detailsVisible` | `boolean` |  | No | Whether the number and CVV are revealed, for controlled use. |
| `defaultDetailsVisible` | `boolean` | `false` | No | Whether the number and CVV start revealed when uncontrolled. Default: false |
| `onDetailsVisibleChange` | `((visible: boolean) => void)` |  | No | Called with the next state when the details are shown or hidden. |
| `onClick` | `(() => void)` |  | No | Called after the folder is pressed, alongside the open toggle. |
| `onAction` | `(() => void)` |  | No | Called when the actions button is pressed. The button shows only when set. |
| `ariaLabel` | `string` |  | No | Accessible name for the folder button. Defaults to the `open` or `close` label. |
| `actionLabel` | `string` |  | No | Accessible name for the actions button. Defaults to the `actions` label. |
| `disabled` | `boolean` | `false` | No | Disables opening, revealing details and the actions button. Default: false |
| `className` | `string` |  | No | Classes merged onto the root element. |
| `cardClassName` | `string` |  | No | Classes merged onto the wrapper around the card face. |
| `labels` | `Partial<{ open: string; close: string; showDetails: string; hideDetails: string; expiry: string; cvv: string; actions: string; }>` |  | No | Override any built-in string. `{title}`, `{lastFour}` and `{expiry}` fill `open`, `close` and `actions`. |

## About Card Folder

Card Folder is a React payment card component that shows a landscape card tucked into a stitched purse pocket. Pressing it lifts the card forward while the purse compresses into its bottom seam, and a separate eye button reveals the full card number and CVV with a rolling digit swap. The open state and the detail visibility are each controlled or uncontrolled, and an optional overflow action button sits beside the card. It is built with Framer Motion and Tailwind CSS.

### When to use it

- A fintech or banking app shows a virtual card that users can lift out to view.
- A wallet screen hides card numbers by default and reveals them only on request.
- A card management page needs a per-card actions button for tasks like freezing or replacing a card.

### Accessibility

The card is a button with aria-expanded and a default label that reads the title, the last four digits and the expiry, such as "Open Travel card, card ending in 4242, expires 08/29"; ariaLabel replaces it. The detail toggle is a separate button named "Show card details" or "Hide card details" with aria-pressed, and while the card is lifted the purse layer is inert and hidden from assistive technology. With reduced motion enabled, the purse fades instead of compressing and the card does not lift.

### FAQ

**How do I build an animated credit card component in React?**

Render CardFolder with title, cardNumber, expiry and cvv, and pass your card artwork as the card prop. cardClassName styles the card surface.

**How do I hide the card number by default?**

Details start hidden, showing only the last four digits and a masked CVV. Use defaultDetailsVisible for uncontrolled use, or detailsVisible with onDetailsVisibleChange to control it.

**Can I add a menu button to the card?**

Yes. Pass onAction to render an overflow button next to the card, and actionLabel to name it (it defaults to "Open actions for" followed by the title).

## Source

- Registry detail: https://beui.dev/r/card-folder
- Raw source: https://beui.dev/r/card-folder/raw
- GitHub: https://github.com/starc007/ui-components
