Componentnavigation0.42 KB gzipZero dependencies

InfiniteScroll

IntersectionObserver sentinel: when visible calls onLoadMore, shows animated loader row; wraps children.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add infinite-scroll

Or install the full npm package:

npm install bigbullui

Usage

tsx5 lines
import { InfiniteScroll } from "@/components/ui/infinite-scroll" <InfiniteScroll onLoadMore={() => {}} hasMore={true}>  {[1, 2, 3, 4, 5].map((i) => <div key={i} className="p-3 bg-card">Item {i}</div>)}</InfiniteScroll>

Source code

infinite-scroll.tsx + 1 helper

Zero third-party dependencies (2 local files shown in tabs below).

tsxinfinite-scroll.tsx54 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export type InfiniteScrollProps = {  onLoadMore: () => void;  hasMore: boolean;  loader?: React.ReactNode;  children?: React.ReactNode;} & React.HTMLAttributes<HTMLElement>; export function InfiniteScroll({ onLoadMore, hasMore, loader, children, ...props }: InfiniteScrollProps) {   const sentinelRef = React.useRef<HTMLDivElement>(null);   React.useEffect(() => {    const observer = new IntersectionObserver(

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { InfiniteScroll } from "@/components/ui/infinite-scroll"; <InfiniteScroll />
PropTypeDescription
onLoadMore() => voidCallback when sentinel intersects.
hasMorebooleanWhether more items are available.
loaderReact.ReactNodeOptional custom loader component.
childrenReact.ReactNodeChild elements rendered inside the component.