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.jsonCarouselCarouselCaptiondefaultCarouselLabels- +1 more
Gallery with autoplay
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
Ember
The last hour of a desert day
Lagoon
Shallow water, twelve shades of teal
Bloom
A field of late spring tulips
Meadow
Morning haze over the hills
import { Carousel } from "@/components/sheenui/carousel/carousel";
import { CarouselCaption } from "@/components/sheenui/carousel/carousel-caption";
// Package build (after the first npm release, or a packed tarball): import { Carousel, CarouselCaption } from "@sheenui/theme";
const scenes = [
{ title: "Dunes", from: "from-amber-300", to: "to-rose-500" },
{ title: "Glacier", from: "from-sky-200", to: "to-indigo-500" },
{ title: "Forest", from: "from-lime-300", to: "to-emerald-700" },
];
function Scene({ title, from, to }: (typeof scenes)[number]) {
return (
<div className={`relative aspect-video overflow-hidden rounded-sheen-lg bg-gradient-to-br ${from} ${to}`}>
{/* The caption bar carries its own dark scrim, so the words stay readable over any image. */}
<CarouselCaption>{title}</CarouselCaption>
</div>
);
}
export function Example() {
return (
<Carousel aria-label="Landscapes" loop autoplay={5000} arrows="overlay">
{scenes.map((scene) => (
<Scene key={scene.title} {...scene} />
))}
</Carousel>
);
}Files to copy
8 folders · 13 files · 4 packages
- From
theme/src/ components/carousel/carousel.tsxcomponents/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”).
Glass login
Email + password, social sign-in and a shimmering submit.
Data table
Sorting, filters, selection, CSV export and a dense mode.
Dashboard kit
Charts, stat tiles and a sidebar shell, wired together.
Checkout
Order summary, card fields and a confident pay button.
Docs theme
MDX pages, code blocks, search and a table of contents.
Onboarding
Steps, progress and an empty state that invites action.
import { Carousel } from "@/components/sheenui/carousel/carousel";
// Package build (after the first npm release, or a packed tarball): import { Carousel } from "@sheenui/theme";
const products = [
{ name: "Dashboard", price: "$49" },
{ name: "Landing page", price: "$29" },
{ name: "Docs site", price: "$39" },
{ name: "Admin panel", price: "$59" },
];
function ProductCard({ name, price }: (typeof products)[number]) {
return (
<div className="glass-1 flex flex-col gap-1 rounded-sheen-lg p-5">
<h3 className="font-semibold">{name}</h3>
<p className="text-sm text-sheen-fg-muted">{price}</p>
</div>
);
}
export function Example() {
return (
<Carousel
aria-label="Templates"
slidesPerView={{ 0: 1.15, 560: 2, 900: 3 }}
slidesToScroll="page"
gap={16}
>
{products.map((p) => (
<ProductCard key={p.name} {...p} />
))}
</Carousel>
);
}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.”
“Reduced motion is respected everywhere. I didn't have to file a single bug.”
“We shipped the dashboard in a week. The charts alone saved us a month.”
“Copy the folder, done. No black-box package, no lock-in.”
“Our customers keep asking which design system we use.”
import { Carousel } from "@/components/sheenui/carousel/carousel";
// Package build (after the first npm release, or a packed tarball): import { Carousel } from "@sheenui/theme";
const quotes = [
{ name: "Asha", text: "Shipped our dashboard in a week." },
{ name: "Ravi", text: "The motion feels native." },
{ name: "Meera", text: "Accessible out of the box." },
];
function Quote({ name, text }: (typeof quotes)[number]) {
return (
<figure className="glass-1 rounded-sheen-lg p-6">
<blockquote>{text}</blockquote>
<figcaption className="mt-3 text-sm text-sheen-fg-muted">{name}</figcaption>
</figure>
);
}
export function Example() {
return (
<Carousel
aria-label="What teams say"
align="center"
loop
effect="scale"
slidesPerView={{ 0: 1.2, 640: 1.6, 1024: 2.2 }}
gap={12}
>
{quotes.map((q) => <Quote key={q.name} {...q} />)}
</Carousel>
);
}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.
الشفق
ضوء بنفسجي فوق بحيرة متجمدة
جمر
آخر ساعة من نهار الصحراء
بحيرة
مياه ضحلة بدرجات الفيروز
import { Carousel } from "@/components/sheenui/carousel/carousel";
// Package build (after the first npm release, or a packed tarball): import { Carousel } from "@sheenui/theme";
const scenes = [
{ title: "كثبان", from: "from-amber-300", to: "to-rose-500" },
{ title: "جبال", from: "from-sky-200", to: "to-indigo-500" },
];
function Scene({ title, from, to }: (typeof scenes)[number]) {
return (
<div className={`grid aspect-video place-items-center rounded-sheen-lg bg-gradient-to-br ${from} ${to} text-xl font-semibold text-white`}>
{title}
</div>
);
}
export function Example() {
return (
<div dir="rtl" lang="ar">
<Carousel
aria-label="مناظر"
loop
labels={{
carousel: "عرض شرائح",
slide: "شريحة",
slideLabel: (i, n) => `${i} من ${n}`,
previous: "الشريحة السابقة",
next: "الشريحة التالية",
goTo: (i) => `الشريحة ${i}`,
picker: "اختر شريحة",
status: (i, n) => `الشريحة ${i} من ${n}`,
}}
>
{scenes.map((scene) => <Scene key={scene.title} {...scene} />)}
</Carousel>
</div>
);
}Props
CarouselLabels keys and English defaults (14)
CarouselCaption props
Keyboard
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.
When to use 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
Related pages
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .