> ## Documentation Index
> Fetch the complete documentation index at: https://anvil.servicetitan.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Infinite Content – Code

> InfiniteContent is a scrollable container with infinite scroll loading.

> [!WARNING]
>
> Atlas is deprecated. Use [AI Kit](https://anvil.servicetitan.com/docs/building-agentic-experiences) for any new Atlas experiences.

> [tab] Implementation
>
> ext-atlas-infinite-content-demo
>
> [StackBlitz demo](https://stackblitz.com/github/servicetitan/anvil2-docs-live-code/tree/main/examples/ext-atlas-infinite-content-demo?file=src/App.tsx)
>
> ```tsx lines expandable theme={null}
> import { InfiniteContent } from "@servicetitan/anvil2-ext-atlas";
> import { Flex, Text } from "@servicetitan/anvil2";
>
> function App() {
>   return (
>     <Flex
>       direction="column"
>       gap={2}
>       style={{ height: "300px", border: "1px dashed #ccc", padding: "1rem" }}
>     >
>       <Text size="medium" variant="eyebrow">
>         With Content
>       </Text>
>       <InfiniteContent
>         hasMore={true}
>         onLoadMore={() => console.log("load more")}
>       >
>         <Text>Item 1</Text>
>         <Text>Item 2</Text>
>         <Text>Item 3</Text>
>       </InfiniteContent>
>     </Flex>
>   );
> }
>
> export default App;
> ```
>
> ## Common Examples
>
> ### Basic Usage
>
> Scrollable content with infinite loading:
>
> ```tsx theme={null}
> import { InfiniteContent } from "@servicetitan/anvil2-ext-atlas";
>
> function InfiniteList() {
>   const [items, setItems] = useState([]);
>   const [hasMore, setHasMore] = useState(true);
>   const [loading, setLoading] = useState(false);
>
>   const loadMore = async () => {
>     setLoading(true);
>     const newItems = await fetchMoreItems();
>     setItems((prev) => [...prev, ...newItems]);
>     setHasMore(newItems.length > 0);
>     setLoading(false);
>   };
>
>   return (
>     <InfiniteContent
>       hasMore={hasMore}
>       loadingMore={loading}
>       onLoadMore={loadMore}
>       renderEndMessage={() => <div>No more items</div>}
>     >
>       {items.map((item) => (
>         <Item key={item.id} {...item} />
>       ))}
>     </InfiniteContent>
>   );
> }
> ```
>
> ### With Scroll Callbacks
>
> Track scroll position:
>
> ```tsx theme={null}
> import { InfiniteContent } from "@servicetitan/anvil2-ext-atlas";
>
> function ScrollTrackingList() {
>   const [atTop, setAtTop] = useState(true);
>
>   return (
>     <InfiniteContent
>       hasMore={hasMore}
>       onLoadMore={loadMore}
>       onScrollDown={() => setAtTop(false)}
>       onScrollTop={() => setAtTop(true)}
>     >
>       {children}
>     </InfiniteContent>
>   );
> }
> ```
>
> ### Custom Loading Indicators
>
> Customize loading and end messages:
>
> ```tsx theme={null}
> import { InfiniteContent, Loader } from "@servicetitan/anvil2-ext-atlas";
>
> function CustomLoadingList() {
>   return (
>     <InfiniteContent
>       hasMore={hasMore}
>       loadingMore={isLoading}
>       onLoadMore={loadMore}
>       renderLoadingMore={() => <Loader />}
>       renderEndMessage={() => (
>         <div className="end-message">You've reached the end!</div>
>       )}
>     >
>       {children}
>     </InfiniteContent>
>   );
> }
> ```

> [tab] InfiniteContent API
>
> ```tsx theme={null}
> <InfiniteContent
>   loading={false}
>   hasMore={true}
>   loadingMore={false}
>   onLoadMore={handleLoadMore}
>   rootMargin="200px"
>   threshold={0.1}
>   renderLoadingMore={() => <Spinner />}
>   renderEndMessage={() => <div>End of list</div>}
>   onScrollDown={handleScrollDown}
>   onScrollTop={handleScrollTop}
> >
>   {children}
> </InfiniteContent>
> ```
>
> ## `InfiniteContent` Props
>
> **children** `ReactNode`
>
> The content to render inside the scrollable container.
>
> **className** `string`
>
> Additional CSS class name for custom styling.
>
> **hasMore** `boolean` (default: false)
>
> When true, enables infinite scroll loading.
>
> **loading** `boolean` (default: false)
>
> When true and no children exist, shows the loading spinner.
>
> **loadingMore** `boolean` (default: false)
>
> When true, shows the loading more indicator.
>
> **onLoadMore** `() =\> void`
>
> Callback fired when more content should be loaded.
>
> **onScrollDown** `() =\> void`
>
> Callback fired when user scrolls past the threshold.
>
> **onScrollTop** `() =\> void`
>
> Callback fired when user scrolls back to top.
>
> **renderEndMessage** `() =\> ReactNode`
>
> Custom render function for the end of list message.
>
> **renderLoadingMore** `() =\> ReactNode`
>
> Custom render function for the loading more indicator.
>
> **rootMargin** `string` (default: 200px)
>
> Intersection Observer root margin for load trigger.
>
> **scrollContainerRef** `RefObject\<HTMLElement\>`
>
> Optional ref to custom scroll container element.
>
> **scrollThreshold** `number` (default: 50)
>
> Pixel threshold for scroll callbacks.
>
> **threshold** `number` (default: 0.1)
>
> Intersection Observer threshold for load trigger.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.