Back to library
INTERACTION_103

Testimonial Carousel.

Quotes cross-fade and slide with an auto-advancing rhythm. The first quote visible, the rest offset 24px right at 0 opacity before the trigger; sliding the outgoing quote left while the next enters from the right once a 5 second interval, paused on hover and off-screen.

CATEGORY
Cards
COMPLEXITY
Intermediate
TECH
CSS
PLATFORM
Both
PERFORMANCE
Light
LIVE PLAYGROUND
“Shipped in a day”
CSS / CSS
/* Testimonial Carousel — Quotes cross-fade and slide with an auto-advancing rhythm. */
.testimonial-carousel {
  --dur: 520ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --stagger: 60ms;
  will-change: transform, opacity;
}

.testimonial-carousel > * {
  opacity: 0;
  transform: translateY(14px);
  animation: testimonial-carousel-in var(--dur) var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * var(--stagger));
}

/* the first quote visible, the rest offset 24px right at 0 opacity -> sliding the outgoing quote left while the next enters from the right */
@keyframes testimonial-carousel-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .testimonial-carousel > * {
    opacity: 1;
    transform: none;
    animation: none;
  }
}
React / TSX
import { useEffect, useRef } from "react";

/** Testimonial Carousel — trigger: a 5 second interval, paused on hover and off-screen */
export function TestimonialCarousel({ children }: { children: React.ReactNode }) {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
      el.dataset["state"] = "in";
      return;
    }
    const io = new IntersectionObserver(
      ([entry]) => {
        if (entry?.isIntersecting) {
          el.dataset["state"] = "in";
          io.unobserve(el);
        }
      },
      { threshold: 0.2 },
    );
    io.observe(el);
    return () => io.disconnect();
  }, []);

  return (
    <div ref={ref} className="testimonial-carousel" data-state="out">
      {children}
    </div>
  );
}

IF YOU LIKE THIS, STEAL THESE TOO.

INTERACTION_093CSS

Expandable Card

A card grows in place to reveal its detail without a page change.

Cards / LightView
INTERACTION_094CSS

Stacked Cards

Cards stack with depth and fan out on interaction.

Cards / LightView
INTERACTION_097CSS + JS

Cursor Reactive Card

The card content shifts subtly with pointer position.

Cards / LightView
INTERACTION_101CSS

Bento Grid Interaction

Hovering one tile dims and recedes the rest of the grid.

Cards / LightView