For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
Shadcn Labs/

Carousel

Slides push in like a track from the side you moved toward. A React component built on View Transitions, installed with the shadcn CLI.

Aurora Ridge

Lofoten, Norway

01 / 05

Installation

$ pnpm dlx shadcn@latest add @transition-kit/carousel

Usage

import {
  Carousel,
  CarouselContent,
  CarouselDots,
  CarouselItem,
  CarouselNext,
  CarouselPrevious,
} from "@/components/transitions/carousel";
<Carousel loop aria-label="Featured places">
  <CarouselContent>
    <CarouselItem className="border bg-card p-6">Aurora Ridge</CarouselItem>
    <CarouselItem className="border bg-card p-6">Copper Dunes</CarouselItem>
    <CarouselItem className="border bg-card p-6">Tide Pools</CarouselItem>
  </CarouselContent>
  <div className="flex items-center justify-between">
    <CarouselPrevious />
    <CarouselDots />
    <CarouselNext />
  </div>
</Carousel>
<Carousel loop autoplay={5000} aria-label="Featured places">
  ...
</Carousel>
const [index, setIndex] = React.useState(0);
 
<Carousel index={index} onIndexChange={setIndex} aria-label="Screenshots">
  ...
</Carousel>;
const Counter = () => {
  const { count, index } = useCarousel();
  return (
    <span className="text-sm text-muted-foreground tabular-nums">
      {index + 1} / {count}
    </span>
  );
};

API Reference

PropTypeDefaultDescription
indexnumber-Controlled slide on screen.
defaultIndexnumber0Initial slide when uncontrolled.
onIndexChange(index: number) => void-Called with the new slide index after each move.
loopbooleanfalseWraps from the last slide to the first and back.
autoplaynumber (ms)-Advances every N milliseconds. Pauses on hover, keyboard focus, a hidden tab and reduced motion; without loop it rewinds to the first slide after the last. The root gets data-autoplay="playing" or "paused".

useCarousel

ReturnTypeDescription
indexnumberThe current slide index.
countnumberThe total number of slides.
loopbooleanWhether wrapping is on.
playingbooleanWhether autoplay is running.
canPreviousbooleanWhether moving back is possible.
canNextbooleanWhether moving forward is possible.
goTo(index: number) => voidMoves to the slide index.
previous() => voidMoves one slide back.
next() => voidMoves one slide forward.