Skip to content

Infinite Scroll

Automatically loads more data when scrolling to the bottom, supporting SSR, custom slots, and complex scroll container scenarios.

Basic Usage

The simplest asynchronous paginated load. Synchronize loading status via v-model:loading and lock loading with finished.

Item 1
Item 2
Item 3
Item 4
Item 5
Basic Usage

Custom Tip Text

Quickly customize intuitive text interaction via attributes to improve user experience.

Item 1
Item 2
Item 3
Custom Tip Text

Error State

When the interface response is abnormal, display an error tip and allow users to click to retry.

Item 1
Item 2
Item 3
Error State

Custom Slots

With slot mode, you have complete control over the visual presentation during different lifecycle states (loading, finished, error).

Item 1
Item 2
Custom Slots

Use in Nuxt (SSR)

The InfiniteScroll component is deeply adapted for Nuxt 3/4. In SSR mode, the component intelligently handles hydration logic and automatically starts IntersectionObserver on the client.

Nuxt SSR Support

Real-world Scenario: E-commerce Product List

In real e-commerce scenarios, lists often contain complex card layouts. Combining with fetch or useFetch, you can easily implement a high-performance product waterfall flow.

E-commerce Product List Scenario

API

Props

PropDescriptionTypeDefault
loadingWhether it is loading (supports v-model)booleanfalse
finishedWhether all data has been loadedbooleanfalse
errorWhether loading failed (supports v-model)booleanfalse
thresholdDistance threshold (px) to trigger loadingnumber100
directionScroll direction'vertical' | 'horizontal''vertical'
loading-textLoading tip textstring'Loading...'
finished-textFinished tip textstring'No more items'
error-textError tip textstring'Load failed, click to retry'
immediate-checkWhether to check loading immediately on initializationbooleantrue
disabledWhether to disable scroll loadingbooleanfalse
targetSpecifies the scroll container selectorstring''
use-observerWhether to use IntersectionObserver (recommended)booleantrue
root-marginIntersectionObserver rootMargin configstring'0px'

Events

Event NameDescriptionCallback Parameters
loadCalled when more data should be loaded()
update:loadingUpdates loading status(val: boolean)
update:errorUpdates error status(val: boolean)

Slots

Slot NameDescription
defaultMain list content
loadingCustom content for loading status
finishedCustom content for finished status
errorCustom content for error status (click to retry)

Expose

NameDescriptionType
checkManually check if loading is needed() => void
retryRetry loading (clears error state and triggers load)() => void

Theme Variables (CSS Variables)

VariableDefaultDescription
--yh-color-text-secondary#86868bLoading text color
--yh-color-text-placeholder#c0c4ccFinished text color
--yh-color-danger#f56c6cError state text color

Released under the MIT License.