animated-testimonials
aceternity/animated-testimonialsUnverifiedComponent
aceternity publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/rickhallett/becoming-diamond-nextjs/main/animated-testimonials.jsonSource
1"use client";23import { IconArrowLeft, IconArrowRight } from "@tabler/icons-react";4import { motion, AnimatePresence } from "motion/react";56import { useEffect, useState } from "react";78type Testimonial = {9 quote: string;10 name: string;11 designation: string;12 src: string;13};14export const AnimatedTestimonials = ({15 testimonials,16 autoplay = false,17}: {18 testimonials: Testimonial[];19 autoplay?: boolean;20}) => {21 const [active, setActive] = useState(0);2223 const handleNext = () => {24 setActive((prev) => (prev + 1) % testimonials.length);25 };2627 const handlePrev = () => {28 setActive((prev) => (prev - 1 + testimonials.length) % testimonials.length);29 };3031 const isActive = (index: number) => {32 return index === active;33 };3435 useEffect(() => {36 if (autoplay) {37 const interval = setInterval(handleNext, 5000);38 return () => clearInterval(interval);39 }40 }, [autoplay]);4142 const randomRotateY = () => {43 return Math.floor(Math.random() * 21) - 10;44 };45 return (46 <div className="mx-auto max-w-sm px-4 py-20 font-sans antialiased md:max-w-4xl md:px-8 lg:px-12">47 <div className="relative grid grid-cols-1 gap-20 md:grid-cols-2">48 <div>49 <div className="relative h-80 w-full">50 <AnimatePresence>51 {testimonials.map((testimonial, index) => (52 <motion.div53 key={testimonial.src}54 initial={{55 opacity: 0,56 scale: 0.9,57 z: -100,58 rotate: randomRotateY(),59 }}60 animate={{61 opacity: isActive(index) ? 1 : 0.7,62 scale: isActive(index) ? 1 : 0.95,63 z: isActive(index) ? 0 : -100,64 rotate: isActive(index) ? 0 : randomRotateY(),65 zIndex: isActive(index)66 ? 4067 : testimonials.length + 2 - index,68 y: isActive(index) ? [0, -80, 0] : 0,69 }}70 exit={{71 opacity: 0,72 scale: 0.9,73 z: 100,74 rotate: randomRotateY(),75 }}76 transition={{77 duration: 0.4,78 ease: "easeInOut",79 }}80 className="absolute inset-0 origin-bottom"81 >82 <img83// … truncated
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-tooltipanimated-tooltip | aceternity | Components | Unverified | 1 dep | |
| apple-cards-carouselapple-cards-carousel | aceternity | Components | Unverified | 2 deps | |
| Ascii Artascii-art | aceternity | Components | Free | 1 dep |
