Make your AI a shadcn expert

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.

Scroll to load preview...

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

CarouselItem
CarouselItem
CarouselPrevious
CarouselNext

Sizes

basis-1/2 or lg:basis-1/3 on CarouselItem. Default is basis-full.

Scroll to load preview...

Spacing

Override the default pl-4 / -ml-4. pl-1 on the item, -ml-1 on the content.

Scroll to load preview...

Orientation

orientation="vertical". Give CarouselContent a height or the track collapses.

Scroll to load preview...

API

setApi gives you the Embla instance. selectedScrollSnap() is the current index.

Scroll to load preview...

Plugins

plugins={[Autoplay({ delay: 2000 })]}. Stop on hover with the plugin’s stop and reset.

Scroll to load preview...

RTL

Wrap with DirectionProvider and dir="rtl". Set opts.direction to "rtl" and rotate the arrows with rtl:rotate-180.

Scroll to load preview...

API Reference

Prop

Type

CarouselPrevious / CarouselNext

Prop

Type

CarouselContent and CarouselItem take className. Import CarouselApi when you use setApi.

Keyboard

KeyAction
ArrowLeftPrevious slide
ArrowRightNext 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

Questions

Was this page helpful?

Sign in to leave feedback.