Infinite Scroll

Overview

An infinite scroll container that loads more content using the IntersectionObserver API.

This data component is intended for interfaces that need an infinite scroll container that loads more content using the IntersectionObserver API, analytics dashboards, and reporting views. Its implementation is provided as editable source so the final behavior and styling stay inside your project.

Technologies

React
TypeScript
Tailwind CSS
shadcn/ui

No additional package dependency is declared for this component.

@spectrumui/infinite-scroll-demo

Installation

Login to view commandCreate a free account to access the install command

Properties

PropTypeDefaultDescription
*isLoadingboolean-

If isLoading is true, infinite scroll will stop calling next() function to avoid duplicate calls.

*hasMoreboolean-

If hasMore is false, infinite scroll will stop calling next() function.

*next() => unknown-

next Function to call when the user scrolls to the bottom of the children element.

thresholdnumber1

The threshold is the number of pixels from the bottom of the element where the next function will be called.

The range of threshold is 0 ~ 1, and the default value is 1.

Since InfiniteScroll is implemented with IntersectionObserver, you can find more on MDN.

rootnumbernull

This property will be used as the viewport for checking visibility of the last or the first item. Must be the ancestor of the item. Defaults to the browser viewport.

Since InfiniteScroll is implemented with IntersectionObserver, you can find more on MDN.

rootMarginstring0px

The rootMargin is the margin around the root. You can use any valid CSS unit like px, em, rem, %, etc.

Since InfiniteScroll is implemented with IntersectionObserver, you can find more on MDN.

reversebooleanfalse

Set this property to true means that InfiniteScroll will call next when the first item shows up in the viewport. This property is usually used to implement the chatbox behavior.

If your next function prepend the new data to the previous data, the first item will always show up on the top. This will cause InfiniteScroll continuously call next. Make sure write some code to prevent this circumstance.

childrenReactNodeundefinedThis property is that user will see according to thethreshold position and call next on the viewpoint.

Usage

The live preview and its Code tab above are the working example for this component. Copy the example after installation, then provide the required values from its TypeScript signature.

Use cases

  • interfaces that need an infinite scroll container that loads more content using the IntersectionObserver API
  • analytics dashboards
  • reporting views

Features

  • Copy-paste source that remains in your repository
  • TypeScript source included with the component
  • Tailwind CSS classes editable in the component source
  • shadcn/ui dependencies: local UI primitives
  • Spectrum UI registry dependencies: @spectrumui/infinite-scroll-dependecies

Accessibility

  • Test focus order, keyboard operation, labels, contrast, and screen-reader output in the final application context.

Customization

  • Edit the Tailwind utility classes in the copied source to match your spacing, color, and typography tokens.
  • Edit the copied source directly for visual or structural changes.

Topic guides

See how this component fits into broader interface patterns, implementation decisions, and working examples.

Infinite Scroll FAQ

Is Infinite Scroll free to use in commercial projects?

Yes. The public Infinite Scroll source is available under the Apache License 2.0, including for commercial use, subject to the LICENSE terms.

How do I install Infinite Scroll?

Run npx shadcn@latest add @spectrumui/infinite-scroll-demo. The page also exposes the source for manual installation.

Does Infinite Scroll require Motion?

No Motion dependency was detected in the documented source or registry entry for Infinite Scroll.

Does Infinite Scroll use shadcn/ui or Radix UI?

Infinite Scroll uses local shadcn/ui primitives.

Can I use Infinite Scroll in Next.js?

The documented React source is used in this Next.js application. Keep its use client directive when copying it into the App Router. Install the detected dependencies and verify any application-specific data or image configuration.

What accessibility checks should I run for Infinite Scroll?

No component-specific accessibility mechanism was detected automatically. Test keyboard operation, focus, labels, contrast, and screen-reader output before shipping.