Docs
Infinite Scroll

Infinite Scroll

A smooth infinite scrolling component for displaying repeating content.

Technologies

Powered by modern web technologies

⚛️React
📘TypeScript
Next.js
🎨Tailwind
🎭Framer
🔁JavaScript
🤖Node.js
🐍Python
🧁React Native
⚛️React
📘TypeScript
Next.js
🎨Tailwind
🎭Framer
🔁JavaScript
🤖Node.js
🐍Python
🧁React Native
⚛️React
📘TypeScript
Next.js
🎨Tailwind
🎭Framer
🔁JavaScript
🤖Node.js
🐍Python
🧁React Native
⚛️React
📘TypeScript
Next.js
🎨Tailwind
🎭Framer
🔁JavaScript
🤖Node.js
🐍Python
🧁React Native
⚛️React
📘TypeScript
Next.js
🎨Tailwind
🎭Framer
🔁JavaScript
🤖Node.js
🐍Python
🧁React Native
⚛️React
📘TypeScript
Next.js
🎨Tailwind
🎭Framer
🔁JavaScript
🤖Node.js
🐍Python
🧁React Native
⚛️React
📘TypeScript
Next.js
🎨Tailwind
🎭Framer
🔁JavaScript
🤖Node.js
🐍Python
🧁React Native
⚛️React
📘TypeScript
Next.js
🎨Tailwind
🎭Framer
🔁JavaScript
🤖Node.js
🐍Python
🧁React Native
⚛️React
📘TypeScript
Next.js
🎨Tailwind
🎭Framer
🔁JavaScript
🤖Node.js
🐍Python
🧁React Native

What People Say

Trusted by developers worldwide

Sarah Chen

Sarah Chen

Lead Designer at TechVision Inc

The UI components are incredibly polished and the documentation is top-notch. A game-changer for our design system.

Michael Rodriguez

Michael Rodriguez

Senior Developer at InnovateLabs

Perfect balance of flexibility and ease of use. Saved us countless hours in development time.

Emily Thompson

Emily Thompson

UX Director at DesignCraft

The attention to detail in animations and interactions is remarkable. Our clients love the results!

David Kim

David Kim

Frontend Architect at StartupFlow

Best-in-class components that work seamlessly together. The dark mode implementation is flawless.

Alexandra Wright

Alexandra Wright

Accessibility Specialist at CreativeEdge

The accessibility features are outstanding. Finally, a component library that takes a11y seriously!

James Foster

James Foster

Performance Engineer at CloudScale

Impressive performance optimizations out of the box. Our load times improved significantly.

Sofia Martinez

Sofia Martinez

Design Systems Lead at DesignSphere

The customization options are endless. We built our entire design system on top of these components.

Lucas Anderson

Lucas Anderson

Tech Lead at TechFlow

Integration was a breeze. The TypeScript support is exceptional and caught many potential issues early.

Nina Patel

Nina Patel

Motion Designer at WebCraft

The motion design is subtle yet effective. Creates a premium feel that our users appreciate.

Thomas Weber

Thomas Weber

Senior Frontend Dev at DevForge

Excellent state management and event handling. Complex interactions become simple to implement.

Sarah Chen

Sarah Chen

Lead Designer at TechVision Inc

The UI components are incredibly polished and the documentation is top-notch. A game-changer for our design system.

Michael Rodriguez

Michael Rodriguez

Senior Developer at InnovateLabs

Perfect balance of flexibility and ease of use. Saved us countless hours in development time.

Emily Thompson

Emily Thompson

UX Director at DesignCraft

The attention to detail in animations and interactions is remarkable. Our clients love the results!

David Kim

David Kim

Frontend Architect at StartupFlow

Best-in-class components that work seamlessly together. The dark mode implementation is flawless.

Alexandra Wright

Alexandra Wright

Accessibility Specialist at CreativeEdge

The accessibility features are outstanding. Finally, a component library that takes a11y seriously!

James Foster

James Foster

Performance Engineer at CloudScale

Impressive performance optimizations out of the box. Our load times improved significantly.

Sofia Martinez

Sofia Martinez

Design Systems Lead at DesignSphere

The customization options are endless. We built our entire design system on top of these components.

Lucas Anderson

Lucas Anderson

Tech Lead at TechFlow

Integration was a breeze. The TypeScript support is exceptional and caught many potential issues early.

Nina Patel

Nina Patel

Motion Designer at WebCraft

The motion design is subtle yet effective. Creates a premium feel that our users appreciate.

Thomas Weber

Thomas Weber

Senior Frontend Dev at DevForge

Excellent state management and event handling. Complex interactions become simple to implement.

Sarah Chen

Sarah Chen

Lead Designer at TechVision Inc

The UI components are incredibly polished and the documentation is top-notch. A game-changer for our design system.

Michael Rodriguez

Michael Rodriguez

Senior Developer at InnovateLabs

Perfect balance of flexibility and ease of use. Saved us countless hours in development time.

Emily Thompson

Emily Thompson

UX Director at DesignCraft

The attention to detail in animations and interactions is remarkable. Our clients love the results!

David Kim

David Kim

Frontend Architect at StartupFlow

Best-in-class components that work seamlessly together. The dark mode implementation is flawless.

Alexandra Wright

Alexandra Wright

Accessibility Specialist at CreativeEdge

The accessibility features are outstanding. Finally, a component library that takes a11y seriously!

James Foster

James Foster

Performance Engineer at CloudScale

Impressive performance optimizations out of the box. Our load times improved significantly.

Sofia Martinez

Sofia Martinez

Design Systems Lead at DesignSphere

The customization options are endless. We built our entire design system on top of these components.

Lucas Anderson

Lucas Anderson

Tech Lead at TechFlow

Integration was a breeze. The TypeScript support is exceptional and caught many potential issues early.

Nina Patel

Nina Patel

Motion Designer at WebCraft

The motion design is subtle yet effective. Creates a premium feel that our users appreciate.

Thomas Weber

Thomas Weber

Senior Frontend Dev at DevForge

Excellent state management and event handling. Complex interactions become simple to implement.

Sarah Chen

Sarah Chen

Lead Designer at TechVision Inc

The UI components are incredibly polished and the documentation is top-notch. A game-changer for our design system.

Michael Rodriguez

Michael Rodriguez

Senior Developer at InnovateLabs

Perfect balance of flexibility and ease of use. Saved us countless hours in development time.

Emily Thompson

Emily Thompson

UX Director at DesignCraft

The attention to detail in animations and interactions is remarkable. Our clients love the results!

David Kim

David Kim

Frontend Architect at StartupFlow

Best-in-class components that work seamlessly together. The dark mode implementation is flawless.

Alexandra Wright

Alexandra Wright

Accessibility Specialist at CreativeEdge

The accessibility features are outstanding. Finally, a component library that takes a11y seriously!

James Foster

James Foster

Performance Engineer at CloudScale

Impressive performance optimizations out of the box. Our load times improved significantly.

Sofia Martinez

Sofia Martinez

Design Systems Lead at DesignSphere

The customization options are endless. We built our entire design system on top of these components.

Lucas Anderson

Lucas Anderson

Tech Lead at TechFlow

Integration was a breeze. The TypeScript support is exceptional and caught many potential issues early.

Nina Patel

Nina Patel

Motion Designer at WebCraft

The motion design is subtle yet effective. Creates a premium feel that our users appreciate.

Thomas Weber

Thomas Weber

Senior Frontend Dev at DevForge

Excellent state management and event handling. Complex interactions become simple to implement.

Sarah Chen

Sarah Chen

Lead Designer at TechVision Inc

The UI components are incredibly polished and the documentation is top-notch. A game-changer for our design system.

Michael Rodriguez

Michael Rodriguez

Senior Developer at InnovateLabs

Perfect balance of flexibility and ease of use. Saved us countless hours in development time.

Emily Thompson

Emily Thompson

UX Director at DesignCraft

The attention to detail in animations and interactions is remarkable. Our clients love the results!

David Kim

David Kim

Frontend Architect at StartupFlow

Best-in-class components that work seamlessly together. The dark mode implementation is flawless.

Alexandra Wright

Alexandra Wright

Accessibility Specialist at CreativeEdge

The accessibility features are outstanding. Finally, a component library that takes a11y seriously!

James Foster

James Foster

Performance Engineer at CloudScale

Impressive performance optimizations out of the box. Our load times improved significantly.

Sofia Martinez

Sofia Martinez

Design Systems Lead at DesignSphere

The customization options are endless. We built our entire design system on top of these components.

Lucas Anderson

Lucas Anderson

Tech Lead at TechFlow

Integration was a breeze. The TypeScript support is exceptional and caught many potential issues early.

Nina Patel

Nina Patel

Motion Designer at WebCraft

The motion design is subtle yet effective. Creates a premium feel that our users appreciate.

Thomas Weber

Thomas Weber

Senior Frontend Dev at DevForge

Excellent state management and event handling. Complex interactions become simple to implement.

Sarah Chen

Sarah Chen

Lead Designer at TechVision Inc

The UI components are incredibly polished and the documentation is top-notch. A game-changer for our design system.

Michael Rodriguez

Michael Rodriguez

Senior Developer at InnovateLabs

Perfect balance of flexibility and ease of use. Saved us countless hours in development time.

Emily Thompson

Emily Thompson

UX Director at DesignCraft

The attention to detail in animations and interactions is remarkable. Our clients love the results!

David Kim

David Kim

Frontend Architect at StartupFlow

Best-in-class components that work seamlessly together. The dark mode implementation is flawless.

Alexandra Wright

Alexandra Wright

Accessibility Specialist at CreativeEdge

The accessibility features are outstanding. Finally, a component library that takes a11y seriously!

James Foster

James Foster

Performance Engineer at CloudScale

Impressive performance optimizations out of the box. Our load times improved significantly.

Sofia Martinez

Sofia Martinez

Design Systems Lead at DesignSphere

The customization options are endless. We built our entire design system on top of these components.

Lucas Anderson

Lucas Anderson

Tech Lead at TechFlow

Integration was a breeze. The TypeScript support is exceptional and caught many potential issues early.

Nina Patel

Nina Patel

Motion Designer at WebCraft

The motion design is subtle yet effective. Creates a premium feel that our users appreciate.

Thomas Weber

Thomas Weber

Senior Frontend Dev at DevForge

Excellent state management and event handling. Complex interactions become simple to implement.

Installation

Copy and paste the following code into your project.

"use client";
 
import React, { useRef, useEffect, useState } from "react";
import { motion, useAnimationControls } from "framer-motion";
import { cn } from "@/lib/utils";
 
interface InfiniteScrollProps {
  /** Additional CSS classes to apply to the container */
  className?: string;
  /** Duration of the scroll animation in milliseconds. Default is 15000 */
  duration?: number;
  /** Direction of the scroll animation. Can be "normal" (left to right) or "reverse" (right to left) */
  direction?: "normal" | "reverse";
  /** Background color for the fade effect container. Default is "#ffffff" */
  containerColor?: string;
  /** Whether to show the fade effect at the edges. Default is true */
  showFade?: boolean;
  /** Content to be scrolled infinitely */
  children: React.ReactNode;
  /** Whether to pause the animation when hovering over the content. Default is true */
  pauseOnHover?: boolean;
}
 
export function InfiniteScroll({
  className,
  duration = 15000,
  direction = "normal",
  containerColor = "#ffffff",
  showFade = true,
  children,
  pauseOnHover = true,
}: InfiniteScrollProps) {
  const [contentWidth, setContentWidth] = useState<number>(0);
  const [isPaused, setIsPaused] = useState(false);
  const scrollerRef = useRef<HTMLDivElement>(null);
  const contentRef = useRef<HTMLDivElement>(null);
  const controls = useAnimationControls();
  const elapsedTimeRef = useRef(0);
  const lastTimeRef = useRef(0);
 
  useEffect(() => {
    const content = contentRef.current;
    if (!content) return;
 
    const updateWidth = () => {
      const width = content.offsetWidth;
      setContentWidth(width);
    };
 
    updateWidth();
    window.addEventListener("resize", updateWidth);
    return () => window.removeEventListener("resize", updateWidth);
  }, [children]);
 
  useEffect(() => {
    if (!contentWidth) return;
 
    const startX = direction === "normal" ? 0 : -contentWidth;
    const endX = direction === "normal" ? -contentWidth : 0;
 
    if (!isPaused) {
      const remainingDuration = duration - elapsedTimeRef.current;
      const progress = elapsedTimeRef.current / duration;
      const currentX =
        direction === "normal"
          ? startX + (endX - startX) * progress
          : endX + (startX - endX) * (1 - progress);
 
      controls.set({ x: currentX });
      controls.start({
        x: endX,
        transition: {
          duration: remainingDuration / 1000,
          ease: "linear",
          repeat: Infinity,
          repeatType: "loop",
          repeatDelay: 0,
        },
      });
 
      lastTimeRef.current = Date.now();
    }
  }, [controls, direction, duration, contentWidth, isPaused]);
 
  const handleMouseEnter = () => {
    if (!pauseOnHover) return;
 
    const currentTime = Date.now();
    const deltaTime = currentTime - lastTimeRef.current;
    elapsedTimeRef.current = (elapsedTimeRef.current + deltaTime) % duration;
 
    setIsPaused(true);
    controls.stop();
  };
 
  const handleMouseLeave = () => {
    if (!pauseOnHover) return;
    lastTimeRef.current = Date.now();
    setIsPaused(false);
  };
 
  return (
    <div
      className={cn(
        "relative flex shrink-0 flex-col gap-4 overflow-hidden py-3",
        className,
      )}
      onMouseEnter={handleMouseEnter}
      onMouseLeave={handleMouseLeave}
    >
      <div className="flex">
        <motion.div
          ref={scrollerRef}
          className="flex shrink-0"
          animate={controls}
        >
          <div ref={contentRef} className="flex shrink-0">
            {children}
          </div>
          <div className="flex shrink-0">{children}</div>
          <div className="flex shrink-0">{children}</div>
        </motion.div>
      </div>
      {showFade && (
        <div
          className="pointer-events-none absolute inset-0 bg-linear-to-r from-background via-transparent to-background"
          style={{ "--container-color": containerColor } as React.CSSProperties}
        />
      )}
    </div>
  );
}

Update the import paths to match your project setup.

import { InfiniteScroll } from "@/components/ui/infinite-scroll";

Usage

import { InfiniteScroll } from "@/components/ui/infinite-scroll";
 
const Example = () => {
  return (
    <InfiniteScroll duration={25000} direction="normal" pauseOnHover>
      {items.map((item) => (
        <YourComponent key={item.id} {...item} />
      ))}
    </InfiniteScroll>
  );
};

Features

  • Smooth, continuous scrolling animation
  • Supports both normal and reverse directions
  • Pause on hover functionality
  • Customizable scroll duration
  • Responsive design
  • Dark mode support
  • Automatic content duplication for seamless looping

Props

PropTypeDefaultDescription
childrenReact.ReactNodeRequiredContent to be scrolled infinitely
classNamestring-Additional CSS classes
durationnumber15000Duration of animation in milliseconds
direction"normal"|"reverse""normal"Direction of the scroll animation
containerColorstring"#ffffff"Background color for fade effect
showFadebooleantrueShow fade effect at the edges
pauseOnHoverbooleantruePause animation on hover

Examples

Basic Usage

<InfiniteScroll duration={20000} direction="normal">
  {items.map((item) => (
    <Card key={item.id} {...item} />
  ))}
</InfiniteScroll>

With Pause on Hover

<InfiniteScroll duration={25000} direction="normal" pauseOnHover>
  {items.map((item) => (
    <Card key={item.id} {...item} />
  ))}
</InfiniteScroll>

Bidirectional Scrolling

Create an engaging display with content scrolling in opposite directions:

<div className="flex flex-col gap-8">
  <InfiniteScroll duration={25000} direction="normal">
    {items.map((item) => (
      <Card key={item.id} {...item} />
    ))}
  </InfiniteScroll>
  <InfiniteScroll duration={25000} direction="reverse">
    {items.map((item) => (
      <Card key={item.id} {...item} />
    ))}
  </InfiniteScroll>
</div>

Custom Styling

The component accepts className for custom styling:

<InfiniteScroll
  duration={20000}
  direction="normal"
  className="py-4 bg-gray-50 dark:bg-gray-900"
>
  {items.map((item) => (
    <Card key={item.id} {...item} />
  ))}
</InfiniteScroll>