All components
Animated Testimonials
testimonialsA testimonials carousel with a stacked image deck and word-by-word blur-in quote animation. Supports autoplay, prev/next navigation, and AnimatePresence-based transitions on both images and text.
responsive · 600px
Install
Same command in any shadcn project — React (Vite/CRA), Next.js, Remix, Astro, and more:
$
npx shadcn@latest add https://your-domain/r/inspira-animated-testimonials.jsonUsage
"use client"
import { AnimatedTestimonials } from "@/registry/inspira-react/animated-testimonials"
const testimonials = [
{
quote: "This component library has completely transformed how our team builds UIs. The animations are buttery smooth and the developer experience is outstanding.",
name: "Sarah Chen",
designation: "Lead Frontend Engineer at Vercel",
image: "https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=500&h=500&fit=crop",
},
{
quote: "I was blown away by how easy it was to integrate these components into our existing codebase. The TypeScript support is first-class and the docs are excellent.",
name: "Marcus Johnson",
designation: "CTO at TechCorp",
image: "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=500&h=500&fit=crop",
},
{
quote: "The animated testimonials component alone saved us days of work. Highly recommend this library to any team building modern React applications.",
name: "Priya Patel",
designation: "Product Designer at Figma",
image: "https://images.unsplash.com/photo-1438761681033-6461ffad8d80?w=500&h=500&fit=crop",
},
]
export default function AnimatedTestimonialsDemo() {
return (
<div className="bg-white dark:bg-gray-950">
<AnimatedTestimonials testimonials={testimonials} autoplay duration={4000} />
</div>
)
}Component source
"use client"
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
import { AnimatePresence, motion } from "motion/react"
interface Testimonial {
quote: string
name: string
designation: string
image: string
}
interface AnimatedTestimonialsProps {
testimonials?: Testimonial[]
autoplay?: boolean
duration?: number
}
export function AnimatedTestimonials({
testimonials = [],
autoplay = false,
duration = 5000,
}: AnimatedTestimonialsProps) {
const [active, setActive] = useState(0)
const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null)
const handleNext = useCallback(() => {
setActive((prev) => (prev + 1) % testimonials.length)
}, [testimonials.length])
const handlePrev = useCallback(() => {
setActive((prev) => (prev - 1 + testimonials.length) % testimonials.length)
}, [testimonials.length])
const isActive = (index: number) => index === active
// Stable random rotations per testimonial to avoid re-renders flickering
const rotations = useMemo(
() => testimonials.map(() => Math.floor(Math.random() * 21) - 10),
// eslint-disable-next-line react-hooks/exhaustive-deps
[testimonials.length]
)
useEffect(() => {
if (!autoplay) return
intervalRef.current = setInterval(handleNext, duration)
return () => {
if (intervalRef.current) clearInterval(intervalRef.current)
}
}, [autoplay, duration, handleNext])
const activeTestimonial = testimonials[active]
const words = activeTestimonial?.quote.split(" ") ?? []
if (!testimonials.length) return null
return (
<div className="mx-auto max-w-sm px-4 py-20 font-sans antialiased md:max-w-4xl md:px-8 lg:px-12">
<div className="relative grid grid-cols-1 gap-20 md:grid-cols-2">
{/* Image stack */}
<div>
<div className="relative h-80 w-full">
<AnimatePresence>
{testimonials.map((testimonial, index) => (
<motion.div
key={testimonial.image}
initial={{
opacity: 0,
scale: 0.9,
z: -100,
rotate: rotations[index],
}}
animate={{
opacity: isActive(index) ? 1 : 0.7,
scale: isActive(index) ? 1 : 0.95,
z: isActive(index) ? 0 : -100,
rotate: isActive(index) ? 0 : rotations[index],
zIndex: isActive(index) ? 40 : testimonials.length + 2 - index,
y: isActive(index) ? [0, -80, 0] : 0,
}}
exit={{
opacity: 0,
scale: 0.9,
z: 100,
rotate: rotations[index],
}}
transition={{
duration: 0.4,
ease: "easeInOut",
}}
className="absolute inset-0 origin-bottom"
>
<img
src={testimonial.image}
alt={testimonial.name}
width={500}
height={500}
draggable={false}
className="size-full rounded-3xl object-cover object-center"
/>
</motion.div>
))}
</AnimatePresence>
</div>
</div>
{/* Text content */}
<div className="flex flex-col justify-between 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-2xl font-bold text-black dark:text-white">
{activeTestimonial?.name}
</h3>
<p className="text-sm text-gray-500 dark:text-neutral-500">
{activeTestimonial?.designation}
</p>
<motion.p className="mt-8 text-lg text-gray-500 dark:text-neutral-300">
{words.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}
</motion.span>
))}
</motion.p>
</motion.div>
{/* Navigation */}
<div className="flex gap-4 pt-12 md:pt-0">
<button
type="button"
onClick={handlePrev}
className="group/button flex size-7 items-center justify-center rounded-full bg-gray-100 dark:bg-neutral-800"
aria-label="Previous testimonial"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className="size-5 text-black transition-transform duration-300 group-hover/button:rotate-12 dark:text-neutral-400"
>
<path d="M19 12H5" />
<path d="M12 19l-7-7 7-7" />
</svg>
</button>
<button
type="button"
onClick={handleNext}
className="group/button flex size-7 items-center justify-center rounded-full bg-gray-100 dark:bg-neutral-800"
aria-label="Next testimonial"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className="size-5 text-black transition-transform duration-300 group-hover/button:-rotate-12 dark:text-neutral-400"
>
<path d="M5 12h14" />
<path d="M12 5l7 7-7 7" />
</svg>
</button>
</div>
</div>
</div>
</div>
)
}