A full-screen image slider built with React 19, TypeScript, and Tailwind CSS v4, bundled with Vite. It cycles through beautifully crafted gradient slides with smooth animations, navigation arrows, and dot indicators β all in a clean, reusable component.
- πΌοΈ Full-screen slides β each slide occupies 100% of the viewport height
- π¨ Gradient backgrounds β each slide uses a unique Tailwind CSS
bg-gradient-to-brcolor palette - β±οΈ Auto-play β slides advance automatically every 5 seconds (configurable via props)
- β βΆ Navigation arrows β frosted-glass styled prev/next buttons with hover effects
- π΅ Dot indicators β clickable pagination dots at the bottom; the active dot expands to a pill shape
- π Infinite loop β wraps seamlessly from the last slide back to the first (and vice versa)
- βΏ Accessible β all interactive elements include descriptive
aria-labelattributes - βοΈ React 19 + StrictMode β leverages the latest React release with strict development checks
- π¦ TypeScript β fully typed props and state for safe, predictable development
slider/
βββ index.html # HTML entry point
βββ vite.config.ts # Vite + React + Tailwind CSS v4 plugins
βββ tsconfig.json # TypeScript configuration
βββ package.json # Dependencies and scripts
βββ src/
βββ main.tsx # React app bootstrap (StrictMode + createRoot)
βββ App.tsx # Root component β defines slide data and renders <Slider>
βββ Slider.tsx # Core slider component (logic + UI)
βββ style.css # Global styles β imports Tailwind CSS v4
The Slider component is the heart of the project. It accepts the following props:
| Prop | Type | Default | Description |
|---|---|---|---|
slides |
Slide[] |
required | Array of slide objects to display |
interval |
number |
5000 |
Auto-play interval in milliseconds |
type Slide = {
id: number // Unique identifier for the slide
bg: string // Tailwind CSS gradient class (e.g. "from-blue-900 via-purple-900 to-indigo-900")
title?: string // Optional text label displayed on the slide
}useStatetracks the index of the currently visible slideuseCallbackmemoizes theprevandnextnavigation functionsuseEffectsets up and cleans up thesetIntervalauto-play timer- The slide strip is a horizontal flex container translated via inline
transform: translateX(-N%)for smooth CSS transitions
| # | Title | Gradient Colors |
|---|---|---|
| 1 | Mountain View | blue-900 β purple-900 β indigo-900 |
| 2 | City Lights | gray-900 β slate-800 β zinc-900 |
| 3 | Ocean Sunset | orange-600 β rose-800 β purple-900 |
| 4 | Forest Path | green-900 β emerald-800 β teal-900 |
| 5 | Desert Dunes | amber-700 β yellow-800 β orange-900 |
| Technology | Version | Role |
|---|---|---|
| React | ^19.2.6 | UI component library |
| React DOM | ^19.2.6 | DOM rendering |
| TypeScript | ~6.0.2 | Static typing |
| Vite | ^8.0.12 | Dev server & bundler |
| Tailwind CSS | ^4.3.0 | Utility-first styling |
| @tailwindcss/vite | ^4.3.0 | Tailwind v4 Vite plugin |
| @vitejs/plugin-react | ^6.0.2 | React Fast Refresh via Vite |
- Node.js v18 or higher
- npm v9 or higher
# Clone the repository
git clone <repository-url>
cd slider
# Install dependencies
npm installnpm run devOpens the app at http://localhost:5173 with Hot Module Replacement (HMR) enabled.
npm run buildOutputs optimized static files to the dist/ folder.
npm run previewServes the dist/ folder locally to verify the production build.
You can customize the slider by editing the slides array in App.tsx or by passing your own data to the <Slider> component:
import Slider from './Slider'
const mySlides = [
{ id: 1, title: 'Welcome', bg: 'from-cyan-900 via-blue-800 to-indigo-900' },
{ id: 2, title: 'Explore', bg: 'from-rose-800 via-pink-700 to-fuchsia-900' },
]
function App() {
// Change interval to 3 seconds
return <Slider slides={mySlides} interval={3000} />
}This project is open source and available under the MIT License.