Components

Carousel

A dependency-free React carousel and slider built on Motion and Tailwind CSS: swipe or drag with momentum and snap-to-slide springs, Previous / Next buttons, dots, arrow keys, an endless loop and autoplay that pauses on hover and focus — plus a 3D coverflow variant. No Embla, fully accessible.

  • No Embla
  • Drag & swipe with momentum
  • Loop & autoplay
  • 3D coverflow
  • WAI-ARIA carousel
  • prefers-reduced-motion

Aurora

Northern lights over the fjord

Ember

Last light on the dunes

Tide

Low tide at blue hour

Bloom

Spring in the night garden

Market

Rain on the market street

Installation

$ npx shadcn@latest add https://duskui.com/r/carousel.json

The Previous / Next and play buttons use the DuskUI Button, which the registry installs for you. Same part names as shadcn's Carousel, but no embla-carousel-react.

Usage

gallery.tsx
import {
  Carousel,
  CarouselContent,
  CarouselDots,
  CarouselItem,
  CarouselNext,
  CarouselPrevious,
} from "@/components/dusk/carousel/carousel"

export function Gallery({ photos }: { photos: { src: string; alt: string }[] }) {
  return (
    <Carousel loop aria-label="Gallery">
      <CarouselContent>
        {photos.map((photo) => (
          <CarouselItem key={photo.src}>
            <img src={photo.src} alt={photo.alt} className="rounded-xl" />
          </CarouselItem>
        ))}
      </CarouselContent>
      <div className="mt-4 flex items-center justify-between">
        <CarouselPrevious />
        <CarouselDots />
        <CarouselNext />
      </div>
    </Carousel>
  )
}

Examples

Several per view

Size slides with basis-* on CarouselItem and space them with gap-* on CarouselContent. Without loop the track stops at the last slide and dots cover only the reachable positions. Tabbing to a hidden card slides it into view, and a drag never clicks the link under it.

Autoplay

autoplay takes true (every 5s) or an interval in ms. It pauses while hovered, dragged, focused from the keyboard or in a background tab, and stays off under reduced motion unless the user presses play. CarouselPlayToggle provides the pause control WCAG requires.

“The smoothest carousel I've shipped — and no extra dependency.”
Mia Chen · Design engineer
“Keyboard, swipe and screen readers all just work.”
Leo Park · Accessibility lead
“Autoplay that actually pauses when you look at it. Finally.”
Ava Singh · Product designer
“It respects reduced motion out of the box.”
Kai Moreno · Frontend developer

Blocks

Variations built on Carousel. Each installs on its own and pulls in Carousel automatically.

The selected slide faces you while its neighbours tilt away, recede and dim — driven every frame by the track's motion value, so it follows your finger mid-drag. Swap CarouselItem for CoverflowItem and give slides a width smaller than the viewport. Build your own effects the same way with useCarouselSlide().

Midnight Drive

Coastline

Low Tide

Harbor

Mint Condition

Dusk FM

Golden Hour

Sol

Static

Signal

Bloom

Petal

$ npx shadcn@latest add https://duskui.com/r/coverflow-carousel.json
PropTypeDefaultDescription
rotatenumber42Max tilt of side slides, in degrees (halved under reduced motion).
depthnumber140How far side slides recede, in px.
overlapnumber0.18How much side slides tuck in behind the selected one (0–0.5).
loopbooleantrueLoops by default; all other Carousel props apply (align is always center).

API Reference

Carousel also accepts any div prop. Parts: CarouselContent (viewport + track; className goes to the track, viewportClassName to the viewport), CarouselItem, CarouselPrevious, CarouselNext, CarouselDots and CarouselPlayToggle. Hooks: useCarousel() for custom controls and useCarouselSlide() for per-slide effects.

PropTypeDefaultDescription
loopbooleanfalseWrap around endlessly. With too few slides to fill the loop, the arrows rewind instead.
align"start" | "center""start"Where the selected slide rests.
autoplayboolean | numberfalseAdvance automatically: true for 5s, or an interval in ms.
defaultIndexnumber0Snap selected on mount.
onIndexChange(index: number) => void—Called when the selected snap changes.
draggablebooleantrueAllow dragging and swiping.
aria-labelstring"Carousel"Names the carousel region. Make it specific.
useCarousel(){ selected, snapCount, canPrev, canNext, prev, next, goTo, playing, togglePlaying }—State and actions for custom controls inside <Carousel>.
useCarouselSlide(){ index, count, progress: MotionValue<number> }—Inside a CarouselItem: distance from rest in slides (0 = selected), updated per frame.

Accessibility

  • The root is a region with aria-roledescription="carousel" and your aria-label; each slide is a group with aria-roledescription="slide" and a label like “3 of 5”, per the WAI-ARIA carousel pattern.
  • Left / Right arrow keys move between slides while focus is inside. Tabbing to a slide's content scrolls it into view, and the viewport uses overflow: clip so focus can't scroll it out of sync.
  • Previous / Next use aria-disabled at the ends so focus is kept; dots mark the selected slide with aria-current and every control has aria-controls pointing at the track.
  • User-initiated changes are announced politely (“Slide 2 of 5”); autoplay changes are not.
  • Autoplay pauses on hover, keyboard focus, drag and hidden tabs, includes a pause / play button, and is off under prefers-reduced-motion until the user starts it.
  • Under prefers-reduced-motion slides change instantly instead of springing.