Animated Testimonials

An animated testimonials carousel with stacked image transitions, spring-physics navigation, and a word-by-word text reveal. Perfect for displaying customer quotes, team spotlights, or any social proof content.

Installation

npm install motion @tabler/icons-react react
pnpm install motion @tabler/icons-react react
yarn add motion @tabler/icons-react react
bun add motion @tabler/icons-react react
"use client";import { IconArrowLeft, IconArrowRight } from "@tabler/icons-react";import { motion, AnimatePresence } from "motion/react";import { useEffect, useState } from "react";type Testimonial = {  quote: string;  name: string;  designation: string;  src: string;};export const AnimatedTestimonials = ({  testimonials,  autoplay = false,}: {  testimonials: Testimonial[];  autoplay?: boolean;}) => {  const [active, setActive] = useState(0);  const handleNext = () => {    setActive((prev) => (prev + 1) % testimonials.length);  };  const handlePrev = () => {    setActive((prev) => (prev - 1 + testimonials.length) % testimonials.length);  };  const isActive = (index: number) => {    return index === active;  };  useEffect(() => {    if (autoplay) {      const interval = setInterval(handleNext, 5000);      return () => clearInterval(interval);    }  }, [autoplay]);  const randomRotateY = () => {    return Math.floor(Math.random() * 21) - 10;  };  return (    <div className="mx-auto w-full max-w-sm px-4 py-10 font-sans antialiased sm:max-w-lg sm:px-6 sm:py-14 md:max-w-4xl md:px-8 md:py-20 lg:px-12">      <div className="relative grid grid-cols-1 gap-8 sm:gap-12 md:grid-cols-2 md:gap-20">        {/* Image stack column */}        <div>          <div className="relative h-64 w-full sm:h-72 md:h-80">            <AnimatePresence>              {testimonials.map((testimonial, index) => (                <motion.div                  key={testimonial.src}                  initial={{                    opacity: 0,                    scale: 0.9,                    z: -100,                    rotate: randomRotateY(),                  }}                  animate={{                    opacity: isActive(index) ? 1 : 0.7,                    scale: isActive(index) ? 1 : 0.95,                    z: isActive(index) ? 0 : -100,                    rotate: isActive(index) ? 0 : randomRotateY(),                    zIndex: isActive(index)                      ? 40                      : testimonials.length + 2 - index,                    y: isActive(index) ? [0, -80, 0] : 0,                  }}                  exit={{                    opacity: 0,                    scale: 0.9,                    z: 100,                    rotate: randomRotateY(),                  }}                  transition={{                    duration: 0.4,                    ease: "easeInOut",                  }}                  className="absolute inset-0 origin-bottom"                >                  <img                    src={testimonial.src}                    alt={testimonial.name}                    width={500}                    height={500}                    draggable={false}                    className="h-full w-full rounded-3xl object-cover object-center"                  />                </motion.div>              ))}            </AnimatePresence>          </div>        </div>        {/* Text content column */}        <div className="flex flex-col justify-between py-2 md:py-4">          <motion.div            key={active}            initial={{              y: 20,              opacity: 0,            }}            animate={{              y: 0,              opacity: 1,            }}            exit={{              y: -20,              opacity: 0,            }}            transition={{              duration: 0.2,              ease: "easeInOut",            }}          >            <h3 className="text-xl font-bold text-black dark:text-white sm:text-2xl">              {testimonials[active].name}            </h3>            <p className="text-sm text-gray-500 dark:text-neutral-500">              {testimonials[active].designation}            </p>            <motion.p className="mt-6 text-base text-gray-500 dark:text-neutral-300 sm:mt-8 sm:text-lg">              {testimonials[active].quote.split(" ").map((word, index) => (                <motion.span                  key={index}                  initial={{                    filter: "blur(10px)",                    opacity: 0,                    y: 5,                  }}                  animate={{                    filter: "blur(0px)",                    opacity: 1,                    y: 0,                  }}                  transition={{                    duration: 0.2,                    ease: "easeInOut",                    delay: 0.02 * index,                  }}                  className="inline-block"                >                  {word}&nbsp;                </motion.span>              ))}            </motion.p>          </motion.div>          <div className="flex gap-4 pt-8 md:pt-0">            <button              onClick={handlePrev}              className="group/button flex h-7 w-7 items-center justify-center rounded-full bg-gray-100 dark:bg-neutral-800"            >              <IconArrowLeft className="h-5 w-5 text-black transition-transform duration-300 group-hover/button:rotate-12 dark:text-neutral-400" />            </button>            <button              onClick={handleNext}              className="group/button flex h-7 w-7 items-center justify-center rounded-full bg-gray-100 dark:bg-neutral-800"            >              <IconArrowRight className="h-5 w-5 text-black transition-transform duration-300 group-hover/button:-rotate-12 dark:text-neutral-400" />            </button>          </div>        </div>      </div>    </div>  );};

Usage

import { AnimatedTestimonials } from "@/components/craft-blocks/creative/animated-testimonials/animated-testimonials";

const testimonials = [
  {
    quote:
      "The attention to detail and innovative features have completely transformed our workflow.",
    name: "Sarah Chen",
    designation: "Product Manager at TechFlow",
    src: "https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?q=80&w=3560&auto=format&fit=crop",
  },
  {
    quote:
      "Implementation was seamless and the results exceeded our expectations.",
    name: "Michael Rodriguez",
    designation: "CTO at InnovateSphere",
    src: "https://images.unsplash.com/photo-1438761681033-6461ffad8d80?q=80&w=3540&auto=format&fit=crop",
  },
];

export default function MyComponent() {
  return <AnimatedTestimonials testimonials={testimonials} autoplay />;
}

API

Prop

Type

Testimonial Object

Prop

Type

Features

  • 🖼️ Stacked Image Cards: Each testimonial image is layered in a depth stack with random Y-axis rotations on inactive cards
  • ✨ Word-by-Word Reveal: Quote text animates in one word at a time with a blur-fade effect
  • 🔄 Spring Transitions: Images bounce through a vertical arc (y: [0, -80, 0]) on activation via easeInOut
  • ⬅️➡️ Prev / Next Controls: Arrow buttons with rotate-on-hover affordance for intuitive navigation
  • ⏱️ Autoplay: Optional 5-second interval that auto-advances the carousel
  • 📱 Responsive Layout: Stacks vertically on mobile, side-by-side on md+ screens

Animation Details

Image Stack Transition

  • Activate: opacity 0.7→1, scale 0.95→1, z -100→0, y [0, -80, 0], rotate → 0
  • Deactivate: opacity 1→0.7, scale 1→0.95, rotate → random ±10°
  • Exit: opacity→0, scale→0.9, z→100, duration 0.4s easeInOut

Text Reveal

  • Each word animates: blur(10px)→blur(0), opacity 0→1, y 5→0
  • Staggered delay: 0.02s × word index
  • Left arrow: group-hover:rotate-12
  • Right arrow: group-hover:-rotate-12

Examples

Customer Success Team

const testimonials = [
  {
    quote: "Outstanding support and robust features.",
    name: "Emma Thompson",
    designation: "Customer Success Manager",
    src: "/team/emma.jpg",
  },
  {
    quote: "The scalability has been game-changing for our org.",
    name: "David Park",
    designation: "Support Specialist",
    src: "/team/david.jpg",
  },
];

<AnimatedTestimonials testimonials={testimonials} autoplay />

With Autoplay Disabled

<AnimatedTestimonials testimonials={testimonials} autoplay={false} />

Last updated on