Components / Cards
Flip Card
A card that flips in 3D to reveal its back side, on hover or click.
Installation
Requires React 18+ and Tailwind CSS.
- 1
Install dependencies
$ npm install motion - 2
Add the component
Copy the code from the Code tab above into
components/ui/flip-card.tsx. - 3
Use it
example.tsximport { FlipCard } from "@/components/ui/flip-card"; export default function FlipCardDemo() { return ( <FlipCard front={ <div className="flex size-full flex-col justify-end rounded-2xl bg-gradient-to-br from-orange-400 via-rose-500 to-fuchsia-600 p-5 text-white shadow-xl"> <p className="text-xs font-medium uppercase tracking-wider text-white/70">Hover me</p> <p className="text-2xl font-semibold">Pro Plan</p> </div> } back={ <div className="flex size-full flex-col justify-between rounded-2xl border border-zinc-200 bg-white p-5 shadow-xl dark:border-white/10 dark:bg-zinc-900"> <div> <p className="text-3xl font-semibold text-zinc-900 dark:text-white"> $19<span className="text-sm font-normal text-zinc-500">/mo</span> </p> <ul className="mt-4 space-y-2 text-sm text-zinc-600 dark:text-zinc-400"> <li>✓ Unlimited projects</li> <li>✓ Priority support</li> <li>✓ Custom domains</li> </ul> </div> <span className="rounded-lg bg-zinc-900 py-2 text-center text-sm font-semibold text-white dark:bg-white dark:text-zinc-900"> Upgrade </span> </div> } /> ); }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| front | ReactNode | — | Front face. |
| back | ReactNode | — | Back face. |
| trigger | "hover" | "click" | "hover" | What flips the card. |
| className | string | "h-72 w-56" | Card size. |