InfiniteScroll
Data Display
stable
Sentinel-based infinite scroll that fires a load event when the user reaches the start or end of a scrollable area.
API
Props
All props accepted by this component, with their type, default value and description.
- sideTInfiniteScrollSide'end'
- Which edge(s) of the scroll area to observe. "both" watches top and bottom simultaneously.
- modeTInfiniteScrollMode'intersect'
- How the next page is triggered. "intersect" fires automatically when the sentinel enters the viewport; "manual" shows a Load More button.
- loadMoreTextstring'Load more'
- Label for the Load More button shown in manual mode.
- emptyTextstring'No more items'
- Message displayed when the done callback is called with "empty".
- marginstring
- Root margin passed to the IntersectionObserver. Expands the detection zone, e.g. "0px 0px 200px 0px" to load ahead.
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- colorTColor
- Color applied to the progress spinner and the Load More button.
- bgColorTColor
- heightnumber | string
- Explicit height. Set this to make the component itself the scroll container.
- maxHeightnumber | string
- Maximum height before the scroll container clips and scrolls.
- maxWidthnumber | string
- minHeightnumber | string
- minWidthnumber | string
- widthnumber | string
- tagstring'div'
- HTML element rendered at the root of the scroll container.
- directionTDirection'vertical'
- Scroll axis to observe.
- fontSizeTFontSize
API
Slots
Content slots exposed by this component.
- #error
- Content shown after done("error") is called. Use props.onClick to retry.
- #empty
- Content shown after done("empty") is called. The default renders the emptyText string.
- #loading
- Custom loading indicator shown while a page fetch is in flight. The default renders an OrigamProgress spinner.
- #loadMore
- Custom Load More trigger shown in manual mode. The default renders an OrigamBtn.
- #default
- The scrollable list content. Items are appended here as new pages load.
API
Emits
Events emitted by this component.
- @load{ side: TInfiniteScrollSide, done: (status: 'ok' | 'empty' | 'error') => void }
- Fired when the sentinel enters the viewport (or the user clicks Load More in manual mode). Call done("ok") after appending data, done("empty") when there are no more pages, or done("error") on failure.
Interactive
Playground
Edit props live and see the component update in real time. The generated code snippet updates as you change values.
Rendering the live preview…
Usage
Examples
Ready-to-paste code snippets for your templates.
Automatic infinite scroll
Manual load mode