Skip to content

React Carousel

A glass React carousel you can swipe, drag or flick, with an endless loop, responsive slides per view and autoplay that pauses on hover and focus.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/carousel.json
Dunes
Glacier
Forest
  • Carousel
  • CarouselCaption
  • defaultCarouselLabels
  • +1 more

One slide per view, loop, overlay arrows, autoplay every 5 s. The active dot fills as the next slide nears; hover, drag or Tab into it to pause, and use the pause button to stop it. Under reduced motion autoplay waits for Play. The overlay arrows sit on a page-colored veil with a two-tone focus ring, so they stay legible on any image; ←/→ work on them too.

Aurora

Violet light over a frozen lake

1/5

Ember

The last hour of a desert day

2/5

Lagoon

Shallow water, twelve shades of teal

3/5

Bloom

A field of late spring tulips

4/5

Meadow

Morning haze over the hills

5/5

Files to copy

8 folders · 13 files · 4 packages
From theme/src/
  • components/carousel/carousel.tsx
  • components/button/
  • components/carousel/parts/
  • components/spinner/
  • hooks/{use-direction.ts, use-intersection.ts, use-latest.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts}
  • motion/{gate.ts, tokens.ts}
  • lib/{cn.ts, form.ts, math.ts, state-light.tsx}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/carousel.jsonRegistry item: carousel. The styles need the Tailwind v4 glass UI setup.
The examples also use
  • components/carousel/carousel-caption.tsx
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Responsive cards

Slides per view follow the carousel's own width: 1.15 on phones (a peek of the next card), 2 from 560px, 3 from 900px. Arrows move a page at a time; the ends rubber-band. With several cards in view, the dots and announcements name the range (“Slides 4 to 6 of 6”).

BlockFree

Glass login

Email + password, social sign-in and a shimmering submit.

ComponentFree

Data table

Sorting, filters, selection, CSV export and a dense mode.

Template$49

Dashboard kit

Charts, stat tiles and a sidebar shell, wired together.

BlockFree

Checkout

Order summary, card fields and a confident pay button.

Template$29

Docs theme

MDX pages, code blocks, search and a table of contents.

BlockFree

Onboarding

Steps, progress and an empty state that invites action.

Centered, with depth

align="center" with a fractional view and loop: neighbors peek on both sides. effect="scale" shrinks slides as they leave the center (transform only, follows your finger while dragging).

“The glass finally looks like glass, and our contrast audit passed on the first try.”
Asha VermaDesign lead, Northwind
“Reduced motion is respected everywhere. I didn't have to file a single bug.”
Ravi KumarFrontend, Lumen
“We shipped the dashboard in a week. The charts alone saved us a month.”
Meera IyerFounder, Tidal
“Copy the folder, done. No black-box package, no lock-in.”
Kabir ShahEngineer, Orbit
“Our customers keep asking which design system we use.”
Sara KhanPM, Fieldnote

Right to left

In a right-to-left page the first slide sits on the right, Next moves leftwards, the arrows and the dot pill mirror and ←/→ swap meaning. Every string comes from labels, here in Arabic.

الشفق

ضوء بنفسجي فوق بحيرة متجمدة

1/3

جمر

آخر ساعة من نهار الصحراء

2/3

بحيرة

مياه ضحلة بدرجات الفيروز

3/3

Props

PropTypeDefaultDescription
childrenReactNodeNoneEach child becomes one slide of the carousel.
aria-label (required)stringNoneAccessible name of the carousel, e.g. "Featured products". Required.
slidesPerViewnumber | Record<number, number>1Slides visible at once. A number, or breakpoints keyed by the carousel's own width in px (container width, not the window): { 0: 1.15, 640: 2, 1024: 3 }. Fractions show a peek of the next slide.
gapnumber16Sets the space left between slides, in px.
align"center" | "start""start"Where the current slide sits: at the start, or centred (great with a fractional view + loop).
loopbooleanfalseEndless in both directions. Needs enough slides to fill the view plus one; otherwise it rewinds.
slidesToScrollnumber | "page"1How far the arrows move: a number of slides, or "page" (the slides in view).
autoplaynumber | booleanfalseAdvance on its own: true (every 5 s) or an interval in ms. Never starts by itself under reduced motion.
arrowsfalse | "bottom" | "overlay""bottom""bottom": in the control row. "overlay": floating on the slides' edges. false: none.
dotsbooleantrueShow the dots (a "3 / 12" counter replaces them when they don't fit).
indexnumberNoneControlled position (snap index; with loop, the slide index). Update it from onIndexChange.
defaultIndexnumber0Sets the starting position when uncontrolled.
onIndexChange((index: number) => void)NoneA user or autoplay move asks for a new position (never fired on mount or when following index).
effect"none" | "scale""none""scale": slides away from the current one shrink a little (transform only).
labelsPartial<CarouselLabels>defaultCarouselLabelsEvery other string, for translation: labels={{ carousel: "…" }}; omitted keys keep the English of defaultCarouselLabels. All 14 keys of CarouselLabels are listed in the key table under the props table.
slideClassNamestringNoneAdds extra classes to each slide wrapper.
viewportClassNamestringNoneAdds extra classes to the clipping viewport.
CarouselLabels keys and English defaults (14)
Pass any key in labels; the rest keep the defaults of defaultCarouselLabels.
KeyEnglish default
carouselcarousel
slideslide
slideLabel(i, n) => `${i} of ${n}`
previousPrevious slide
nextNext slide
goTo(i) => `Slide ${i}`
goToRange(a, b) => `Slides ${a} to ${b}`
pickerChoose a slide
playStart automatic slide show
pausePause automatic slide show
status(i, n) => `Slide ${i} of ${n}`
statusRange(a, b, n) => `Slides ${a} to ${b} of ${n}`
counter(i, n) => `${i} / ${n}`
viewportSlides

CarouselCaption props

PropTypeDefaultDescription
position"top" | "bottom""bottom"Where the bar sits on the slide: "bottom" or "top".

Keyboard

KeysAction
TabReach the pause button, the dots and the arrows.
Arrow Left/Arrow RightPrevious or next slide (swapped in right-to-left pages).
Home/EndFirst or last slide.
Enter/SpacePress the focused button (Play or Pause, an arrow, a dot).

Accessibility

  • Follows the WAI-ARIA carousel pattern: aria-roledescription="carousel", slides as groups named "3 of 8", and a polite live region that announces the slide after you navigate.
  • Off-screen slides are inert. Autoplay pauses on hover, drag, a hidden tab or when off-screen, and stops for good when keyboard focus enters (press Play to resume).
  • Under reduced motion autoplay does not start and slides change without a glide.

All exports on this page

  • Carousel — Swipeable slides with arrows, dots, autoplay and loop.
  • CarouselCaption — A caption bar for a slide that is an image.
  • defaultCarouselLabels — The English strings of Carousel.
  • Use it as a React carousel with swipe for a product gallery with one slide per view, loop, overlay arrows and autoplay every five seconds, where users can also swipe, drag or use the dots. Use it as an image slider in Tailwind for a gallery or a row of testimonials, where children are the slides and swipe, arrows and dots come with it.
  • Use slidesPerView breakpoints for a row of testimonial or product cards, such as 1.15 on phones to peek at the next card and 2 or 3 as the carousel widens. Set loop for an infinite loop carousel in React, where the last slide wraps around to the first.
  • Use align="center" with effect="scale" for a featured showcase where neighbors peek on both sides and slides shrink as they leave the center.
  • Skip it when users need to compare all items at once or when the content is critical; a grid or a Tabs panel shows everything, and Scroll area suits a simple sideways list.
  • Pair it with GlassCard for slide content, Button for call-to-action links on slides, and Badge for labels over images.

Frequently asked questions

67 components pages in all: browse them on All components.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .