card-stack
aceternity/card-stackUnverifiedComponent
aceternity publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/rickhallett/becoming-diamond-nextjs/main/card-stack.jsonSource
1"use client";2import { useEffect, useState } from "react";3import { motion } from "motion/react";45let interval: any;67type Card = {8 id: number;9 name: string;10 designation: string;11 content: React.ReactNode;12};1314export const CardStack = ({15 items,16 offset,17 scaleFactor,18}: {19 items: Card[];20 offset?: number;21 scaleFactor?: number;22}) => {23 const CARD_OFFSET = offset || 10;24 const SCALE_FACTOR = scaleFactor || 0.06;25 const [cards, setCards] = useState<Card[]>(items);2627 useEffect(() => {28 startFlipping();2930 return () => clearInterval(interval);31 }, []);32 const startFlipping = () => {33 interval = setInterval(() => {34 setCards((prevCards: Card[]) => {35 const newArray = [...prevCards]; // create a copy of the array36 newArray.unshift(newArray.pop()!); // move the last element to the front37 return newArray;38 });39 }, 5000);40 };4142 return (43 <div className="relative h-60 w-60 md:h-60 md:w-96">44 {cards.map((card, index) => {45 return (46 <motion.div47 key={card.id}48 className="absolute dark:bg-black bg-white h-60 w-60 md:h-60 md:w-96 rounded-3xl p-4 shadow-xl border border-neutral-200 dark:border-white/[0.1] shadow-black/[0.1] dark:shadow-white/[0.05] flex flex-col justify-between"49 style={{50 transformOrigin: "top center",51 }}52 animate={{53 top: index * -CARD_OFFSET,54 scale: 1 - index * SCALE_FACTOR, // decrease scale for cards that are behind55 zIndex: cards.length - index, // decrease z-index for the cards that are behind56 }}57 >58 <div className="font-normal text-neutral-700 dark:text-neutral-200">59 {card.content}60 </div>61 <div>62 <p className="text-neutral-500 font-medium dark:text-white">63 {card.name}64 </p>65 <p className="text-neutral-400 font-normal dark:text-neutral-200">66 {card.designation}67 </p>68 </div>69 </motion.div>70 );71 })}72 </div>73 );74};
What it pulls in
npm packages
Files it writes
More from aceternity
All 89 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| 3d-card3d-card | aceternity | Components | Unverified | no deps | |
| 3d Globe3d-globe | aceternity | Components | Free | 3 deps | |
| 3d-marquee3d-marquee | aceternity | Components | Unverified | no deps | |
| 3d-pin3d-pin | aceternity | Components | Unverified | 1 dep | |
| animated-modalanimated-modal | aceternity | Components | Unverified | 1 dep | |
| animated-testimonialsanimated-testimonials | aceternity | Components | Unverified | 2 deps | |
| animated-tooltipanimated-tooltip | aceternity | Components | Unverified | 1 dep | |
| apple-cards-carouselapple-cards-carousel | aceternity | Components | Unverified | 2 deps |
