# Progressive Blur

> Progressive blur for React and shadcn: a backdrop blur that ramps up to 20px toward an edge, under sticky headers, bottom bars and composers.

A blur that ramps from 0 to 20px over 80px toward an edge, from stacked masked backdrop layers, for headers, bottom bars and composers. Optionally scroll-linked so it appears only once content is underneath.

Also known as a gradual blur.

- Tier: Free (MIT)
- Interaction: Scroll
- Page: https://eased.dev/components/progressive-blur
- Installs: motion
- Registry: https://eased.dev/r/progressive-blur.json

## Install

```bash
npx shadcn add https://eased.dev/r/progressive-blur.json
```

A blur that ramps from nothing to 20px over 80px toward an edge, built from stacked masked backdrop layers, for sticky headers, bottom bars and composers.

## When to use

- A header or toolbar floating over a scrolling list, where content should soften as it passes under instead of meeting a hard frosted strip.
- A bottom bar or a chat composer over a feed or a conversation.
- Any edge where the blur should appear only once content is actually underneath: link it to the scroller.

## When not to use

- Fading a scroller's own edges where there is more to scroll, with no bar on top: use a [Scroll Area](/components/scroll-area).
- A solid header that content scrolls behind out of sight: a plain background is cheaper.

## Usage

Place it as a sibling over the scroller, in a positioned parent, and render the header after it.

```tsx inbox.tsx
import { useRef } from "react";
import { ProgressiveBlur } from "@/components/eased/progressive-blur/progressive-blur";

export function Inbox() {
  const scroller = useRef<HTMLDivElement>(null);
  return (
    <div className="relative h-96">
      <div ref={scroller} className="h-full overflow-y-auto pt-12">…</div>
      <ProgressiveBlur side="top" size={72} scrollRef={scroller} />
      <header className="absolute inset-x-0 top-0 h-12">Inbox</header>
    </div>
  );
}
```

## Examples

### Under a composer

At the bottom edge, a linked blur shows while there is more below and fades out at the end of the conversation.

```tsx
<div className="relative h-[32rem]">
  <div ref={thread} className="h-full overflow-y-auto pb-24">…</div>
  <ProgressiveBlur side="bottom" size={96} scrollRef={thread} className="z-10" />
  <div className="absolute inset-x-3 bottom-3 z-20">
    <Composer onSubmit={send} />
  </div>
</div>
```

### Fixed strength

Without a scroller, set `strength` (a number or a MotionValue from 0 to 1).

```tsx
<ProgressiveBlur side="bottom" strength={0.6} tint={false} />
```

## API reference

### ProgressiveBlur

| Prop | Type | Default | Description |
|---|---|---|---|
| `side` | `"top" \| "bottom" \| "left" \| "right"` | `"top"` | The edge the blur is strongest at; it pins itself flush to that edge. |
| `size` | `number` | `80` | Ramp length in px. |
| `maxBlur` | `number` | `20` | Blur at the edge, px. |
| `layers` | `number` | `6` | More is smoother and costs more GPU. At least 2. |
| `tint` | `boolean` | `true` | A surface-coloured scrim under the ramp, so text over busy content stays legible. |
| `scrollRef` | `RefObject<HTMLElement \| null> \| HTMLElement \| null` | | Links strength to scroll. Top and left fade in as you scroll away from the start; bottom and right show while there is more to scroll. |
| `scrollRange` | `number` | `size` | Scroll distance to full strength, px. |
| `strength` | `number \| MotionValue<number>` | `1` | Strength from 0 to 1, when there is no `scrollRef`. |
| `className` | `string` | `""` | Position and stacking, e.g. `z-10`. |

A ref whose scroller mounts later links on the next render. Rows added or resized later re-measure at once.

## Accessibility

- It is `aria-hidden` and never takes pointer events, so clicks and scrolling pass through to the content underneath.
- The tint keeps text in the header legible over busy content; keep it on unless the bar has its own background.

## Motion

Six stacked backdrop layers, each double the last one's radius and masked to an overlapping band, so content softens gradually toward the edge. Linked to a scroller, strength follows the scroll position directly, with no animation of its own, so reduced motion needs no separate branch. Browsers without `backdrop-filter` show the tint only.

## Notes for AI

Put ProgressiveBlur as a sibling of the scroller, not inside it (it would scroll away), in a parent with `position: relative`, and render the header or bar after it so the bar sits on top. Pass `scrollRef` whenever there is a scroller, so the blur is gone when nothing is underneath.

Do not put `opacity`, `filter` or `mask` on it or on any ancestor up to the scroller: any of them becomes the backdrop root and the blur goes blank. That is why strength is applied as each layer's own opacity; fade it with `strength`, never with a wrapper.

## Related

- [Scroll Area](/components/scroll-area): a scroller whose edges fade where there is more.
- [Composer](/components/composer): a message input to float over a conversation.

## Example

`components/eased/progressive-blur/progressive-blur-demo.tsx`

```tsx
"use client";

import { useRef, useState } from "react";
import { Button } from "../button/button";
import { DemoFrame } from "../lib/demo-frame";
import { ScrollArea } from "../scroll-area/scroll-area";
import { Segmented } from "../segmented/segmented";
import { ProgressiveBlur } from "./progressive-blur";

type Mode = "ramp" | "flat" | "off";

const MODES = [
  { value: "ramp", label: "Ramp" },
  { value: "flat", label: "Flat" },
  { value: "off", label: "Off" },
] as const;

const TONES = [
  "bg-info-subtle fill-info-text",
  "bg-warning-subtle fill-warning-text",
  "bg-success-subtle fill-success-text",
  "bg-danger-subtle fill-danger-text",
  "bg-surface-active fill-text-secondary",
  "bg-brand-subtle fill-brand-text",
];

const ALBUMS = [
  ["Low Tide", "Mara Lindqvist"],
  ["Paper Suns", "The Overpass"],
  ["Northern Rooms", "Iso Kaito"],
  ["Glasshouse", "Dela Cruz"],
  ["Small Hours", "June Arden"],
  ["Field Notes", "Halden Rowe"],
  ["Static Bloom", "Neon Parish"],
  ["Slow Light", "Halden Rowe"],
  ["Copper Coast", "Mara Lindqvist"],
  ["Weather Report", "Sol Ferreira"],
  ["After Image", "Iso Kaito"],
  ["Open Water", "The Overpass"],
];

/** A music library whose header and mini player blur the covers scrolling under them. */
export function ProgressiveBlurDemo() {
  const [mode, setMode] = useState<Mode>("ramp");
  const scroller = useRef<HTMLDivElement>(null);

  return (
    <DemoFrame
      title="Progressive Blur"
      actions={<Segmented size="sm" options={MODES} value={mode} onValueChange={setMode} aria-label="Blur style" />}
    >
      <div className="relative min-h-0 flex-1">
        <ScrollArea viewportRef={scroller} fade={0} className="h-full" contentClassName="px-4 pt-14 pb-20" aria-label="Albums">
          <ul className="grid grid-cols-3 gap-x-3 gap-y-4 @max-xs:grid-cols-2">
            {ALBUMS.map(([title, artist], i) => (
              <li key={title} className="min-w-0">
                <Cover tone={TONES[i % TONES.length]} shape={i % 4} />
                <p className="mt-1.5 truncate text-ui-sm font-medium text-text">{title}</p>
                <p className="truncate text-ui-xs text-text-muted">{artist}</p>
              </li>
            ))}
          </ul>
        </ScrollArea>

        {mode === "ramp" && <ProgressiveBlur side="top" size={72} scrollRef={scroller} scrollRange={48} />}
        {mode === "ramp" && <ProgressiveBlur side="bottom" size={96} scrollRef={scroller} scrollRange={48} />}
        {mode === "flat" && (
          <>
            <div aria-hidden className="pointer-events-none absolute inset-x-0 top-0 h-12 bg-surface/60 backdrop-blur-[20px]" />
            <div aria-hidden className="pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-surface/60 backdrop-blur-[20px]" />
          </>
        )}

        <div className="pointer-events-none absolute inset-x-0 top-0 flex h-12 items-center justify-between px-4">
          <p className="text-ui-lg font-medium text-text">Library</p>
          <p className="text-ui-sm text-text-muted tabular-nums">{ALBUMS.length} albums</p>
        </div>

        <NowPlaying />
      </div>
    </DemoFrame>
  );
}

function NowPlaying() {
  const [playing, setPlaying] = useState(false);
  return (
    // Inset to the grid's 16px content line; the cover and button nest inside its 10px corner.
    <div className="absolute inset-x-4 bottom-4 flex items-center gap-3 rounded-control border border-line bg-surface-raised p-1 shadow-floating [--pad:4px] [--radius-outer:var(--eased-radius-control)]">
      <span className="size-9 shrink-0 overflow-hidden radius-nested">
        <Cover tone={TONES[0]} shape={0} flat />
      </span>
      <div className="min-w-0 flex-1">
        <p className="truncate text-ui-sm font-medium text-text">Low Tide</p>
        <p className="truncate text-ui-xs text-text-muted">Mara Lindqvist</p>
      </div>
      <Button
        variant="ghost"
        size="icon"
        aria-label={playing ? "Pause" : "Play"}
        onClick={() => setPlaying((p) => !p)}
        className="radius-nested! text-text"
      >
        <svg width="16" height="16" viewBox="0 0 16 16" aria-hidden className="fill-current">
          {playing ? <path d="M4 3h3v10H4zM9 3h3v10H9z" /> : <path d="M5.2 2.8v10.4L13.4 8z" />}
        </svg>
      </Button>
    </div>
  );
}

function Cover({ tone, shape, flat = false }: { tone: string; shape: number; flat?: boolean }) {
  return (
    <div className={`${tone} flex aspect-square w-full items-center justify-center ${flat ? "" : "image-ring overflow-hidden rounded-control"}`}>
      <svg viewBox="0 0 40 40" className="h-3/5 w-3/5" aria-hidden>
        {shape === 0 && <circle cx="20" cy="20" r="14" />}
        {shape === 1 && <rect x="7" y="7" width="26" height="26" rx="4" />}
        {shape === 2 && <path d="M20 5 36 34H4Z" />}
        {shape === 3 && (
          <>
            <circle cx="13" cy="20" r="9" />
            <circle cx="27" cy="20" r="9" opacity=".6" />
          </>
        )}
      </svg>
    </div>
  );
}
```
