Componentnavigation0.42 KB gzipZero dependencies
InfiniteScroll
IntersectionObserver sentinel: when visible calls onLoadMore, shows animated loader row; wraps children.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add infinite-scrollOr install the full npm package:
npm install bigbulluiUsage
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 helperZero 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 />| Prop | Type | Description |
|---|---|---|
| onLoadMore | () => void | Callback when sentinel intersects. |
| hasMore | boolean | Whether more items are available. |
| loader | React.ReactNode | Optional custom loader component. |
| children | React.ReactNode | Child elements rendered inside the component. |