Component guideEditable source

Carousel

A swipeable sequence with previous and next controls, powered by Embla.

Original component docs
On this page5 sectionsBack to top

Use Carousel for a short sequence that benefits from horizontal or vertical browsing. Do not hide essential information exclusively in later slides. Leave room for navigation buttons positioned outside the track.

Live preview
Loading preview...

#Installation

Complete the base setup. For manual installation:

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/carousel.json

The live preview additionally uses Card. Install it before copying the Code example:

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/card.json

#Usage

import {
  Carousel,
  CarouselContent,
  CarouselItem,
  CarouselNext,
  CarouselPrevious,
} from "@/components/ui/carousel";

export default function Highlights() {
  return (
    <div className="px-12">
      <Carousel className="w-full max-w-sm" aria-label="Project highlights">
        <CarouselContent>
          {["Plan", "Build", "Review"].map((title) => (
            <CarouselItem key={title}>
              <div className="border-2 border-border p-8">{title}</div>
            </CarouselItem>
          ))}
        </CarouselContent>
        <CarouselPrevious />
        <CarouselNext />
      </Carousel>
    </div>
  );
}

#API reference

Prop / partPurposeDefault
orientationhorizontal or verticalhorizontal
optsEmbla options such as align and loopEmbla defaults
pluginsExplicitly installed Embla pluginsNone
setApiReceives the Embla API—
CarouselContent / CarouselItemTrack and slides—
CarouselPrevious / CarouselNextBoundary-aware navigation buttonsIcon buttons
CarouselPrevious.variant / sizePrevious button appearance and sizenoShadow / icon
CarouselNext.variant / sizeNext button appearance and sizenoShadow / icon

#Accessibility

Name the carousel region and provide meaningful slide content. Keep navigation buttons available for people who cannot swipe. Autoplay is not included; adding it requires pause controls and reduced-motion support. Give a vertical carousel a definite height and test the layout on narrow screens.

Left and right arrow shortcuts apply when the carousel region or its navigation buttons have focus. Add tabIndex={0} to make the region focusable. Inputs and other controls inside a slide keep their own keyboard behavior.

Navigation buttons accept state-based className functions. Their onClick handlers run before scrolling; call event.preventDefault() to cancel that button's navigation.

#Slides with inputs

Also install Input, Label, and Slider for this example.

Loading preview...