Updated
Testimonial Carousel
Customize
Interval2s
Snug
Installation
npx shadcn@latest add https://uibrik.com/r/testimonial-carousel.jsonInstall the packages
npm install motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/testimonial-carousel/testimonial-carousel.tsx"use client"; import { useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent, type PointerEvent } from "react"; import { animate, motion, useMotionValue, useReducedMotion } from "motion/react"; import { cn } from "@/lib/utils"; // Testimonial carousel. One quote at a time, set large, with a faint oversized // quote mark behind it and the pager under it. Every quote sits in the same // grid cell and only the visible one is painted; the others are faded out and // inert. // // Two ways to size the frame. "snug" eases its real height to the quote on // show, so a short quote sits close to the pager and the pager follows. The // text never scales: the old quote is gone before the height moves, and the // new one fades in once there is room. "tallest" holds the frame at the // longest quote and anchors each one to its bottom, so the pager never moves. // // Swipe or drag sideways to step, or use the arrow keys once the pager has // focus. While dragging, the quote leans a little with the pointer and springs // back when let go. export type Testimonial = { quote: string; name: string;
Adds the files to
components/uibrik/testimonial-carousel and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/testimonial-carousel.Usage
import { TestimonialCarousel } from "@/components/uibrik/testimonial-carousel/testimonial-carousel";const testimonials = [ { quote: "We replaced three tools with this one. The team stopped asking where things live.", name: "Maya Chen", role: "Head of Product, Northwind", avatar: "/registry/testimonial-carousel/maya.webp", }, { quote: "Setup took an afternoon. Six months later nobody has needed to think about it, which is exactly what we wanted from the infrastructure underneath our whole release process.", name: "Daniel Okafor", role: "Engineering Lead, Fieldnote", avatar: "/registry/testimonial-carousel/daniel.webp", }, // …2 more];<TestimonialCarousel autoplay interval={2} fit="snug" testimonials={testimonials}/>Where to use Testimonial Carousel
Single-quote sections
One large quote at a time over a faint quote mark gives each customer full attention.
Case study highlights
The frame easing to each quote's height handles short and long quotes.
Service sites
Swipe and arrow keys make it accessible on mobile and desktop.
Props
TestimonialCarousel- autoplay
- Type boolean
- true
- Advance on a timer. Pauses while the pointer or focus is inside.
- interval
- Type number
- 2
- How long each quote stays with autoplay on.
- fit
- Type "snug" | "tallest"
- "snug"
- Snug eases the height to each quote, so the pager follows. Tallest holds the height of the longest quote, so the pager never moves.
- testimonials
- Type { quote: string; name: string; role?: string; avatar?: string }[]
- 4 sample quotes
- The testimonials, in order.
- className
- Type string
- –
- Classes for the wrapper.