AnimationsCarousel

Carousel

A smooth, draggable carousel with infinite looping, spring animations, and responsive design. Built with Framer Motion for fluid interactions and Tabler Icons for navigation.

Installation

$ npx @nehal712521/inprogress add carousel

Requires: framer-motion lucide-react

Preview

Mountain Adventure

Explore the highest peaks and breathtaking views

Ocean Escape

Dive into crystal clear waters and discover marine life

Desert Wanderer

Experience the magic of golden sand dunes

Forest Retreat

Find peace among ancient trees and wildlife

City Lights

Explore vibrant nightlife and urban culture

Mountain Adventure

Explore the highest peaks and breathtaking views

Ocean Escape

Dive into crystal clear waters and discover marine life

Desert Wanderer

Experience the magic of golden sand dunes

Forest Retreat

Find peace among ancient trees and wildlife

City Lights

Explore vibrant nightlife and urban culture

Mountain Adventure

Explore the highest peaks and breathtaking views

Ocean Escape

Dive into crystal clear waters and discover marine life

Desert Wanderer

Experience the magic of golden sand dunes

Forest Retreat

Find peace among ancient trees and wildlife

City Lights

Explore vibrant nightlife and urban culture

Features

Infinite Looping

Seamlessly cycles from last slide back to first

Drag & Swipe

Touch and mouse drag support with velocity detection

Spring Animations

Smooth Framer Motion spring transitions

Responsive Design

Adapts to mobile, tablet, and desktop layouts

Navigation Arrows

Clean prev/next buttons with hover effects

Pagination Dots

Active slide indicator with direct navigation

Scale Transform

Active slide enlarges while others shrink

Keyboard Support

Navigate with arrow keys for accessibility

Usage

import { Carousel, CardSlide } from "@/components/ui/carousel";

const slides = [
  {
    id: 1,
    content: (
      <CardSlide
        title="Mountain Adventure"
        description="Explore the highest peaks"
        gradient="from-emerald-600 to-teal-800"
      />
    ),
  },
  {
    id: 2,
    content: (
      <CardSlide
        title="Ocean Escape"
        description="Dive into crystal clear waters"
        gradient="from-blue-600 to-indigo-800"
      />
    ),
  },
  // Add more slides...
];

export default function MyPage() {
  return (
    <Carousel
      items={slides}
      slideWidth={300}
      slideHeight={400}
      showArrows={true}
      showDots={true}
      autoPlay={false}
    />
  );
}

Custom Slides

You can use any React content as slides. The carousel automatically handles sizing based on your slideWidth and slideHeight props.

import { Carousel } from "@/components/ui/carousel";

// Custom slide content
const customSlides = [
  {
    id: 1,
    content: (
      <div className="w-full h-full bg-gradient-to-br from-purple-500 to-pink-600 rounded-2xl p-6 flex flex-col justify-center items-center text-center">
        <h2 className="text-2xl font-bold text-white mb-2">Custom Card</h2>
        <p className="text-white/80">Any content works here!</p>
      </div>
    ),
  },
  // More custom slides...
];

<Carousel
  items={customSlides}
  slideWidth={350}
  slideHeight={250}
  gap={30}
/>

Auto Play

Enable automatic slide advancement with customizable intervals. Auto-play pauses while dragging.

<Carousel
  items={slides}
  autoPlay={true}
  autoPlayInterval={3000} // 3 seconds
  showArrows={true}
  showDots={true}
/>

Props

PropTypeDefaultDescription
itemsCarouselItem[]requiredArray of items with id and content
slideWidthnumber300Width of each slide in pixels
slideHeightnumber400Height of each slide in pixels
gapnumber20Gap between slides in pixels
showArrowsbooleantrueShow navigation arrows
showDotsbooleantrueShow pagination dots
autoPlaybooleanfalseEnable auto-play
autoPlayIntervalnumber5000Auto-play interval in ms
classNamestring""Additional CSS classes

Helper Components

The carousel comes with pre-built slide components for common use cases:

CardSlide

A gradient card with title, description, and optional background image.

Props: title, description?, image?, gradient?, className?

ImageSlide

A full-bleed image slide with optional gradient overlay.

Props: src, alt, overlay?

CarouselSlide

The base slide wrapper with scale and shadow animations. Used internally but can be composed manually.

Props: children, isActive?, className?