LayerwiseLayerwise
  • Features
  • Pricing
  • Templates
  • Docs
DownloadDownload
FeaturesPricingTemplatesDocsAI Website BuilderVibe CodingPersonal Software
DownloadDownload
  1. Glossary
  2. /
  3. Interaction feedback

Pull to refresh

Also called pull down to refresh or swipe to refresh

A gesture where you drag a list down from the top to reveal a spinner and load fresh content, common in mobile feeds and inboxes.

import { useRef, useState, type ReactNode, type TouchEvent } from 'react';
import { animate, motion, useMotionValue, useTransform } from 'motion/react';

const RESISTANCE = 0.5; // the list moves half as far as the finger
const THRESHOLD = 60; // px of list travel needed to refresh
const HOLD_AT = 48; // where the list waits while new items load
const SETTLE = { type: 'spring', bounce: 0 } as const;

// Desktop has no pull gesture, so keep a Refresh button there too.
type Props = { onRefresh: () => Promise<void>; children: ReactNode };

export function PullToRefresh({ onRefresh, children }: Props) {
  const y = useMotionValue(0);
  const rotate = useTransform(y, [0, THRESHOLD], [0, 360]);
  const startY = useRef<number | null>(null);
  const [refreshing, setRefreshing] = useState(false);

  async function refresh() {
    setRefreshing(true);
    animate(y, HOLD_AT, SETTLE);
    await onRefresh();
    setRefreshing(false);
    animate(y, 0, SETTLE);
  }

  function onTouchMove(event: TouchEvent<HTMLDivElement>) {
    if (startY.current === null || event.currentTarget.scrollTop > 0) return;
    const pulled = event.touches[0]!.clientY - startY.current;
    y.set(Math.max(0, pulled) * RESISTANCE);
  }

  function onTouchEnd() {
    if (startY.current === null) return;
    startY.current = null;
    if (y.get() > THRESHOLD) refresh();
    else animate(y, 0, SETTLE);
  }

  return (
    <div className='relative h-[32rem] overflow-hidden rounded-2xl border'>
      {/* Hidden behind the list until it moves; turns with the pull. */}
      <motion.span
        style={{ rotate }}
        className={`absolute top-3 left-1/2 -ml-3 size-6 rounded-full border-2 border-muted border-t-foreground ${refreshing ? 'animate-spin' : ''}`}
      />
      <motion.div
        style={{ y }}
        onTouchStart={(event) => {
          const atTop = event.currentTarget.scrollTop === 0 && !refreshing;
          startY.current = atTop ? event.touches[0]!.clientY : null;
        }}
        onTouchMove={onTouchMove}
        onTouchEnd={onTouchEnd}
        // contain: the browser's own pull-to-refresh doesn't fight this one.
        className='relative h-full overflow-y-auto overscroll-y-contain bg-background'
      >
        {children}
      </motion.div>
    </div>
  );
}
Add pull to refresh to the inbox list on mobile: when the list is scrolled to the top and the user drags down, move the list with increasing resistance (about half the finger distance), and show a spinner that rotates with the pull. If released past 60px, hold the list 48px down with the spinner spinning until new messages load, then spring back. Set overscroll-behavior-y: contain on the page, and keep a refresh button for desktop.

Paste into Layerwise or any AI coding tool.

What is Pull to refresh?

Pull to refresh starts when a list is already scrolled to the top and you keep dragging down. The content follows with growing resistance, and an indicator appears in the gap, often spinning as you pull. Release past a threshold and the spinner keeps going while new content loads, then the list springs back with the new items on top.

The resistance is what makes it feel right: the list moves less than the finger, so the pull feels elastic, and a short pull that does not reach the threshold simply springs back. It suits feeds, inboxes, and lists that change often on phones. On desktop, people expect a refresh button, so keep one available.

Phone browsers have their own pull-to-refresh that reloads the whole page. In Chrome on Android, setting overscroll-behavior-y: contain on the page turns it off, so it does not fight with yours.

Often confused with

Infinite scroll
Infinite scroll loads more items when you reach the bottom of a list. Pull to refresh loads newer items when you pull down from the top.

Related terms

All terms

Rubber-banding

An edge effect where content dragged past its limit moves less than your finger, then springs back on release, like a stretched rubber band.

Spinner

A small looping animation, usually a rotating ring, that shows the app is busy with a short task of unknown length.

Loading state

The view a screen shows while its data is on the way, designed together with the outcomes that follow: loaded, empty, or error.

Drag gesture

Moving an element by pressing on it and sliding the pointer or finger, usually within set bounds and with a glide after release.

Build it with Layerwise

Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.

DownloadDownloadRead the docs
LayerwiseLayerwise

Build full-stack web apps in minutes with AI.

Product

  • Features
  • Pricing
  • Download
  • Templates

Solutions

  • AI Website Builder
  • Vibe Coding
  • Personal Software

Resources

  • Documentation
  • Changelog
  • Blog
  • Vibe Coding Glossary
  • llms.txt
  • llms-full.txt

Company

  • About
  • Contact

Legal

  • Privacy
  • Analytics Privacy
  • Terms
  • Security
  • Abuse

© 2026 Layerwise. All rights reserved.

Entrances & exits

  • Fade in
  • Slide in
  • Scale in
  • Pop in
  • Blur in
  • Reveal animation
  • Enter and exit animations

Timing & sequencing

  • Duration
  • Delay
  • Keyframes
  • Tweening
  • Stagger
  • Orchestration
  • Fill mode
  • Stepped animation
  • Looping animation
  • Yoyo animation

Easing

  • Easing
  • Linear easing
  • Ease-in
  • Ease-out
  • Ease-in-out
  • Cubic-bezier
  • Asymmetric easing
  • Overshoot easing

Springs & physics

  • Spring animation
  • Stiffness
  • Damping
  • Mass
  • Bounce
  • Velocity
  • Momentum
  • Interruptible animation
  • Rubber-banding

Transforms

  • Translate
  • Scale
  • Rotate
  • Skew
  • 3D flip
  • Perspective
  • Transform origin
  • Origin-aware animation

State transitions

  • Crossfade
  • Morph
  • Shared element transition
  • Layout animation
  • Height auto animation
  • Direction-aware transition
  • Continuity transition
  • Page transition
  • View Transitions API

Scroll effects

  • Scroll reveal
  • Scroll-driven animation
  • Parallax scrolling
  • Scrollytelling
  • Scroll pinning
  • Horizontal scroll section
  • Scroll progress bar
  • Scroll snap
  • Smooth scrolling

Interaction feedback

  • Hover effect
  • Press feedback
  • Ripple effect
  • Shake animation
  • Hold to confirm
  • Drag gesture
  • Drag to reorder
  • Swipe to dismiss
  • Pull to refresh
  • Magnetic button
  • Custom cursor
  • 3D tilt card
  • Spotlight card

Text effects

  • Typewriter effect
  • Text scramble
  • Split text animation
  • Text morph
  • Rotating words
  • Gradient text
  • Shimmer text
  • Number ticker
  • Tabular numbers
  • Underline animation

Loops & ambient motion

  • Marquee
  • Pulse animation
  • Float animation
  • Orbit animation
  • Idle animation
  • Particle background
  • Border beam
  • Confetti
  • Animated gradient

Visual effects

  • Blur
  • Clip-path
  • Mask
  • Before/after slider
  • SVG line drawing
  • Lottie animation

Motion principles

  • Purposeful animation
  • Anticipation
  • Follow-through
  • Squash and stretch
  • Perceived performance
  • Frequency of use
  • Spatial consistency
  • Reduced motion

Animation performance

  • Frame rate (FPS)
  • Jank
  • GPU acceleration
  • will-change
  • Layout thrashing

Layout

  • Hero section
  • Above the fold
  • Sticky header
  • Sidebar
  • Bento grid
  • Card
  • Flexbox
  • CSS Grid
  • Padding vs margin
  • Responsive design
  • Container
  • Masonry layout
  • Split screen
  • Z-index
  • Overflow

Components

  • Button variants
  • Modal
  • Drawer
  • Popover
  • Tooltip
  • Dropdown menu
  • Context menu
  • Toast notification
  • Tabs
  • Segmented control
  • Accordion
  • Carousel
  • Command palette
  • Combobox
  • Toggle switch
  • Checkbox
  • Radio button
  • Date picker
  • Breadcrumb
  • Pagination
  • Infinite scroll
  • Badge
  • Avatar stack
  • Empty state
  • Skeleton screen
  • Spinner
  • Progress bar
  • Data table
  • Stepper
  • Floating label
  • Inline validation
  • Alert banner
  • Tag input

States & patterns

  • Interaction states
  • Focus ring
  • Loading state
  • Optimistic UI
  • Debounce
  • Lazy loading
  • Dark mode
  • Micro-interaction
  • Affordance
  • Undo
  • Drag and drop
  • Keyboard shortcut

Visual styles

  • Glassmorphism
  • Liquid glass
  • Neumorphism
  • Claymorphism
  • Neo-brutalism
  • Skeuomorphism
  • Flat design
  • Mesh gradient
  • Aurora background
  • Grain texture
  • Glow effect
  • Drop shadow
  • Border radius
  • Grid background
  • Typographic hierarchy
  • Accent color
  • Color contrast

Vibe coding & AI

  • Vibe coding
  • Prompt
  • Context window
  • Token
  • AI agent
  • Tool call
  • Hallucination
  • Diff
  • Live preview
  • Checkpoint
  • Git commit
  • Deploy
  • Frontend and backend
  • API
  • Database
  • Rules file
  • MCP
  • Plan mode
  • Visual edit

Inbox

Priya PatelStandup moved to 10
Leo MartinsPricing page is live
Ava BrooksInterview notes
Sam LeeInvoice paid