testimonal-slider
eldoraui/testimonal-sliderFreeComponent
A testimonial slider component.
Live preview
live · rendered by the registry
Rendered by eldoraui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://eldoraui.site/r/testimonal-slider.jsonSource
1"use client"23import { useEffect, useRef, useState } from "react"4import Image from "next/image"5import { Transition } from "@headlessui/react"67interface Testimonial {8 img: string9 quote: string10 name: string11 role: string12}1314export default function FancyTestimonialsSlider({15 testimonials,16 autorotateTiming = 7000,17}: {18 testimonials: Testimonial[]19 autorotateTiming?: number20}) {21 const testimonialsRef = useRef<HTMLDivElement>(null)22 const [active, setActive] = useState<number>(0)23 const [autorotate, setAutorotate] = useState<boolean>(true)2425 useEffect(() => {26 if (!autorotate) return27 const interval = setInterval(() => {28 setActive(active + 1 === testimonials.length ? 0 : (active) => active + 1)29 }, autorotateTiming)30 return () => clearInterval(interval)31 }, [active, autorotate])3233 const heightFix = () => {34 if (testimonialsRef.current && testimonialsRef.current.parentElement)35 testimonialsRef.current.parentElement.style.height = `${testimonialsRef.current.clientHeight}px`36 }3738 useEffect(() => {39 heightFix()40 }, [])4142 return (43 <div className="mx-auto w-full max-w-3xl px-4 text-center sm:px-6">44 {/* Testimonial image */}45 <div className="relative h-24 sm:h-32">46 <div className="pointer-events-none absolute top-0 left-1/2 h-[320px] w-[320px] -translate-x-1/2 before:absolute before:inset-0 before:-z-10 before:rounded-full before:bg-gradient-to-b before:from-cyan-500/25 before:via-cyan-500/5 before:via-25% before:to-cyan-500/0 before:to-75% sm:h-[480px] sm:w-[480px]">47 <div className="h-24 [mask-image:_linear-gradient(0deg,transparent,theme(colors.white)_20%,theme(colors.white))] sm:h-32">48 {testimonials.map((testimonial, index) => (49 <Transition50 as="div"51 key={index}52 show={active === index}53 className="absolute inset-0 -z-10 h-full"54 enter="transition ease-[cubic-bezier(0.68,-0.3,0.32,1)] duration-700 order-first"55 enterFrom="opacity-0 -rotate-[60deg]"56 enterTo="opacity-100 rotate-0"57 leave="transition ease-[cubic-bezier(0.68,-0.3,0.32,1)] duration-700"58 leaveFrom="opacity-100 rotate-0"59 leaveTo="opacity-0 rotate-[60deg]"60 beforeEnter={() => heightFix()}61 >62 <Image63 className="relative top-8 left-1/2 -translate-x-1/2 rounded-full sm:top-11"64// … truncated
What it pulls in
npm packages
Files it writes
More from eldoraui
All 115 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| animated-badgeanimated-badge | eldoraui | Components | Free | 2 deps | |
| animated-frameworksanimated-frameworks | eldoraui | Components | Free | 2 deps | |
| animated-grid-patternanimated-grid-pattern | eldoraui | Components | Free | 3 deps | |
| animated-listanimated-list | eldoraui | Components | Free | 1 dep | |
| animated-shiny-buttonanimated-shiny-button | eldoraui | Components | Free | 1 dep | |
| blur-in-textblur-in-text | eldoraui | Components | Free | 3 deps | |
| browserbrowser | eldoraui | Components | Free | 2 deps | |
| card-flip-hovercard-flip-hover | eldoraui | Components | Free | 1 dep |
