React Carousel Component
A dependency-free React carousel with keyboard-friendly controls, visible position indicators and an accessible live status. Copy the component and replace the sample slides.
Copy the code
'use client'
import { useState } from 'react'
const slides = ['Design systems', 'Accessible components', 'Fast delivery']
export function Carousel() {
const [index, setIndex] = useState(0)
const move = (delta: number) => setIndex(value => (value + delta + slides.length) % slides.length)
return (
<section aria-roledescription="carousel" aria-label="Product highlights" className="overflow-hidden rounded-2xl border">
<div className="grid min-h-52 place-items-center bg-gradient-to-br from-violet-600 to-cyan-500 text-3xl font-bold text-white">
{slides[index]}
</div>
<div className="flex items-center justify-between bg-slate-950 p-3 text-white">
<button onClick={() => move(-1)} aria-label="Previous slide">β</button>
<span aria-live="polite">{index + 1} / {slides.length}</span>
<button onClick={() => move(1)} aria-label="Next slide">β</button>
</div>
</section>
)
}Tailwind CSS Β· no dependencies Β· MIT licensed. Paste it straight into any React, Next.js or Vite project.
About the react carousel
This react carousel is part of Empire UI - a free, open-source library of 34+ component types rendered across 41 visual styles, from glassmorphism to neo-brutalism. Every block is copy-paste ready in React and Tailwind CSS with no runtime dependencies.
Want it in a different look? Browse all 41 styles or grab the matching glassmorphism components.