Installation
Run this in a project that already uses shadcn/ui. The CLI adds the block, its components and npm dependencies.
pnpm dlx shadcn@latest add https://ui.sumansharma.info.np/r/testimonials-7.jsonPrefer to iterate with AI?Open in
Usage
The CLI writes the block to components/testimonials.tsx. Import it anywhere:
Loading...
Source
The CLI writes this component to components/testimonials.tsx.
'use client'
import { useState, useEffect } from 'react'
import Image from 'next/image'
import * as motion from 'motion/react-client'
import { Star, ChevronLeft, ChevronRight, Quote } from 'lucide-react'
import { AnimatePresence } from 'motion/react'
const testimonials = [
{
quote: 'Staying with a local family in Pokhara through PahunaHomes was the highlight of my Nepal trip. The warmth and hospitality were truly special. I felt like I was part of the family within hours of arriving.',
author: 'Emma Thompson',
location: 'Australia',
image: 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=800&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8YXZhdGFyfGVufDB8fDB8fHww',
rating: 5,
},
{
quote: 'PahunaHomes found us the perfect mountain retreat near Everest. The views were breathtaking, and our host made us feel like family. They shared local stories and traditions that made our experience truly authentic.',
author: 'Michael Chen',
location: 'United States',
image: 'https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=800&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8M3x8YXZhdGFyfGVufDB8fDB8fHww',
rating: 5,
},
{
quote: 'As a solo female traveler, safety was my priority. PahunaHomes connected me with a wonderful family in Kathmandu who looked after me like their daughter. They even taught me how to cook traditional Nepali dishes!',
author: 'Sophie Dubois',
location: 'France',
image: 'https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=800&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MTB8fGF2YXRhcnxlbnwwfHwwfHx8MA%3D%3D',
rating: 5,
},
{
quote: 'The cultural immersion we experienced through our PahunaHomes stay was incredible. Our host family invited us to participate in a local festival, which became the most memorable part of our journey through Nepal.',
author: 'James Wilson',
location: 'United Kingdom',
image: 'https://plus.unsplash.com/premium_photo-1670884442192-7b58d513cd55?w=800&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MTN8fGF2YXRhcnxlbnwwfHwwfHx8MA%3D%3D',
rating: 5,
},
]
export default function TestimonialsSection() {
const [currentIndex, setCurrentIndex] = useState(0)
const [isAutoPlaying, setIsAutoPlaying] = useState(true)
const [direction, setDirection] = useState(0)
const nextTestimonial = () => {
setDirection(1)
setCurrentIndex((prev) => (prev === testimonials.length - 1 ? 0 : prev + 1))
}
const prevTestimonial = () => {
setDirection(-1)
setCurrentIndex((prev) => (prev === 0 ? testimonials.length - 1 : prev - 1))
}
useEffect(() => {
if (!isAutoPlaying) return
const interval = setInterval(() => {
nextTestimonial()
}, 8000)
return () => clearInterval(interval)
}, [isAutoPlaying])
const handleMouseEnter = () => setIsAutoPlaying(false)
const handleMouseLeave = () => setIsAutoPlaying(true)
const variants = {
enter: (direction: number) => ({
x: direction > 0 ? 200 : -200,
opacity: 0,
}),
center: {
x: 0,
opacity: 1,
},
exit: (direction: number) => ({
x: direction > 0 ? -200 : 200,
opacity: 0,
}),
}
return (
<section
className="bg-white py-24 dark:bg-gray-900"
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}>
<div className="container mx-auto px-4">
<motion.div
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
transition={{ duration: 0.5 }}
viewport={{ once: true }}
className="mb-16 text-center">
<span className="mb-2 inline-block font-medium text-teal-600 dark:text-teal-400">Guest Experiences</span>
<h2 className="mb-4 text-4xl font-bold text-teal-800 md:text-5xl dark:text-teal-200">What Our Guests Say</h2>
<p className="mx-auto max-w-3xl text-lg text-gray-700 dark:text-gray-300">Real stories from travelers who experienced the magic of Nepali hospitality through PahunaHomes.</p>
</motion.div>
<div className="relative mx-auto max-w-4xl">
<div className="absolute -left-12 -top-12 text-teal-200 opacity-50 dark:text-teal-700">
<Quote size={80} />
</div>
<div className="relative overflow-hidden rounded-xl bg-teal-50 p-8 md:p-12 dark:bg-teal-800">
<AnimatePresence
initial={false}
custom={direction}
mode="wait">
<motion.div
key={currentIndex}
custom={direction}
variants={variants}
initial="enter"
animate="center"
exit="exit"
transition={{ duration: 0.5, ease: 'easeInOut' }}
className="flex flex-col items-center gap-8 md:flex-row">
<div className="relative h-24 w-24 flex-shrink-0 overflow-hidden rounded-full border-4 border-white shadow-lg md:h-32 md:w-32 dark:border-gray-700">
<Image
src={testimonials[currentIndex].image || '/placeholder.svg'}
alt={testimonials[currentIndex].author}
fill
className="object-cover"
/>
</div>
<div className="text-center md:text-left">
<div className="mb-4 flex justify-center md:justify-start">
{[...Array(testimonials[currentIndex].rating)].map((_, i) => (
<Star
key={i}
className="h-5 w-5 fill-current text-yellow-400"
/>
))}
</div>
<blockquote className="mb-6 text-lg italic text-gray-700 md:text-xl dark:text-gray-300">{testimonials[currentIndex].quote}</blockquote>
<div>
<p className="font-bold text-teal-800 dark:text-teal-200">{testimonials[currentIndex].author}</p>
<p className="text-teal-600 dark:text-teal-400">{testimonials[currentIndex].location}</p>
</div>
</div>
</motion.div>
</AnimatePresence>
</div>
{/* Navigation */}
<div className="mt-8 flex justify-center gap-2">
{testimonials.map((_, index) => (
<button
key={index}
onClick={() => {
setDirection(index > currentIndex ? 1 : -1)
setCurrentIndex(index)
}}
className={`h-3 w-3 rounded-full transition-all duration-300 ${currentIndex === index ? 'w-8 bg-teal-600 dark:bg-teal-400' : 'bg-teal-200 dark:bg-teal-700'}`}
aria-label={`Go to testimonial ${index + 1}`}
/>
))}
</div>
{/* Arrow navigation */}
<button
onClick={prevTestimonial}
className="absolute -left-4 top-1/2 -translate-y-1/2 rounded-full bg-white p-3 text-teal-600 shadow-lg transition-colors hover:text-teal-800 md:-left-8 dark:bg-gray-800 dark:text-teal-400 dark:hover:text-teal-200"
aria-label="Previous testimonial">
<ChevronLeft className="h-6 w-6" />
</button>
<button
onClick={nextTestimonial}
className="absolute -right-4 top-1/2 -translate-y-1/2 rounded-full bg-white p-3 text-teal-600 shadow-lg transition-colors hover:text-teal-800 md:-right-8 dark:bg-gray-800 dark:text-teal-400 dark:hover:text-teal-200"
aria-label="Next testimonial">
<ChevronRight className="h-6 w-6" />
</button>
</div>
</div>
</section>
)
}
More testimonials blocks
View all 7 →- Testimonials 101Bento grid of testimonial cards with avatars and company logos.
- Testimonials 202Testimonial cards in an asymmetric grid with a featured quote.
- Testimonials 303Single large testimonial with a company logo and author.
- Testimonials 404Single testimonial with an avatar and author details.
- Testimonials 505Masonry wall of short community testimonials.
- Testimonials 606Multi-column testimonial wall with avatars and handles.