INFINITYUI
HomeComponentsDocsTemplates
Star

Getting Started

  • Introduction
  • Installation
  • CLI
  • Audit

Navigation

  • Spotlight Navbar
  • Glass DockNEW
  • Animated Tab Bar
  • Circle Menu
  • Magnet Tabs
  • Animated Sidebar
  • Apple Spotlight
  • Page TOC RailNEW

Text

  • Flip Text
  • Glitch Text
  • Liquid Text
  • Flip Fade Text
  • Mask Cursor Effect

Cards

  • Glow Border Card
  • Testimonials Card
  • Interactive Book
  • Trading CardsNEW
  • Hover Image
  • Chain of ThoughtNEW
  • Masonry Grid
  • Image Pile
  • Staggered Grid

Inputs

  • AI InputNEW
  • OTP Input
  • Leave Rating

Buttons

  • Social Flip Button
  • Creepy Button

Loaders

  • Jelly Loader
  • Rolling Ball Scroll
  • Glowing Scroll

Backgrounds

  • Light Lines
  • Perspective Grid
  • Liquid Ocean
  • Eagle Vision
  • Flow Scroll
  • Horizontal Scroll

Overlays

  • PersonaNEW
  • Infinite Moving Cards
  • Masked Avatars
  • Stacked Logos
  • Icon Wheel
  • Pixelated CarouselNEW
  • Pixelated Image Trail
  • Flip Scroll
  • Interactive Folder
  • Animated Folder IconNEW
  • Stack Scroll
  • Rubik Cube
Cards

Testimonials Card

#card#testimonial#carousel
“

“The components are stunning. Our design system is 10x better.”

S

Sarah Chen

Lead Designer at Linear

implementedInfinityUI component

This component is fully implemented in InfinityUI and wired into the docs and registry flow.

Installation

Use the registry command to add the component source, and install any package dependencies if needed.

Infinity Registry

Install the component source into your project with the shadcn CLI.

npx shadcn@latest add https://infinityui-pearl.vercel.app/r/testimonials-card
Package Dependencies

Install the npm packages used by this component source.

npm install framer-motion

Component Code

Copy and paste this code into your component file.

tsx
"use client";

import { useState, useEffect } from "react";
import { motion, AnimatePresence } from "framer-motion";

interface Testimonial {
    quote: string;
    name: string;
    title?: string;
    avatar?: string;
}

interface TestimonialsCardProps {
    testimonials: Testimonial[];
    autoPlay?: boolean;
    interval?: number;
}

export function TestimonialsCard({ testimonials, autoPlay = true, interval = 4000 }: TestimonialsCardProps) {
    const [index, setIndex] = useState(0);
    const [direction, setDirection] = useState(1);

    const go = (next: number) => {
        setDirection(next > index ? 1 : -1);
        setIndex(next);
    };

    useEffect(() => {
        if (!autoPlay) return;
        const t = setInterval(() => {
            setDirection(1);
            setIndex((i) => (i + 1) % testimonials.length);
        }, interval);
        return () => clearInterval(t);
    }, [autoPlay, interval, testimonials.length]);

    const t = testimonials[index];

    return (
        <div className="relative w-full max-w-lg p-8 rounded-2xl bg-zinc-900 border border-white/10 overflow-hidden">
            {/* Quote mark */}
            <span className="absolute top-6 right-8 text-6xl text-white/5 font-serif select-none leading-none">&ldquo;</span>

            <AnimatePresence mode="wait" custom={direction}>
                <motion.div
                    key={index}
                    custom={direction}
                    initial={{ opacity: 0, x: direction * 40 }}
                    animate={{ opacity: 1, x: 0 }}
                    exit={{ opacity: 0, x: -direction * 40 }}
                    transition={{ duration: 0.35, ease: "easeInOut" }}
                >
                    <p className="text-zinc-200 text-base leading-relaxed mb-6">
                        &ldquo;{t.quote}&rdquo;
                    </p>
                    <div className="flex items-center gap-3">
                        <div className="w-10 h-10 rounded-full bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center text-white font-bold text-sm shrink-0">
                            {t.name[0]}
                        </div>
                        <div>
                            <p className="text-white font-semibold text-sm">{t.name}</p>
                            {t.title && <p className="text-zinc-500 text-xs">{t.title}</p>}
                        </div>
                    </div>
                </motion.div>
            </AnimatePresence>

            {/* Dots */}
            <div className="flex items-center gap-1.5 mt-6">
                {testimonials.map((_, i) => (
                    <button
                        key={i}
                        onClick={() => go(i)}
                        className={`h-1.5 rounded-full transition-all duration-300 ${i === index ? "w-5 bg-indigo-400" : "w-1.5 bg-white/20 hover:bg-white/40"}`}
                        aria-label={`Go to testimonial ${i + 1}`}
                    />
                ))}
            </div>
        </div>
    );
}