Infinite Scroll

More as the reader nears the end — or the start, for a chat — with whatever scrolls. It keeps asking until the content fills the box, keeps the reading place, and gives a feed its keys.

AdvancedExperimental

Usage

Feed

Article 1

What happened today, in a few words.

Article 2

What happened today, in a few words.

Article 3

What happened today, in a few words.

Article 4

What happened today, in a few words.

Article 5

What happened today, in a few words.

Article 6

What happened today, in a few words.

Article 7

What happened today, in a few words.

Article 8

What happened today, in a few words.

import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScFrame, ScInfiniteScroll, ScSpinner } from '@semantic-components/ui';import { SiLoaderCircleIcon } from '@semantic-icons/lucide-icons';
interface Item {  readonly id: number;  readonly title: string;  readonly text: string;}

Anatomy

One part, around your items. The Load more button and the status are your markup: a button calling loadMore(), a role="status" with your words.

import { ScInfiniteScroll } from '@semantic-components/ui';
<div scInfiniteScroll #feed="scInfiniteScroll" role="feed" aria-label="News" [loading]="loading()" [done]="done()" (more)="load()">  @for (item of items(); track item.id) { <article tabindex="0">…</article> }</div><p role="status">@if (loading()) { Loading… } @else if (done()) { That’s all. }</p><button (click)="feed.loadMore()">Load more</button>

How it asks

  • (more) when a marker after your items is within distance (200px) of the edge of what scrolls — itself, the box around it, or the page — and it is not loading, not done.
  • After each load it looks again: a first page shorter than the box asks again, until the box is full or there is no more.
  • auto off: only loadMore() asks — after an error, so a failing server isn't asked again and again.
  • direction="start", a chat: it opens at the end, and older items come in above while the one being read stays put — no column-reverse needed.

Keyboard

On a role="feed" with role="article" items (WAI-ARIA's feed):

  • Page Down / Page Up: the next or the previous article — on the last, more is asked for, so a keyboard reader loads as a scrolling one does.
  • Ctrl + End / Ctrl + Home: out of the feed, to what comes after it or before it.

Accessibility

  • aria-busy is on it while loading. For articles, a role="feed", each article with aria-posinset and aria-setsize (-1 until done).
  • Say what happens in a role="status" kept in the page: "Loading…", "That's all", an error.
  • Offer a Load more button where the content after the list (a footer) must stay within reach.

Examples

Load more button

  • Result 1
  • Result 2
  • Result 3
  • Result 4
  • Result 5

5 results shown.

import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScButton, ScFrame, ScInfiniteScroll } from '@semantic-components/ui';
interface Item {  readonly id: number;  readonly title: string;}
/** auto off: only the button asks — the footer stays within reach, and the reader decides. */@Component({

Error and retry

import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScButton, ScFrame, ScInfiniteScroll } from '@semantic-components/ui';
interface Item {  readonly id: number;  readonly title: string;}
/** A load fails: auto off, so it does not ask again by itself; the status says so and the button tries again. */@Component({

Chat

  1. Message 46
  2. Message 47
  3. Message 48
  4. Message 49
  5. Message 50
  6. Message 51
  7. Message 52
  8. Message 53
  9. Message 54
  10. Message 55
  11. Message 56
  12. Message 57
  13. Message 58
  14. Message 59
  15. Message 60
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScFrame, ScInfiniteScroll } from '@semantic-components/ui';
interface Message {  readonly id: number;  readonly text: string;  readonly mine: boolean;}
/** direction="start": it opens at the end, and older messages come in above as the reader scrolls up — the one they were reading stays where it was. */

Grid

import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScFrame, ScInfiniteScroll } from '@semantic-components/ui';
interface Item {  readonly id: number;  readonly name: string;}
/** Any layout: here a grid of products. The first page does not fill the box — it asks again, until the box is full or there is no more. */@Component({

RTL

المقال 1

المقال 2

المقال 3

المقال 4

المقال 5

المقال 6

المقال 7

المقال 8

import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation, signal } from '@angular/core';import { ScFrame, ScInfiniteScroll, ScSpinner } from '@semantic-components/ui';import { SiLoaderCircleIcon } from '@semantic-icons/lucide-icons';
interface Item {  readonly id: number;  readonly title: string;}

API reference

PartSelectorDescription
ScInfiniteScroll[scInfiniteScroll] Around your items: (more) near the end or the start; aria-busy; a feed’s keys. exportAs: loadMore().
InputTypeDefaultDescription
loadingbooleanfalse Your load is under way: nothing more is asked for.
donebooleanfalse There is no more.
distancenumber200 How near the end (px) asks for more.
direction'end' | 'start''end' `start`: a chat — older items come in above.
autobooleantrue Off: only loadMore() asks.