Skip to content
Latestv1.0.63

Infinite Scroll ​

Automatically loads more data when scrolling near the end of the container. It supports SSR-friendly usage, custom status slots, and manual retry handling.

Basic Usage ​

Use v-model:loading to drive the loading state and finished to stop further loads.

Basic Usage

Custom Tip Text ​

If you want to override the locale text for a single instance, pass loading-text, finished-text, or error-text.

Custom Tip Text

Error State ​

When a request fails, bind v-model:error and let the built-in retry area or your custom error slot trigger another load.

Error State

Custom Slots ​

Use the loading, finished, and error slots to fully control status rendering while preserving the component's load logic.

Custom Slots

Use in Nuxt ​

YhInfiniteScroll can be used directly in Nuxt. In SSR it renders stable markup first, then starts IntersectionObserver or scroll listeners on the client after mount.

Nuxt SSR Support

Real-world Scenario: E-commerce Product List ​

The component also works well with card grids and longer async chains, as long as the container keeps a clear scroll boundary.

E-commerce Product List Scenario

API ​

Props ​

PropDescriptionTypeDefault
loadingCurrent loading state. Supports v-model:loading.booleanfalse
finishedWhether all data has been loadedbooleanfalse
errorWhether the current load has failed. Supports v-model:error.booleanfalse
thresholdDistance threshold in pixels before the end is reachednumber100
directionScroll direction'vertical' | 'horizontal''vertical'
loading-textPer-instance loading text. Falls back to locale text when empty.string''
finished-textPer-instance finished text. Falls back to locale text when empty.string''
error-textPer-instance error text. Falls back to locale text when empty.string''
immediate-checkWhether to run an initial load check after mountbooleantrue
disabledDisables automatic loadingbooleanfalse
targetSelector of the external scroll containerstring''
use-observerWhether to use IntersectionObserverbooleantrue
root-marginIntersectionObserver root marginstring'0px'
theme-overridesComponent-level theme overridesComponentThemeVarsundefined

Events ​

EventDescriptionParameters
loadTriggered when the component needs the next page of data()
update:loadingEmits the new loading state(value: boolean)
update:errorEmits the new error state(value: boolean)

Slots ​

SlotDescriptionParameters
defaultMain scroll content-
loadingCustom content shown while loading-
finishedCustom content shown after all data is loaded-
errorCustom content shown when loading fails-

Expose ​

NameDescriptionType
checkManually checks whether another load should be triggered() => void
retryClears the error state and triggers another load() => void

Theme Variables ​

YhInfiniteScroll supports themeOverrides, while its default appearance mainly consumes shared global tokens instead of a large component-specific CSS variable table.

TokenDescriptionDefault
--yh-text-color-secondaryLoading text color#86868b
--yh-text-color-placeholderFinished text color#c0c4cc
--yh-color-dangerError text color#f56c6c

Type Exports ​

NameDescription
YhInfiniteScrollPropsComponent props type
YhInfiniteScrollEmitsComponent emits type
YhInfiniteScrollSlotsComponent slots type
YhInfiniteScrollExposeComponent expose type
YhInfiniteScrollInstanceComponent instance type

Released under the MIT License.