Card Stack
- Source
- Aceternity UI ↗
- Author
- Aceternity UI
- Licence
- Aceternity UI licence (free component)
Loading…
A stack of testimonial cards rotates the back card to the front every few seconds.
Code
"use client";
import { CardStack } from "@/lab/aceternity/ui/card-stack";
import { cn } from "@/lib/utils";
import { Fit } from "./_fit";
export default function CardStackDemo() {
return (
<Fit width={460} height={340} max={1.5}>
<div className="h-full flex items-center justify-center w-full pt-6">
<CardStack items={CARDS} />
</div>
</Fit>
);
}
// Small utility to highlight the content of specific section of a testimonial content
const Highlight = ({
children,
className,
}: {
children: React.ReactNode;
className?: string;
}) => {
return (
<span
className={cn(
"font-bold bg-emerald-100 text-emerald-700 dark:bg-emerald-700/[0.2] dark:text-emerald-500 px-1 py-0.5",
className
)}
>
{children}
</span>
);
};
const CARDS = [
{
id: 0,
name: "Manu Arora",
designation: "Senior Software Engineer",
content: (
<p>
These cards are amazing, <Highlight>I want to use them</Highlight> in my
project. Framer motion is a godsend ngl tbh fam 🙏
</p>
),
},
{
id: 1,
name: "Elon Musk",
designation: "Senior Shitposter",
content: (
<p>
I dont like this Twitter thing,{" "}
<Highlight>deleting it right away</Highlight> because yolo. Instead, I
would like to call it <Highlight>X.com</Highlight> so that it can easily
be confused with adult sites.
</p>
),
},
{
id: 2,
name: "Tyler Durden",
designation: "Manager Project Mayhem",
content: (
<p>
The first rule of
<Highlight>Fight Club</Highlight> is that you do not talk about fight
club. The second rule of
<Highlight>Fight club</Highlight> is that you DO NOT TALK about fight
club.
</p>
),
},
];
Prompt
Build "Card Stack", a card animation. What it does: A stack of testimonial cards rotates the back card to the front every few seconds. Write it as a single self-contained React component in TypeScript that fills its parent (w-full h-full), styled with Tailwind CSS, using motion. Technique: the Motion library. It sits on a light background, in a 16:10 frame. Respect prefers-reduced-motion with a still state, pause work when the element is off screen, and keep it accessible. Original: https://ui.aceternity.com/components/card-stack (Aceternity UI, Aceternity UI licence (free component)).