Infinite Scroll
An Infinite Scroll component is a user interface feature that automatically loads and displays additional content as the user scrolls down a page. Instead of traditional pagination, this component creates a seamless browsing experience by continuously appending new items, such as images or articles, when the user reaches the bottom of the viewport. This enhances user engagement and keeps the content flow uninterrupted, making it ideal for applications like social media feeds, product galleries, and news websites.
Rendered live, with the same build of the library you install.
Item 0
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
Item 9
Item 10
Item 11
Item 12
Item 13
Item 14
Item 15
Item 16
Item 17
Item 18
Item 19
InfiniteScroll.tsx
import { useState } from 'react';import { NCard, NInfiniteScroll, NLoading } from '@nayan-ui/react';const InfiniteScroll = () => {const [items, setItems] = useState(new Array(20).fill(''));const [isFetching, setIsFetching] = useState(false);const fetchNextPage = () => {setIsFetching(true);setTimeout(() => {setItems(prev => [...prev, ...new Array(20).fill('')]);setIsFetching(false);}, 2000);};return (<div><NInfiniteScrollnext={() => !isFetching && fetchNextPage()}hasMore={true}loader={<NLoading />}dataLength={items.length}scrollThreshold={0.99}>{items.map((_item: any, index: number) => (<NCard key={index} className="p-3 mb-3">Item {index}</NCard>))}</NInfiniteScroll></div>);};export default InfiniteScroll;
| Name | Type | Default | Details |
|---|---|---|---|
| next | function | Required | Function to load next set of data. |
| hasMore | boolean | Required | Whether there is more data to load. |
| children | React.ReactNode | Required | Content to display in the scroll container. |
| loader | React.ReactNode | Required | Loading indicator component. |
| scrollThreshold | number | string | Optional | Threshold for triggering next load. |
| endMessage | React.ReactNode | Optional | Message to show when no more data. |
| style | CSSProperties | Optional | Custom styles for the container. |
| height | number | string | Optional | Height of the scroll container. |
| scrollableTarget | HTMLElement | string | null | Optional | Target element for scrolling. |
| hasChildren | boolean | Optional | Whether container has children. |
| inverse | boolean | Optional | Whether to use inverse scrolling. |
| pullDownToRefresh | boolean | Optional | Enable pull to refresh functionality. |
| pullDownToRefreshContent | React.ReactNode | Optional | Content for pull to refresh. |
| releaseToRefreshContent | React.ReactNode | Optional | Content for release to refresh. |
| pullDownToRefreshThreshold | number | Optional | Threshold for pull to refresh. |
| refreshFunction | function | Optional | Function to call on refresh. |
| onScroll | (e: Event) => any | Optional | Scroll event handler. |
| dataLength | number | Required | Length of current data array. |
| initialScrollY | number | Optional | Initial scroll position. |
| className | string | ' ' | You can customise by passing tailwind classes. |
| aria-label | string | Optional | ARIA label for accessibility. |
Other components solving nearby problems.
- React Infinite Scroll
- Infinite Scroll Component
- React Infinite Scrolling
- React Virtual Scroll
- Load More on Scroll
- Infinite Scroll Library
- React Infinite Scroll Hook
- Infinite Scroll Example
- Lazy Load in React
- React Scroll Pagination
- Infinite Scroll Implementation
- React Infinite List
- Scrolling Content in React
- Custom Infinite Scroll
- React Infinite Scroll Component
- Optimized Infinite Scroll
- React Infinite Load More
- Infinite Scrolling List
- React Infinite Scroll Hooks
- Infinite Scroll Performance
- React Infinite Scrolling Example
- Infinite Scroll UI Component
- React Infinite Scroll Tutorial
- Infinite Scroll Design System
- React Infinite Scroll TypeScript
- Mobile Infinite Scroll React
- Infinite Scroll Best Practices
- React Infinite Scroll Performance
- Infinite Scroll UI Library
- Virtual Scrolling React
- Pagination Component React
- Lazy Loading React
- Scroll Component React