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

Parallax scrolling

Also called parallax effect

A scroll effect where background layers move slower than the foreground, which creates a sense of depth as the page scrolls.

import { useRef } from 'react';
import {
  motion,
  useReducedMotion,
  useScroll,
  useTransform
} from 'motion/react';

// Fraction of the scroll speed each far layer moves at. 1 is normal speed.
const SKY_SPEED = 0.2;
const MOUNTAINS_SPEED = 0.5;

const LAYER = 'absolute inset-0 size-full object-cover';

export function ParallaxHero() {
  const ref = useRef<HTMLElement>(null);
  const reduceMotion = useReducedMotion();
  // 0 with the hero's top at the top of the viewport, 1 once it has scrolled out.
  const { scrollYProgress } = useScroll({
    target: ref,
    offset: ['start start', 'end start']
  });
  // Pushing a layer down while the page scrolls up makes it move slower on screen.
  const skyY = useTransform(
    scrollYProgress,
    [0, 1],
    ['0%', `${(1 - SKY_SPEED) * 100}%`]
  );
  const mountainsY = useTransform(
    scrollYProgress,
    [0, 1],
    ['0%', `${(1 - MOUNTAINS_SPEED) * 100}%`]
  );

  return (
    <section ref={ref} className='relative h-screen overflow-hidden'>
      <motion.img
        src='/hero/sky.webp'
        alt=''
        style={reduceMotion ? undefined : { y: skyY }}
        className={LAYER}
      />
      <motion.img
        src='/hero/mountains.webp'
        alt=''
        style={reduceMotion ? undefined : { y: mountainsY }}
        className={LAYER}
      />
      <img src='/hero/foreground.webp' alt='' className={LAYER} />
      <h1 className='relative pt-32 text-center text-5xl font-semibold text-white'>
        Into the mountains
      </h1>
    </section>
  );
}
Add parallax scrolling to the hero: split the illustration into three layers (sky, mountains, foreground) that move at 20%, 50%, and 100% of the scroll speed as the hero scrolls out of view. Drive transform: translateY from scroll position, keep the headline at normal speed, and disable the effect when prefers-reduced-motion is set.

Paste into Layerwise or any AI coding tool.

What is Parallax scrolling?

Parallax scrolling borrows a trick from side-scrolling games: things far away move slowly and things up close move fast. On a web page, a hero illustration might scroll at a fraction of normal speed while the headline and content scroll normally, so the scene feels layered.

It works best in a hero or one illustrated section where depth adds to the story. Use two to four layers with clearly different speeds, and keep text on a layer that moves at normal speed so it stays easy to read.

Strong or constant parallax can make some people feel motion sick, so turn it off when prefers-reduced-motion is set. Move layers with transform; the older background-attachment: fixed trick is ignored by many mobile browsers.

Related terms

All terms

Scroll-driven animation

An animation whose progress is tied directly to the scroll position, so it moves forward as you scroll down and rewinds as you scroll up.

Hero section

The large first section at the top of a landing page, with a headline, a short subhead, a call to action, and a visual.

Perspective

A CSS property that sets how far the viewer sits from a 3D scene, so rotated elements look deep up close and flatter from far away.

Reduced motion

An operating system setting that asks apps to minimize movement, which websites detect with the prefers-reduced-motion media query.

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

Into the hills

Trail guide

  • Day 1Ridge loop8 mi
  • Day 2Lake overlook11 mi
  • Day 3Summit trail6 mi
  • Day 4Valley return9 mi