Nexlide logo

Nexlide

Latest npm version of Nexlide

A modern, lightweight, and fully customizable React carousel component built with Framer Motion for smooth animations and Tailwind CSS for flexible styling.

Core Features

10+ smooth animations (fade, slide, flip, zoom, bounce)
Independent caption system with custom timing New
Framer Motion drag engine with inertia & elastic physics
Native RTL architecture (Arabic, Hebrew, Persian) New
Built-in accessibility (ARIA, keyboard, screen readers)
Responsive by design with aspect ratio control
Smart image optimization (lazy loading, decoding async)
Dark mode ready (system preference detection)
Framer Motion powered for production-grade animations
Pure Tailwind CSS (zero external CSS imports)

What It Supports?

Autoplay direction control (forward/reverse) New
Multi-trigger pause system: hover, focus, drag, tab New
Infinite seamless looping with smart index wrapping
Adaptive navigation arrows (auto RTL mirroring) New
Clickable pagination dots with active states
Touch gestures with momentum snap-back
Full keyboard navigation (arrow keys) New
10+ className props for deep styling
Next.js App Router with 'use client' support
TypeScript ready with full type definitions

The best is yet to come!

Parallax • 3D • Cube • Coverflow • and more — actively in development 🚀

Installation & Usage

Installation

bash
npm install nexlide

yarn add nexlide

pnpm add nexlide

📦 Peer Dependencies

These dependencies are usually already present in React / Next.js projects:

  • react (>=18)
  • framer-motion (required)

Optional (Styling Utilities)

Nexlide uses a cn() utility internally for className merging, inspired by the common Tailwind pattern.

If you are customizing or extending the component and want to reuse this utility, it relies on:

  • clsx
  • tailwind-merge
  • class-variance-authority

⚠️These are already bundled within Nexlide and do NOT need to be installed manually unless you plan to use the same utility pattern in your own components.

Basic Usage

The component is a Client Component (it uses React hooks and browser events like touch gestures). In Next.js App Router, you must place it inside a file that starts with 'use client';.

tsx
'use client';

import { Carousel } from 'nexlide'

const carouselItems = [
  {
    imageUrl: "https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200&q=75&fm=webp",
    title: "Incredible Mountains",
    description: "A breathtaking landscape at sunset",
  },
  {
    imageUrl: "https://images.unsplash.com/photo-1507525428034-b723cf961d3e?w=1200&q=75&fm=webp",
  },
  {
    imageUrl: "https://images.unsplash.com/photo-1477959858617-67f85cf4f1df?w=1200&q=75&fm=webp",
    title: "Vibrant Night City",
  },
  {
    imageUrl: "https://images.unsplash.com/photo-1757843298369-6e5503c14bfd?w=1200&q=75&fm=webp",
    description: "Neon and motion in the city that never sleeps",
  },
  {
    imageUrl: "https://images.unsplash.com/photo-1482192505345-5655af888cc4?w=1200&q=75&fm=webp",
  },
  // ...
];

export default function MyPage() {
  return (
    <div className="p-8">
      <Carousel
        items={carouselItems}
        autoPlay
        autoPlayInterval={4000}
        showPagination
        showArrows
        infiniteLoop
        pauseOnHover={true}
        pauseOnFocus={true}
        pauseOnDrag={true}
        animation="zoomIn"
        captionAnimation="slideBottom"
        captionDelay={0.6}
        captionDuration={1.0}
        className="rounded-2xl shadow-2xl max-w-4xl mx-auto"
      />
    </div>
  )
}

RTL Support

For right-to-left languages (Arabic, Hebrew, Persian, etc.), enable the rtl prop to automatically adapt the carousel's behavior and layout.

tsx
'use client';

import { Carousel } from 'nexlide'

const carouselItems = [ /* ... */ ];

export default function RTLPage() {
  return (
    <div className="p-8" dir="rtl">  {/* Optional: Set dir on a parent */}
      <Carousel
        rtl={true}                   // Enables full RTL support
        items={carouselItems}
        autoPlay
        autoPlayInterval={4000}
        animation="slideRight"       // Recommended for RTL, but optional
        showArrows
        showPagination
      />
    </div>
  );
}

💡The animation="slideRight" is recommended for RTL contexts as it provides the most natural directional flow, but you can use any animation type based on your preferences.

Note: If you're using Pages Router or a different React setup without App Router restrictions, you can omit `use client`;.

Demos — See Nexlide in Action

How to interact with the demos?

Hover to pause autoplay • Tab to focus • Drag to swipe • Click arrows or dots • Resize window to test responsiveness.

1. Autoplay reverse + caption delay

2. RTL mode (Arabic/Hebrew support)

3. Fade + slow caption + all pauses

4. Bounce animation + manual only

5. Flip animation + fast caption

6. ZoomOut + arrows only (no dots)

Available Animations

Use animation for the image/slide transition and captionAnimation for the title + description entrance.

Bounce

Bouncy entrance animation

Flip

3D flip animation

Fade

Smooth opacity transition

Fade In

Gentle entrance from transparent

Slide Left

Slides in from the right

Slide Right

Slides in from the left

Slide Top

Slides up from the bottom

Slide Bottom

Slides down from the top

Zoom In

Zoom in animation

Zoom Out

Zoom out animation

Props

Explore all available configuration options for the Carousel component. This reference table lists every prop, its TypeScript type, default value (when applicable), and a clear explanation of its purpose and usage.

PropTypeDefault ValueDescription
items
CarouselItem[]
— (required)
Array of carousel items. Each item must include imageUrl, while title and description are optional.
autoPlay
boolean
false
Enables automatic slide transition.
autoPlayInterval
number
3000
Time in milliseconds between automatic slides (only when autoPlay is true).
autoPlayDirection New
forwardreverse
forward
Direction of the autoplay animation: "forward" advances to the next slide, "reverse" goes to the previous slide.
infiniteLoop
boolean
true
Enables infinite looping (goes back to first slide after last).
pauseOnHover New
boolean
true
Pause autoplay on mouse hover. Resumes when hover ends. Improves user reading experience. (effective only when autoplay = true).
pauseOnFocus New
boolean
true
Pause autoplay when the carousel receives keyboard focus. Enhances accessibility for keyboard/screen reader users. (effective only when autoplay = true).
pauseOnDrag New
boolean
true
Pause autoplay while the user is actively dragging/swiping the carousel. (effective only when autoplay = true).
showPagination
boolean
true
Shows pagination dots at the bottom.
showArrows
boolean
true
Shows previous/next arrow buttons.
animation
AnimationType
slideLeft
Animation type for the image slide transition.
rtl New
boolean
false
Enables right-to-left (RTL) mode. When true, reverses swipe direction, swaps arrow positions and functions, changes default animation to slideRight, and applies dir="rtl" to the container for proper layout in languages like Arabic or Hebrew.
className
string
Custom Tailwind classes for the main container.
slideClassName
string
Custom classes for each slide wrapper (motion.div).
captionClassName
string
Custom classes for the caption container.
arrowClassName
string
Custom classes for navigation arrows.
paginationClassName
string
Custom classes for the pagination container (dots wrapper).
dotClassName
string
Custom classes for each pagination dot.
captionAnimation
AnimationType
fade
Animation type for the caption appearance.
captionDelay
number
0.5
Delay in seconds before the caption animation starts (after the main slide transition begins). Useful for creating a natural staggered reveal effect. Value in seconds (e.g. 0.5 = 500ms).
captionDuration New
number
0.8
Duration in seconds of the caption animation itself (fade in, slide up, etc.). Controls animation speed — higher values = slower animation. Value in seconds (e.g. 0.8 = 800ms).

Type:AnimationType

bounceflipfadefadeInslideLeftslideRightslideTopslideBottomzoomInzoomOut

License

MIT License. See LICENSE for details.