Skip to content
Browse documentation

A generated image comes up like a print in the tray: a soft field of its colours, then pools of focus opening through it.

Used forStreaming generatorsPhoto editorsUpscalers and restorersAI headshots

Install with the shadcn CLI

$ npx shadcn@latest add https://hairlineui.com/r/film-develop.json

Registered the namespace? Then it’s shadcn add @hairline/film-develop. Set it up

Templates

Need the whole page?

61 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 6 are free.

All 61 templates

Where it’s used

  • Streaming generators

    Show the model’s preview frames, deep in blur, as progress rises.

  • Photo editors

    A filter or a relight developing over the photo.

  • Upscalers and restorers

    The restored photo developing out of the old one.

  • AI headshots

    Portraits arriving one by one in a studio app.

What it handles for you

Previews from diffusion models are noisy and half-formed; shown raw they look broken, and hidden they leave people staring at a spinner.

Instead of wiring upprogressive jpegblur-up placeholderloading spinnerfake progress bar
  1. Uses your preview

    A streamed preview stays deep in blur and clears with your progress, so people see it coming without the noise.

  2. Develops, never pops

    The final image comes up through soft colour and then pools of focus, middle first.

  3. Organic front

    Focus spreads through noise, so there are no bars or lines crossing the picture.

  4. Any image host

    It only draws the image, never reads it, so it needs no CORS.

  5. Honest progress

    A rolling percentage when your API reports one, and the preview’s blur follows it.

  6. Failure designed

    A failed generation says so with Try again.

Overview

For image APIs that tell you how far along they are. While your generation runs, the frame is a developing tray: soft colour drifting in it, or, if your API streams a low-resolution preview, that preview held deep in blur and clearing a little as your progress rises. When the final image has loaded it develops like a print: a soft field of its own colours first, then pools of focus open through it on an organic front, the middle first, until the whole picture is sharp, in 1.7s. It needs no CORS, so it works with any image host.

States

waiting
Without a preview, two soft colour fields drift in the tray over 5.5s. With one, the preview sits scaled 110% under blur(22px), easing to blur(10px) as progress reaches 1.
developing
Once the final image has decoded: a soft field of its own colours (a 14-pixel copy scaled up), a finer field fading in from 12%, and the sharp print through a noise mask whose pools open from the middle over 1.7s.
shown
The plain image. onReady fires.
failed
The tray with “This image couldn’t be created.” and Try again when onRetry is passed.

Usage

usage.tsx
import { FilmDevelop } from "@/components/film-develop";<FilmDevelop  src={image?.url}  status={job.status}  preview={job.previewUrl}  progress={job.progress}  alt={prompt}  onRetry={regenerate}  className="aspect-square w-80"/>

Works with

Polling your generation API

Start a generation, poll its status, and hand the component the real state. Any API that reports generating, ready and failed works the same way.

example.tsx
"use client";import * as React from "react";import { FilmDevelop } from "@/components/film-develop";type Job = { id: string; status: "generating" | "ready" | "error"; url?: string; progress?: number };export function Generation({ prompt }: { prompt: string }) {  const [job, setJob] = React.useState<Job | null>(null);  async function generate() {    const { id } = await fetch("/api/generate", { method: "POST", body: JSON.stringify({ prompt }) }).then((r) => r.json());    setJob({ id, status: "generating" });    const poll = window.setInterval(async () => {      const next: Job = await fetch(`/api/generate/${id}`).then((r) => r.json());      setJob(next);      if (next.status !== "generating") window.clearInterval(poll);    }, 1000);  }  return (    <div className="grid gap-3">      <FilmDevelop        src={job?.url}        status={job?.status ?? "generating"}        progress={job?.progress}        alt={prompt}        onRetry={generate}        className="aspect-square w-80"      />      <button onClick={generate}>Generate</button>    </div>  );}

Props

src
string
The generated image. It can arrive before or with status "ready"; the reveal waits until it has loaded and decoded.
status
"generating" | "ready" | "error"
Your generation’s real state. Nothing plays on a timer.
progress
number
0 to 1, if your API reports it. Shown as a small rolling figure; without it, no number is shown.
alt
string
The image’s text alternative, usually its prompt.
crossOrigin
"anonymous" | "use-credentials"
Set it when your image host sends CORS headers.
onReady
() => void
Called once the reveal has played, or the image is shown without one.
onRetry
() => void
Shows Try again when the generation fails.
labels
{ generating?, ready?, failed?, retry? }
Words for the progress tag, the announcements and the failure.
className
string
Size the frame here, e.g. "aspect-square w-72".
preview
string
A low-resolution preview your API streams while it works. Shown deep in blur, clearing with progress.

Accessibility and motion

  • It follows your status: it waits while "generating", and plays only once status is "ready" and the image has loaded and decoded (img.decode), so it can never finish before the picture does. An image that was already there when the page loaded is simply shown.
  • The figure has aria-busy while it waits, and a status line announces Generating, Image ready or the failure; the image keeps its alt text.
  • Each frame draws the soft field, the finer field and the masked print on one canvas; the focus mask is 64 × 80 and scaled up smoothly, so its edges stay soft.
  • Under reduced motion the image appears in place, with no drift while waiting.

Requirements

React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

The CLI also installs Number roll.

Source

"use client";/* ───────────────────────────────────────────────────────── * FILM DEVELOP: the image comes up like a print in the tray * * While your generation runs, the well is a developing tray: * soft colour drifting in it, or, if your API streams a low- * resolution preview, that preview held deep in blur and * clearing as your progress rises. When the final image has * loaded, it develops: a soft field of its own colours, then * pools of focus open through it on an organic front until the * whole print is sharp. Works with any image host, no CORS. * ───────────────────────────────────────────────────────── */import * as React from "react";import { clamp01, drawFitted, noise2 } from "./image-grains";import { Announce, ErrorFace, ProgressTag, frameClass, useArrival, useReducedMotion, type RevealProps } from "./image-arrival";export type { GenerationStatus, RevealLabels } from "./image-arrival";export interface FilmDevelopProps extends RevealProps {  /** A low-resolution preview your API streams while it works (a data URL or a URL). Shown deep in blur, clearing with progress. */  preview?: string;}const DEVELOP = 1700;const COLS = 64;const ROWS = 80;/** How developed a point is at time p: an organic front, the middle first, with a soft edge. */function clarity(nx: number, ny: number, n: number, p: number) {  if (p <= 0) return 0;  if (p >= 1) return 1;  const dist = Math.min(1, Math.hypot(nx - 0.5, ny - 0.46) * 1.38);  const threshold = Math.min(0.78, Math.max(0.04, dist * 0.34 + n * 0.46));  const raw = clamp01((p - (threshold - 0.077)) / 0.22);  return raw * raw * (3 - 2 * raw);}const TRAY =  "radial-gradient(45% 40% at 35% 40%, color-mix(in oklab, var(--chart-3) 34%, transparent), transparent 70%), radial-gradient(40% 45% at 68% 62%, color-mix(in oklab, var(--chart-1) 30%, transparent), transparent 70%)";export function FilmDevelop({ src, preview, status, progress, alt, crossOrigin, onReady, onRetry, labels, className }: FilmDevelopProps) {  const reduced = useReducedMotion();  const { phase, onLoad, onError, imageRef, finish } = useArrival(src, status, onReady);  const figure = React.useRef<HTMLElement>(null);  const image = React.useRef<HTMLImageElement>(null);  const canvas = React.useRef<HTMLCanvasElement>(null);  const revealing = phase === "revealing";  React.useEffect(() => {    if (!revealing) return;    const el = canvas.current;    const box = figure.current;    const img = image.current;    if (reduced || !el || !box || !img) {      const id = window.setTimeout(finish, 0);      return () => window.clearTimeout(id);    }    const dpr = Math.min(window.devicePixelRatio || 1, 2);    const w = box.clientWidth;    const h = box.clientHeight;    const W = Math.round(w * dpr);    const H = Math.round(h * dpr);    el.width = W;    el.height = H;    const ctx = el.getContext("2d");    if (!ctx) return;    const fit = getComputedStyle(img).objectFit || "cover";    const at = (cw: number, ch: number) => {      const c = document.createElement("canvas");      c.width = cw;      c.height = ch;      const cx = c.getContext("2d");      if (cx) drawFitted(cx, img, img.naturalWidth, img.naturalHeight, 0, 0, cw, ch, fit);      return c;    };    // A soft field of the image's own colours (upscaling a tiny copy blurs it for free), a finer one, and the sharp print.    const soft = at(14, Math.max(4, Math.round((14 * h) / w)));    const finer = at(44, Math.max(8, Math.round((44 * h) / w)));    const sharp = at(W, H);    const field = new Float32Array(COLS * ROWS);    for (let y = 0; y < ROWS; y++)      for (let x = 0; x < COLS; x++) field[y * COLS + x] = noise2((x / COLS) * 3.2 + 7.1, (y / ROWS) * 4 + 3.3) * 0.68 + noise2((x / COLS) * 8.4 + 11.3, (y / ROWS) * 10.2 + 5.7) * 0.32;    const mask = document.createElement("canvas");    mask.width = COLS;    mask.height = ROWS;    const mctx = mask.getContext("2d");    const maskData = new ImageData(COLS, ROWS);    const out = document.createElement("canvas");    out.width = W;    out.height = H;    const octx = out.getContext("2d");    if (!mctx || !octx) return;    let frame = 0;    const start = performance.now();    const step = (now: number) => {      const p = clamp01((now - start) / DEVELOP);      ctx.imageSmoothingEnabled = true;      ctx.imageSmoothingQuality = "high";      ctx.globalAlpha = 1;      ctx.drawImage(soft, 0, 0, W, H);      if (p > 0.12) {        ctx.globalAlpha = clamp01((p - 0.12) / 0.4);        ctx.drawImage(finer, 0, 0, W, H);        ctx.globalAlpha = 1;      }      const d = maskData.data;      for (let y = 0; y < ROWS; y++)        for (let x = 0; x < COLS; x++) {          const i = y * COLS + x;          d[i * 4] = d[i * 4 + 1] = d[i * 4 + 2] = 255;          d[i * 4 + 3] = Math.round(clarity(x / (COLS - 1), y / (ROWS - 1), field[i], p) * 255);        }      mctx.putImageData(maskData, 0, 0);      octx.globalCompositeOperation = "copy";      octx.drawImage(sharp, 0, 0);      octx.globalCompositeOperation = "destination-in";      octx.imageSmoothingEnabled = true;      octx.drawImage(mask, 0, 0, W, H);      ctx.drawImage(out, 0, 0);      if (p < 1) frame = requestAnimationFrame(step);      else finish();    };    frame = requestAnimationFrame(step);    return () => cancelAnimationFrame(frame);  }, [revealing, reduced, finish]);  const waiting = phase === "waiting";  const blur = 22 - 12 * clamp01(progress ?? 0);  return (    <figure ref={figure} className={frameClass(className)} aria-busy={waiting}>      {waiting && !preview && (        <div aria-hidden="true" className="pointer-events-none absolute -inset-[12%]" style={{ background: TRAY, animation: reduced ? "none" : "ui-develop-drift 5.5s ease-in-out infinite alternate" }} />      )}      {waiting && preview && (        // eslint-disable-next-line @next/next/no-img-element        <img          src={preview}          alt=""          aria-hidden="true"          className="pointer-events-none absolute inset-0 size-full scale-110 object-cover"          style={{ filter: `blur(${blur}px) saturate(0.85)`, transition: "filter 600ms ease-out" }}        />      )}      {src && (        // eslint-disable-next-line @next/next/no-img-element        <img          ref={(el) => {            image.current = el;            imageRef(el);          }}          key={src}          src={src}          alt={alt}          crossOrigin={crossOrigin}          onLoad={onLoad}          onError={onError}          draggable={false}          className="absolute inset-0 size-full object-cover"          style={{ opacity: phase === "shown" ? 1 : 0 }}        />      )}      {revealing && <canvas ref={canvas} aria-hidden="true" className="pointer-events-none absolute inset-0 size-full" />}      {waiting && <ProgressTag progress={progress} label={labels?.generating ?? "Developing"} />}      {phase === "error" && <ErrorFace labels={labels} onRetry={onRetry} />}      <Announce phase={phase} labels={labels} />    </figure>  );}

Registry item: /r/film-develop.json