Shadcn Carousel
React carousel for product galleries and testimonials. Built with TypeScript and Tailwind CSS for Next.js using Base UI — swipe, sizes, plugins, and RTL.
A carousel is a track of slides you swipe or step through with arrows. One item fills the row by default; set basis on CarouselItem to show more. Use it for product photos, quote rows, and any list that should not take the whole page.
Looking for a neobrutalism version for shadcn?
Same carousel, thicker borders. The NeoBrutalism carousel is the kit if you want that look.
Usage
import {
Carousel,
CarouselContent,
CarouselItem,
CarouselNext,
CarouselPrevious,
} from "@/components/ui/carousel"<Carousel>
<CarouselContent>
<CarouselItem>1</CarouselItem>
<CarouselItem>2</CarouselItem>
<CarouselItem>3</CarouselItem>
</CarouselContent>
<CarouselPrevious />
<CarouselNext />
</Carousel>Items default to basis-full. opts goes to Embla — align: "start" and loop: true are the usual ones.
Composition
Sizes
basis-1/2 or lg:basis-1/3 on CarouselItem. Default is basis-full.
Spacing
Override the default pl-4 / -ml-4. pl-1 on the item, -ml-1 on the content.
Orientation
orientation="vertical". Give CarouselContent a height or the track collapses.
API
setApi gives you the Embla instance. selectedScrollSnap() is the current index.
Plugins
plugins={[Autoplay({ delay: 2000 })]}. Stop on hover with the plugin’s stop and reset.
RTL
Wrap with DirectionProvider and dir="rtl". Set opts.direction to "rtl" and rotate the arrows with rtl:rotate-180.
API Reference
Prop
Type
CarouselPrevious / CarouselNext
Prop
Type
CarouselContent and CarouselItem take className. Import CarouselApi when you use setApi.
Keyboard
| Key | Action |
|---|---|
ArrowLeft | Previous slide |
ArrowRight | Next slide |
Left and right still fire when the track is vertical.
Notes
Arrows sit outside the track
CarouselPrevious is absolute -left-12. Give the carousel a max-width and pad the parent or the buttons clip.
opts.loop keeps both arrows enabled at the ends.
With other components
Each slide is a card
ButtonPrev and next chrome
Aspect RatioPhotos keep their frame
BadgeSale tag on a slide
AvatarFace on a quote
DialogOpen the full photo
Questions
Related
Was this page helpful?
Sign in to leave feedback.
Card
React card for login forms, settings, and product tiles. Built with TypeScript and Tailwind CSS for Next.js using Base UI — header, content, footer, and an action slot.
Chart
React chart for dashboards and analytics. Built with TypeScript and Tailwind CSS for Next.js using Base UI — themed tooltips, legends, and CSS variable colors.