Carousel
The carousel primitive: crossfade or sliding slides, autoplay that pauses on hover and focus, arrows, dot or progress-bar indicators, a play button, keyboard arrows and touch swipe. Autoplay stops under reduced motion.
npx shadcn@latest add https://ui.develop-better-solutions.com/r/carousel.jsonDependencies:
lucide-reactUses:carousel-hooks
Usage
carousel-example.tsx
"use client";
import { Carousel } from "@dbs/ui";
const SLIDES = [
{ id: "a", image: "/samples/hero-landscape.jpg", title: "Painted horizons" },
{ id: "b", image: "/samples/hero-meadow.jpg", title: "Open meadow" },
{ id: "c", image: "/samples/hero-wave.jpg", title: "Calm water" },
];
export default function CarouselExample() {
return (
<div className="grid w-full gap-8">
<Carousel
label="Crossfade carousel"
items={SLIDES}
autoplay={4500}
indicators="bars"
showPlayPause
controls="light"
getKey={(s) => s.id}
viewportClassName="h-[260px] rounded-2xl"
renderSlide={(s) => (
<>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src={s.image} alt={s.title} className="h-full w-full object-cover" />
<p className="absolute bottom-12 left-6 text-2xl font-medium text-white drop-shadow">{s.title}</p>
</>
)}
/>
<Carousel
label="Sliding carousel"
mode="slide"
items={SLIDES}
controls="light"
getKey={(s) => s.id}
viewportClassName="h-[200px] rounded-2xl"
renderSlide={(s) => (
// eslint-disable-next-line @next/next/no-img-element
<img src={s.image} alt={s.title} className="h-full w-full object-cover" />
)}
/>
</div>
);
}


