OfferLifetime Pro for $99

Infinite Scroll

Watches a marker after the last item, a little early, and never asks twice while loading. Failures show Retry. Works in the page or inside a scrolling panel.

Data & feedbackFree129 lines · one file

The decision inside it

A Load more button for people who do not scroll

Keyboard and screen-reader users get a real button after the list, hidden until focused, and loading and the end are announced.

When to use it

Use Infinite Scroll for long feeds people browse rather than search: activity, history, a gallery. Pass hasMore and loading from your data hook. For tables people jump around in, use Pagination.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Layro's Infinite Scroll for this.
Install it: npx shadcn@latest add @layro/infinite-scroll
(the @layro registry is set up in components.json, with LAYRO_KEY in .env.local)
Import it from @/components/ui/infinite-scroll.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @layro registry with your CLI token: see the Namespaced tab.

Usage

components/activity-feed.tsx
import { InfiniteScroll } from "@/components/ui/infinite-scroll";

export function ActivityFeed({ items, hasMore, loading, next }: { items: { id: string; text: string }[]; hasMore: boolean; loading: boolean; next: () => void }) {
  return (
    <InfiniteScroll hasMore={hasMore} loading={loading} onLoadMore={next}>
      <ul>
        {items.map((i) => (
          <li key={i.id}>{i.text}</li>
        ))}
      </ul>
    </InfiniteScroll>
  );
}

API reference

“Copy prompt” above puts a full brief on your clipboard — install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

PropTypeNotes
hasMorerequiredbooleanMore pages exist.
loadingrequiredbooleanA page is on its way.
onLoadMorerequired() => void | Promise<void>Ask for the next page.
thresholdnumberPixels before the end to start loading. Default 300.
loaderReact.ReactNodeShown while loading. Default a spinner and "Loading more".
endMessageReact.ReactNodeShown when there is nothing more. Default "You’re all caught up".
errorstringA failure message; shows Retry.
onRetry() => void—
rootReact.RefObject<HTMLElement | null>The scrolling element, when the list scrolls inside a panel. Default the page.
loadMoreLabelstringThe button text for keyboard and screen-reader users. Default "Load more".
childrenrequiredReact.ReactNode—

Dependencies

npm packages

clsxlucide-reacttailwind-merge

Layro foundations, installed alongside it

layro-theme

States

All of them are drawn by the component. None is left for you to design.

  • Loading
  • Loaded
  • Error with retry
  • End of list
  • Inside a panel

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances

Lifetime access

Every component, and everything we ship next.

  • All 232 components, source included
  • Every template, and everything released after you buy
  • shadcn CLI or download — React 18/19, Tailwind v4
  • One payment. No subscription.