Copies›Progressive Blur

Progressive Blur

Text melts into blur at the page edges as it scrolls, like iOS. Stacked layers, any edge, exponential curve, sticky and viewport-pinned modes, optional tint.

Copy a ready prompt for Claude Code, Codex or Cursor

Seen on

Devouring Details (Rauno Freiberg)

Dependencies

reacttailwindcss

Interaction type

scroll

Install via CLI

pnpm dlx shadcn@latest add @copia/progressive-blur

Without the namespace: npx shadcn@latest add https://copia-ui.vercel.app/r/progressive-blur.json

How to use

demo.tsx
"use client"

import { useEffect, useRef } from "react"
import { ProgressiveBlur, type ProgressiveBlurProps } from "./progressive-blur"

const paragraph =
  "Most components here are recreations of the best interfaces on the web. We study how they work, rebuild them as a single file, add a feature or two and credit the people who made them first. Scroll and the words drift under the edges of the page, melting into blur the way iOS does it: layer over layer, a little softer each time, until the text is only a shape and then nothing at all."

/** Scrolls the page slowly for the preview recording; any user input stops it. */
function useDemoAutoScroll(ref: React.RefObject<HTMLElement | null>) {
  useEffect(() => {
    if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return
    let el: HTMLElement | null = ref.current?.parentElement ?? null
    while (el && !(["auto", "scroll"].includes(getComputedStyle(el).overflowY) && el.scrollHeight > el.clientHeight)) el = el.parentElement
    const scroller = el ?? (document.scrollingElement as HTMLElement)
    let position = scroller.scrollTop
    let last = performance.now()
    let frame = 0
    let stopped = false
    const stop = () => (stopped = true)
    const step = (now: number) => {
      if (stopped) return
      const max = scroller.scrollHeight - scroller.clientHeight
      position = position >= max - 1 ? 0 : position + (70 * (now - last)) / 1000
      scroller.scrollTop = position
      last = now
      frame = requestAnimationFrame(step)
    }
    frame = requestAnimationFrame(step)
    const events = ["wheel", "pointerdown", "touchstart", "keydown"] as const
    events.forEach((t) => window.addEventListener(t, stop, { once: true, capture: true }))
    return () => {
      cancelAnimationFrame(frame)
      events.forEach((t) => window.removeEventListener(t, stop, { capture: true }))
    }
  }, [ref])
}

/** Customizer values (layers, maxBlur, curve, tint) flow into both blurs. */
export default function Demo(props: Pick<ProgressiveBlurProps, "layers" | "maxBlur" | "curve" | "tint">) {
  const root = useRef<HTMLDivElement>(null)
  useDemoAutoScroll(root)
  return (
    <div ref={root} className="flex-1 bg-background text-foreground">
      <ProgressiveBlur {...props} direction="top" sticky className="h-32" />
      <article className="mx-auto flex max-w-xl flex-col items-center gap-12 px-8 pt-[28vh] pb-[30vh]">
        <div className="flex flex-col items-center gap-3">
          <span className="text-center text-[10px] leading-tight tracking-wide text-foreground/50 uppercase">
            Scroll down
            <br />
            to see the effect
          </span>
          <span className="h-14 w-px bg-foreground/40" />
        </div>
        {Array.from({ length: 6 }, (_, i) => (
          <p key={i} className="text-justify text-base leading-relaxed text-foreground/40">
            {paragraph}
          </p>
        ))}
      </article>
      <ProgressiveBlur {...props} direction="bottom" sticky className="h-32" />
    </div>
  )
}

Customization

Use the sliders button at the top right of the preview to tweak layers, maxBlur, curve, tint live and copy the generated JSX.

Props

PropTypeDefaultDescription
direction"top" | "bottom" | "left" | "right""bottom"Edge the blur grows toward.
layersnumber8Stacked blur layers; 6–10 looks smooth.
maxBlurnumber24Blur radius at the edge, in pixels.
curve"linear" | "exponential""exponential"How blur grows across layers.
tintbooleanfalseFade to the background color on top of the blur.
fixedbooleanfalsePin to the viewport edge for a page-wide effect.
stickybooleanfalseStick to the top or bottom of whatever scrolls (page or scrolling parent).
classNamestring-Size the blur area, e.g. h-32 or w-24.

Attribution

Inspired by Devouring Details (Rauno Freiberg). Recreated by Copia.

Read how it was reverse engineered

Source code

progressive-blur.tsx
import { cn } from "@/lib/utils"

type Direction = "top" | "bottom" | "left" | "right"

export type ProgressiveBlurProps = React.ComponentProps<"div"> & {
  /** Edge the blur grows toward. */
  direction?: Direction
  /** Stacked blur layers. 6–10 looks smooth; more costs performance. */
  layers?: number
  /** Blur radius at the edge, in pixels. */
  maxBlur?: number
  /** How blur grows across the layers. "exponential" reads more like iOS. */
  curve?: "linear" | "exponential"
  /** Fade toward the background color on top of the blur, hiding banding on busy content. */
  tint?: boolean
  /** Pin to the viewport edge instead of the nearest `relative` parent (page-wide effect). */
  fixed?: boolean
  /**
   * Stick to the top or bottom edge of whatever scrolls (the page or a scrolling
   * parent) while content moves under it. Place it first (top) or last (bottom)
   * inside the scrolling content.
   */
  sticky?: boolean
}

const GRADIENT_DIRECTION: Record<Direction, string> = {
  top: "to top",
  bottom: "to bottom",
  left: "to left",
  right: "to right",
}

const EDGE_CLASS: Record<Direction, string> = {
  top: "inset-x-0 top-0 h-1/3",
  bottom: "inset-x-0 bottom-0 h-1/3",
  left: "inset-y-0 left-0 w-1/3",
  right: "inset-y-0 right-0 w-1/3",
}

/**
 * Blur that grows smoothly toward an edge. `backdrop-filter` is uniform per
 * element, so N layers are stacked: layer i blurs more and is masked to a band
 * that overlaps its neighbours, which the eye reads as one continuous ramp.
 * Place it inside a `relative` container, or pass `fixed` to blur the page edges
 * while content scrolls under them. Size it with `className` (e.g. `h-40`).
 */
export function ProgressiveBlur({
  direction = "bottom",
  layers = 8,
  maxBlur = 24,
  curve = "exponential",
  tint = false,
  fixed = false,
  sticky = false,
  className,
  style,
  ...props
}: ProgressiveBlurProps) {
  const gradient = GRADIENT_DIRECTION[direction]
  const segment = 1 / (layers + 1)
  const pct = (n: number) => `${(n * segment * 100).toFixed(3)}%`

  const blur = (
    <div aria-hidden className={cn("pointer-events-none z-10", fixed ? "fixed" : "absolute", EDGE_CLASS[direction], className)} style={style} {...props}>
      {Array.from({ length: layers }, (_, i) => {
        const t = (i + 1) / layers
        const blur = maxBlur * (curve === "exponential" ? t * t : t)
        const mask = `linear-gradient(${gradient}, transparent ${pct(i)}, black ${pct(i + 1)}, black ${pct(i + 2)}, transparent ${pct(i + 3)})`
        return (
          <div
            key={i}
            className="absolute inset-0"
            style={{ backdropFilter: `blur(${blur.toFixed(2)}px)`, WebkitBackdropFilter: `blur(${blur.toFixed(2)}px)`, maskImage: mask, WebkitMaskImage: mask }}
          />
        )
      })}
      {tint && <div className="absolute inset-0" style={{ background: `linear-gradient(${gradient}, transparent 20%, var(--background))` }} />}
    </div>
  )

  // A zero-height sticky wrapper keeps the blur glued to the scroller's edge without taking space.
  if (sticky && (direction === "top" || direction === "bottom")) {
    return <div className={cn("pointer-events-none sticky z-10 h-0", direction === "top" ? "top-0" : "bottom-0")}>{blur}</div>
  }
  return blur
}

Keep in mind

Most components here are recreations of the best interfaces out there. We don't claim to be the original creators: this is our attempt to reverse engineer, replicate and often add a few features. We credit everyone we can; if we missed someone, let us know.

Contact

Found a bug or a missing credit? Open an issue

License & usage

  • — Free to use and modify in personal and commercial projects (MIT).
  • — No attribution required, but a link back to Copia is appreciated.
  • — Demo images are not part of the license; replace them with your own.
PreviousPerspective CarouselNext Token Swap
Scroll down
to see the effect

Most components here are recreations of the best interfaces on the web. We study how they work, rebuild them as a single file, add a feature or two and credit the people who made them first. Scroll and the words drift under the edges of the page, melting into blur the way iOS does it: layer over layer, a little softer each time, until the text is only a shape and then nothing at all.

Most components here are recreations of the best interfaces on the web. We study how they work, rebuild them as a single file, add a feature or two and credit the people who made them first. Scroll and the words drift under the edges of the page, melting into blur the way iOS does it: layer over layer, a little softer each time, until the text is only a shape and then nothing at all.

Most components here are recreations of the best interfaces on the web. We study how they work, rebuild them as a single file, add a feature or two and credit the people who made them first. Scroll and the words drift under the edges of the page, melting into blur the way iOS does it: layer over layer, a little softer each time, until the text is only a shape and then nothing at all.

Most components here are recreations of the best interfaces on the web. We study how they work, rebuild them as a single file, add a feature or two and credit the people who made them first. Scroll and the words drift under the edges of the page, melting into blur the way iOS does it: layer over layer, a little softer each time, until the text is only a shape and then nothing at all.

Most components here are recreations of the best interfaces on the web. We study how they work, rebuild them as a single file, add a feature or two and credit the people who made them first. Scroll and the words drift under the edges of the page, melting into blur the way iOS does it: layer over layer, a little softer each time, until the text is only a shape and then nothing at all.

Most components here are recreations of the best interfaces on the web. We study how they work, rebuild them as a single file, add a feature or two and credit the people who made them first. Scroll and the words drift under the edges of the page, melting into blur the way iOS does it: layer over layer, a little softer each time, until the text is only a shape and then nothing at all.