ReactHive

Card Pack

Cards 11

About

A foil pack of cards to open. Tear it along the top, or click: the torn strip curls back and flies off as confetti bursts, the cards rise out and the pack drops away. They fan out face down and turn over in a wave, the rare holo card last, with its own burst.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Card Pack to your project and fits it to your theme.

Code

How Card Pack is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import type { ReactNode } from "react";

import { CardPack, type Pack } from "@/components/ui/card-pack";

/* The demo's Google Fonts. In a Next.js app, use next/font/google instead. */
if (typeof document !== "undefined" && !document.getElementById("card-pack-fonts")) {
  const style = document.createElement("style");
  style.id = "card-pack-fonts";
  style.textContent = "@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:wght@200..800&display=swap'); .rh-bricolage-grotesque { font-family: 'Bricolage Grotesque', sans-serif; }";
  document.head.appendChild(style);
}

const bright = [
  {
    "name": "orange-sunglasses",
    "title": "Citrus",
    "alt": "A person in red sunglasses and a green jacket against orange",
    "caption": "Editorial, spring issue",
    "width": 1440,
    "height": 1800,
    "src": "https://cdn.21st.dev/assets/mirror/3b/3bb078492f3e6b7b2e411adcb66efb67de1d868a71023567df7e49770caf2759.webp"
  },
  {
    "name": "green-dancer",
    "title": "Green Room",
    "alt": "A blurred dancer in white against a green backdrop",
    "caption": "Motion study",
    "width": 1200,
    "height": 1800,
    "src": "https://cdn.21st.dev/assets/mirror/96/96534974eb49bb0e5a352f251a69da6a4b11a6c691eaa20df96e8c21b665e569.webp"
  },
  {
    "name": "pink-blazer",
    "title": "Pink Hour",
    "alt": "A person in a pink blazer against pink",
    "caption": "Editorial, colour stories",
    "width": 1200,
    "height": 1800,
    "src": "https://cdn.21st.dev/assets/mirror/3c/3cbe946fb0d67e3ea99ee0c861b1f9a4257f181200234bd461298577e3902b20.webp"
  },
  {
    "name": "yellow-walk",
    "title": "Procession",
    "alt": "A figure in a yellow robe walking, caught in a multiple exposure against orange",
    "caption": "Motion study",
    "width": 1440,
    "height": 1800,
    "src": "https://cdn.21st.dev/assets/mirror/0a/0aabcb5a22e5bc67dcb561d7b544bd52d518d3040b2f6a45e348d2c77b7e92a0.webp"
  },
  {
    "name": "red-sky",
    "title": "High Noon",
    "alt": "A person in a red outfit against a clear blue sky",
    "caption": "Editorial, summer issue",
    "width": 1800,
    "height": 1221,
    "src": "https://cdn.21st.dev/assets/mirror/88/8817490ab1af62dc8becfbc2c122b30c678b995f1e1e6fc1011538899d2f64bf.webp"
  },
  {
    "name": "spinning-dress",
    "title": "Turn",
    "alt": "A dancer spinning in a swirling, colourful dress",
    "caption": "Motion study",
    "width": 1400,
    "height": 1337,
    "src": "https://cdn.21st.dev/assets/mirror/76/760a67b082183370900b6f059af09fa02a70e18893162ab7003fafddb6a6b968.webp"
  },
  {
    "name": "magenta-hands",
    "title": "Peekaboo",
    "alt": "A person peering through yellow-painted fingers against magenta",
    "caption": "Editorial, colour stories",
    "width": 1195,
    "height": 1800,
    "src": "https://cdn.21st.dev/assets/mirror/5e/5eea8fe53aa88dd9aba2e1cbcce10d5cb3b74462d4bc28d75f714c265cafbabf.webp"
  },
  {
    "name": "orange-dancers",
    "title": "Heat",
    "alt": "Blurred dancers moving through orange light",
    "caption": "Motion study",
    "width": 1800,
    "height": 1169,
    "src": "https://cdn.21st.dev/assets/mirror/56/568de028f92375c3a70e1ec1a3755c218f95e2a7813d5bd5580195da66bebea6.webp"
  },
  {
    "name": "yellow-jacket",
    "title": "Yellow",
    "alt": "A person in a yellow and black jacket in a yellow room",
    "caption": "Editorial, menswear",
    "width": 1200,
    "height": 1800,
    "src": "https://cdn.21st.dev/assets/mirror/3e/3e9a39eb7c2d9ec200ae5c009a2556580e4447f25212ee08985792e6626ecb59.webp"
  },
  {
    "name": "stage-dancers",
    "title": "Encore",
    "alt": "Dancers on a dark stage dissolving into trails of pink and blue light",
    "caption": "Motion study",
    "width": 1800,
    "height": 1376,
    "src": "https://cdn.21st.dev/assets/mirror/a4/a46338d079106c75d677588e79e0c89dd6ed83bb1cef4e891d7d0f90eba522f6.webp"
  },
  {
    "name": "green-dress",
    "title": "Orchard",
    "alt": "A person in a green dress holding an apple",
    "caption": "Editorial, autumn issue",
    "width": 1350,
    "height": 1800,
    "src": "https://cdn.21st.dev/assets/mirror/da/da1c0eb311d45b394f85d1629b83535cacb1386044c497a9bc24d83544b7fadb.webp"
  },
  {
    "name": "violet-blur",
    "title": "Afterglow",
    "alt": "A blurred figure in violet and orange light",
    "caption": "Motion study",
    "width": 1800,
    "height": 1199,
    "src": "https://cdn.21st.dev/assets/mirror/a6/a692ef8f461284b6a292a85bb4c5c284d3cbb7cab8134417e9aeb3f31abf4cee.webp"
  },
  {
    "name": "pink-pair",
    "title": "Two of Us",
    "alt": "Two people in pink sleeves, side by side",
    "caption": "Editorial, colour stories",
    "width": 1350,
    "height": 1800,
    "src": "https://cdn.21st.dev/assets/mirror/fc/fc2d20e32a94b933a2ebfb333fbbf1ceddc0a12a59403244dfdf0c1789f385de.webp"
  },
  {
    "name": "neon-crowd",
    "title": "Night Market",
    "alt": "A crowd blurred into streaks under neon lights",
    "caption": "Motion study",
    "width": 1800,
    "height": 1199,
    "src": "https://cdn.21st.dev/assets/mirror/f7/f7855a5859c4f254cec2a6a8ce3313196276bd1996b50cdb011c137abc5e6774.webp"
  },
  {
    "name": "red-suit",
    "title": "Red Line",
    "alt": "A person in a red suit against a dark backdrop",
    "caption": "Editorial, tailoring",
    "width": 1201,
    "height": 1800,
    "src": "https://cdn.21st.dev/assets/mirror/a9/a9a19a4c073cd0d7098c51866a2a1e0f4caf67c042c38c4f47101b2d9e215568.webp"
  },
  {
    "name": "beach-blur",
    "title": "Tide",
    "alt": "A blurred figure in a bright swimsuit on a beach",
    "caption": "Motion study",
    "width": 1200,
    "height": 1800,
    "src": "https://cdn.21st.dev/assets/mirror/b2/b2ac414c4abb2616d3e6aa5648bfd128dd69032ba412259a0ec170b792f7187f.webp"
  },
  {
    "name": "yellow-blossom",
    "title": "Bloom",
    "alt": "A close portrait framed by yellow blossom",
    "caption": "Editorial, beauty",
    "width": 1200,
    "height": 1800,
    "src": "https://cdn.21st.dev/assets/mirror/56/5617db928d7b8ef766d82c958d9125b5b4528f7bbd01876b44c12e7a36881f72.webp"
  },
  {
    "name": "hair-flip",
    "title": "Flip",
    "alt": "A person tossing their hair, in sunglasses and a pink top",
    "caption": "Editorial, summer issue",
    "width": 1800,
    "height": 1199,
    "src": "https://cdn.21st.dev/assets/mirror/01/01896b2343d03e64c0525b155db049eb63dbba24bafb214b6dee6252b5965086.webp"
  },
  {
    "name": "blue-suit",
    "title": "Blue Note",
    "alt": "A person in a blue suit sitting on white sheets against teal",
    "caption": "Editorial, tailoring",
    "width": 1200,
    "height": 1800,
    "src": "https://cdn.21st.dev/assets/mirror/b2/b20736eb1c9511339d0a6dd78b1688b28479e964e741044a08c3dfa5aa7a7cb9.webp"
  },
  {
    "name": "orange-chair",
    "title": "Sit Still",
    "alt": "A person sitting on a wooden chair against orange",
    "caption": "Editorial, menswear",
    "width": 1201,
    "height": 1800,
    "src": "https://cdn.21st.dev/assets/mirror/57/5790842cde5e70321f83073b8ef3e199e7024456bbe26308f241794c8360b10c.webp"
  }
];

/** A gentle entrance: rises and fades in, a beat after `delay` seconds. */
function Rise({ children, delay = 0, className = "" }: { children: ReactNode; delay?: number; className?: string }) {
  return (
    <div className={className} style={{ animation: `rh-rise 1.1s cubic-bezier(0.22, 1, 0.36, 1) ${delay}s both` }}>
      <style>{`@keyframes rh-rise { from { opacity: 0; transform: translateY(28px); } } @media (prefers-reduced-motion: reduce) { @keyframes rh-rise { from { opacity: 0; } } }`}</style>
      {children}
    </div>
  );
}

const type = { className: "rh-bricolage-grotesque", style: { fontFamily: "'Bricolage Grotesque', sans-serif" } };
const pick = (name: string) => bright.find((p) => p.name === name)!;
const card = (name: string, no: string, tone: string, rare = false) => {
  const p = pick(name);
  return { src: p.src, alt: p.alt, name: p.title, no, tone, rare };
};

// Kept outside the component, so the packs aren't rebuilt on every render.
const PACKS: Pack[] = [
  {
    name: "Bloom",
    color: "linear-gradient(160deg, #ff6fb5, #e8237f 55%, #b3105f)",
    cards: [card("green-dress", "No. 012", "#e6f2da"), card("yellow-blossom", "No. 027", "#fff3c9"), card("pink-pair", "No. 031", "#ffe0ec"), card("blue-suit", "No. 008", "#dcecf1"), card("orange-sunglasses", "No. 001", "#ffe3cf", true)],
  },
  {
    name: "Motion",
    color: "linear-gradient(160deg, #6f8bff, #2f4fe0 55%, #1b2c9e)",
    cards: [card("green-dancer", "No. 044", "#dcf0e2"), card("yellow-walk", "No. 052", "#fff0cc"), card("orange-dancers", "No. 049", "#ffe1cc"), card("violet-blur", "No. 057", "#ece0ff"), card("spinning-dress", "No. 040", "#ffe6dc", true)],
  },
];

function DemoContent() {
  return (
    <main className={`${type.className} relative grid h-svh grid-rows-[auto_1fr] overflow-hidden bg-[#ecebe8] text-[#151515]`}>
      <div className="flex items-start justify-between gap-6 px-[5vw] pt-[4vh]">
        <Rise>
          <h1 className="max-w-[12ch] text-[clamp(1.9rem,4vw,3.5rem)] leading-[0.95] font-semibold tracking-[-0.04em]">The Colour Stories, in Packs of Five</h1>
        </Rise>
        <Rise delay={0.1}>
          <p className="hidden max-w-[16rem] text-right text-[15px] leading-[22px] text-[#151515]/70 sm:block">One foil card in every pack. Drag along the top to tear it, or just click.</p>
        </Rise>
      </div>
      <CardPack packs={PACKS} className="[--card:min(11.5rem,40vw)]" />
    </main>
  );
}

/** The demo in its own colours, filling the frame. */
export default function Demo() {
  return (
    <div className="min-h-svh w-full" style={{ background: "#ecebe8" }}>
      <DemoContent />
    </div>
  );
}

More by ReactHive

View all
  • Card Deal

    Card Deal

    15
  • Step Stack

    Step Stack

    13
  • Shoal

    Shoal

    6
  • Fluid Type

    Fluid Type

    5
  • Satin

    Satin

    5
  • Arc Gallery

    Arc Gallery

    4
  • Mercury Clock

    Mercury Clock

    3
  • Whirlwind

    Whirlwind

    2

More in Cards

View all
  • Course Design Cards

    Course Design Cards

    1.3K
  • Weather Card

    Weather Card

    68
  • Statistics Card 7

    Statistics Card 7

    339
  • Stats cards with links

    Stats cards with links

    102
  • Statistics Card 2

    Statistics Card 2

    316
  • Approval Card

    Approval Card

    37
  • Statistics Card 10

    Statistics Card 10

    306
  • Recipe Card

    Recipe Card

    52

Explore more

Part of ReactHive UI — browse the full library on 21st.dev.