Pull to Refresh

Free

A scrolling region that refreshes when pulled down from the top on a touch screen. The pull starts only at the top and only downward — every other touch stays a native scroll, through passive listeners — with an indicator that moves by transform alone, a Refresh button for the keyboard and screen readers, and "Refreshing…" / "Updated" announced. The bare `svPullToRefresh` directive draws no indicator, for your own.

</>sv-pull-to-refresh pull to refreshrefreshmobilegesturetouchfeedinbox
import { SvPullToRefreshComponent } from '@styloviz/layout/pull-to-refresh';

Demo & usage

Basic usage

Usage example — open the gallery for the full interactive demo.

An interactive demo for this component lives in the gallery.

Open live demo

More examples

With an httpResource

example.htmlAngular
<sv-pull-to-refresh class="min-h-0 flex-1" ariaLabel="Inbox"
  [refreshing]="inbox.isLoading()" (refresh)="inbox.reload()">
  <ul>…</ul>
</sv-pull-to-refresh>

A visible Refresh button

example.htmlAngular
<sv-pull-to-refresh refreshButton="always" [refreshing]="busy()" (refresh)="load()">…</sv-pull-to-refresh>

Your own indicator, with the directive

example.htmlAngular
<div class="h-1 origin-left bg-primary-500" [style.transform]="'scaleX(' + ptr.progress() + ')'" aria-hidden="true"></div>
<div svPullToRefresh #ptr="svPullToRefresh" class="h-96 overflow-y-auto"
     role="region" tabindex="0" aria-label="Activity"
     [refreshing]="busy()" (refresh)="load()">
  <button type="button" (click)="ptr.trigger()">Refresh</button>
  …
</div>

When to use

  • A feed, inbox or list on a phone whose newest items arrive at the top.
  • Alongside, never instead of, a visible way to refresh on a desktop page — `refreshButton="always"` gives you one.
  • Not for loading older items at the bottom (use infinite scroll or a Load more button) and not on a page whose content does not change.

Async states

None — this component has nothing to load, so it has no loading, empty or error state to drive.

Inputs

NameTypeDefaultDescription
refreshingbooleanfalseTrue while your refresh runs: the indicator holds and spins, and "Updated" is announced when it goes false.
thresholdnumber72Indicator travel (px) that arms a refresh.
resistancenumber0.5Indicator travel per pixel of finger travel, 0.1–1.
disabledbooleanfalseTurn the pull and the button off.
refreshButtonSvPullToRefreshButton'focus'How the non-gesture Refresh button shows.
ariaLabelstring''The scrolling region's accessible name.
labelsPartial<SvLayoutLabels>{}Per-instance overrides for the package labels.

Outputs

EventPayload typeDescription
refreshvoidFetch again — from a pull, the button, or `trigger()`. Never while `refreshing`.

Customization & theming

  • `threshold` (indicator px that arms a refresh, 72) and `resistance` (indicator px per finger px, 0.5) tune the feel.
  • `refreshButton`: `focus` (visible on keyboard focus, like a skip link — the default), `always` or `none`.
  • `disabled` turns off the pull and the button.
  • The disc uses the `primary-*` tokens; strings come from the `layout` labels (`pullRegion`, `pullRefresh`, `pullRefreshing`, `pullUpdated`).
  • For your own indicator, use `svPullToRefresh` on any scroller and read `distance()`, `progress()`, `state()` and `tracking()`; `trigger()` refreshes from code.

Best practices

  • Do: Bind `[refreshing]` to your request, so the spinner holds exactly as long as the fetch and "Updated" is announced when it ends.
  • Do: Size the component (a fixed height, or `min-h-0 flex-1` in a column): it is the scroll container.
  • Don't: Don't set `refreshButton="none"` unless your page has its own Refresh control — the pull is touch-only.
  • Tip: A failed refresh should say so in the page and keep what was there — the region does not clear its content.

Accessibility

  • The region is a named, focusable `role="region"` (a scrolling area must be reachable by keyboard), with `aria-busy` while refreshing.
  • A real Refresh button sits first inside it — the keyboard, switch and screen-reader way to refresh (WCAG 2.5.7: the pull has a single-pointer alternative).
  • "Refreshing…" and "Updated" are announced through a polite status region, whichever way the refresh started.
  • The indicator is decorative (`aria-hidden`). It moves by transform and fades by opacity only; under reduced motion it settles without a slide and the spinner does not spin.
  • Every listener is passive and none calls `preventDefault()`, so the gesture never delays or blocks native scrolling.

Feedback on Pull to Refresh

Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.

Loads giscus.app and GitHub — nothing is fetched until you click.