Skip to Content
Zuri
Components

Progressive blur

A blur that grows toward the edge of a scroller, so content softens as it leaves the view.

Live preview
Theme
Preview width
  • School feesToday, 09:12TZS 45,000
  • Mobile data bundleToday, 08:40TZS 5,000
  • Water billYesterdayTZS 18,500
  • Rent shareYesterdayTZS 150,000
  • GroceriesMonTZS 32,400
  • Electricity tokenMonTZS 20,000
  • Bus fareSunTZS 2,500
  • Refund: school kitSatTZS 12,000
  • Savings top-upFriTZS 50,000
  • PharmacyThuTZS 14,300

Use ProgressiveBlur at the edge of a scrolling area, such as a list of transactions, so rows soften as they scroll out of view instead of being cut off by a hard line. It hints that there is more to scroll to. It needs no JavaScript.

Installation

pnpm dlx shadcn@latest add https://components.abdulqadirmsingi.com/r/progressive-blur.json

This also adds two small CSS rules (the fallbacks described below) to your CSS.

Usage

Put it inside a relative container, over the scrolling content, and give the content bottom padding at least as tall as the blur, so the last item can scroll clear of it.

import { ProgressiveBlur } from "@/components/ui/progressive-blur";

<div className="relative h-72 overflow-hidden">
  <section aria-label="Recent transactions" tabIndex={0} className="h-full overflow-y-auto p-4 pb-28">
    …
  </section>
  <ProgressiveBlur />
</div>

The scrolling element needs tabIndex={0} and a name, so keyboard users can scroll it; the blur itself is decorative.

Top and bottom, with a fade

fade also fades the content to the page background colour, so it disappears completely at the edge. Use it when the background is a plain colour.

Live preview
Theme
Preview width
  • School feesToday, 09:12TZS 45,000
  • Mobile data bundleToday, 08:40TZS 5,000
  • Water billYesterdayTZS 18,500
  • Rent shareYesterdayTZS 150,000
  • GroceriesMonTZS 32,400
  • Electricity tokenMonTZS 20,000
  • Bus fareSunTZS 2,500
  • Refund: school kitSatTZS 12,000
  • Savings top-upFriTZS 50,000
  • PharmacyThuTZS 14,300

A side

Live preview
Theme
Preview width
School feesTZS 45,000
Mobile data bundleTZS 5,000
Water billTZS 18,500
Rent shareTZS 150,000
GroceriesTZS 32,400
Electricity tokenTZS 20,000

How it works

It stacks a few blur layers, each confined by a mask to its own band, and the strength doubles from one layer to the next (0.75, 1.5, 3, 6 and 12 pixels with the defaults). The bands overlap, so the layers blend into one smooth ramp that is strongest at the edge.

Props

ProgressiveBlur extends native <div> props (except children) and spreads them onto the element, including ref (React 19). It is a Server Component.

Props
PropTypeDefaultDescription
side"top" | "bottom" | "left" | "right""bottom"The edge it sits on. These are physical edges: it is the visible side of the scroller that content disappears past.
sizenumber | string"6rem"How far it reaches in from the edge. A number is pixels; a string is any CSS length.
strengthnumber12The strongest blur, in pixels, at the very edge.
stepsnumber5How many stacked layers, from 1 to 6. More is smoother but costs more to paint.
fadebooleanfalseAlso fade the content to the page background colour.

Accessibility

  • It is purely decorative: it is hidden from assistive technology, and it never takes a click, tap or text selection, because it ignores pointer events.
  • Text under the blur is only blurred visually. Screen readers still read it. Don't leave anything essential permanently under the blur: give the content end padding so the last item scrolls clear, as in the examples.
  • Make the scrolling area keyboard-reachable (tabIndex={0}, a name, a visible focus ring).
  • It never animates. There is no motion to turn off for prefers-reduced-motion.
  • If someone prefers reduced transparency, or the browser has no backdrop-filter, the blur layers are dropped. With fade on, the content still fades out, so it degrades to a plain fade rather than a hard edge.

Performance

Every layer is a real backdrop blur, and they are expensive to paint, so the Zuri glass rules apply: keep the count low (the default is 5, the cap is 6), don't animate the strength, and use it on one or two edges at a time, not on many elements in a long list.

Tokens used

--background (only with fade).

Known limitations

  • The blur is stacked bands, so with very large strength and very few steps you may see faint steps. Raise steps or lower strength.
  • It blurs whatever is behind it, including anything else you place there, not just the scrolling content.
  • Edges are physical (left and right do not flip in right-to-left layouts), because the scroller's visible edge does not flip.
  • Not tested on every browser: backdrop blur with masks is well supported in current browsers, but old ones fall back to no blur.

Source

import type { ComponentProps, CSSProperties } from "react";import { cn } from "@/lib/utils";/** Which edge of the container the blur sits on. These are physical edges, because it is the *  visible side of a scroller that content disappears past, whichever way the text runs. */export type BlurSide = "top" | "bottom" | "left" | "right";export interface ProgressiveBlurProps extends Omit<ComponentProps<"div">, "children"> {  /** The edge it sits on. Defaults to "bottom". */  side?: BlurSide;  /** How far it reaches in from the edge: a number of pixels, or any CSS length. Defaults to 6rem. */  size?: number | string;  /** The strongest blur, in pixels, at the very edge. Defaults to 12. */  strength?: number;  /** How many stacked blur layers. More is smoother but costs more to paint. 1 to 6; defaults to 5. */  steps?: number;  /** Also fade the content to the page background colour, so it disappears completely at the edge. */  fade?: boolean;}export const MAX_STEPS = 6;/** Which way the gradient runs: from the content side toward the edge, where the blur is strongest. */const toward = { top: "to top", bottom: "to bottom", left: "to left", right: "to right" } as const;const place = {  top: "inset-x-0 top-0",  bottom: "inset-x-0 bottom-0",  left: "inset-y-0 left-0",  right: "inset-y-0 right-0",} as const;export function clampSteps(steps: number): number {  return Number.isFinite(steps) ? Math.min(MAX_STEPS, Math.max(1, Math.round(steps))) : 5;}/** The blur for each layer, weakest first: it doubles from one layer to the next. */export function layerBlurs(strength: number, steps: number): number[] {  const n = clampSteps(steps);  const max = Number.isFinite(strength) ? Math.max(0, strength) : 12;  return Array.from({ length: n }, (_, i) => Math.round((max / 2 ** (n - 1 - i)) * 100) / 100);}/** * The mask that confines layer `i` to its own band. Bands overlap and fade in and out, so the * layers blend into one smooth ramp. The strongest layer is solid all the way to the edge. */export function layerMask(side: BlurSide, i: number, steps: number): string {  const n = clampSteps(steps);  const step = 100 / (n + 1);  const at = (k: number) => `${Math.round(k * step * 100) / 100}%`;  const stops = [`transparent ${at(i)}`, `black ${at(i + 1)}`];  if (i < n - 1) stops.push(`black ${at(i + 2)}`, `transparent ${at(i + 3)}`);  else stops.push("black 100%");  return `linear-gradient(${toward[side]}, ${stops.join(", ")})`;}/** * A blur that grows toward the edge of a scroller, so content softens as it leaves the view instead * of being cut off. Put it inside a `relative` container, over the scrolling content, and give the * content bottom padding at least as large as `size` so the last item can scroll clear of it. * * It is purely decorative: hidden from assistive technology and it never takes a click or a touch. * It needs no JavaScript. Where `backdrop-filter` is missing, or someone prefers reduced * transparency, the blur layers are dropped (see the item's CSS); with `fade` the content still * fades out, so it degrades to a plain fade instead of a hard edge. */export function ProgressiveBlur({  side = "bottom",  size = "6rem",  strength = 12,  steps = 5,  fade = false,  className,  style,  ...props}: ProgressiveBlurProps) {  const length = typeof size === "number" ? `${size}px` : size;  const vertical = side === "top" || side === "bottom";  const blurs = layerBlurs(strength, steps);  const sizing: CSSProperties = vertical ? { height: length } : { width: length };  return (    <div      data-side={side}      className={cn("zuri-pblur pointer-events-none absolute", place[side], className)}      style={{ ...sizing, ...style }}      {...props}      aria-hidden="true"    >      {blurs.map((blur, i) => {        const mask = layerMask(side, i, blurs.length);        return (          <span            // The layers never change order or number for a given set of props.            // biome-ignore lint/suspicious/noArrayIndexKey: a fixed, ordered stack of identical layers.            key={i}            data-pblur-layer=""            className="absolute inset-0 block"            style={{              backdropFilter: `blur(${blur}px)`,              WebkitBackdropFilter: `blur(${blur}px)`,              maskImage: mask,              WebkitMaskImage: mask,            }}          />        );      })}      {fade ? (        <span          data-pblur-fade=""          className="absolute inset-0 block"          style={{ background: `linear-gradient(${toward[side]}, transparent, var(--background))` }}        />      ) : null}    </div>  );}

On this page