Skip to content

Pull to refresh

Expressive

Pull down at the top of a list or page to reload it, with a contained loading indicator that follows the pull.

import { PullToRefresh } from '@windmorph/react';

Purpose

Pull to refresh reloads content with a gesture. Use it at the start of lists, grid lists and card collections where the newest content appears first, for content that changes often, so people have a good chance of seeing something new.

The M3 loading indicator is the one used for pull to refresh, in its contained form, which stands out from the content it is drawn over.

Behaviour

  • The gesture only starts when the content is at its top and the drag goes down; scrolling is never blocked. The indicator follows at half the drag's speed.
  • To make the refresh intentional, the indicator must pass a threshold (threshold, 80px). Letting go past it refreshes; pushing back below it, or letting go before it, cancels.
  • The indicator stays at the threshold until refreshing is false (or the promise from onRefresh settles), and it never scrolls off-screen: it hangs from a sticky layer at the top of the area. When a sticky app bar covers the top of a scrolling page, move it down with classNames.layer (e.g. top-16).
  • Wrap a scroll container (give the area a height and overflow-y-auto, or put the scrolling element inside it) or the whole page. The area sets overscroll-behavior-y: contain and claims the touch while pulling, so the browser's own pull to refresh and rubber-banding don't start as well.
  • A gap-* on a flex area or space-y-* on a block area spaces the content exactly. On a grid area, one row gap appears above the content: every child of a grid is a grid item, including the indicator's layer. Put the grid on an inner element: <PullToRefresh><div className="grid gap-4">…</div></PullToRefresh>.

When not to use

For content that rarely changes, or as the only way to refresh: always offer a refresh button too.

See also

  • Loading indicator: An Expressive shape that morphs while it rotates; replaces the spinning circle.
  • List: Rows with headline, overline, supporting text and leading or trailing content (icons, avatars, images, video thumbnails); items can be links, switches, checkboxes or radio buttons, and put in order by drag or a menu.
  • Top app bar: A header with the screen title and actions, in three sizes, with scroll behaviour.