Skip to content
Browse documentation

The calm wait for a generated image: a slow band of colour drifts while it works, then the mist moves off and the picture sharpens into place.

Used forImage generatorsChat with imagesAvatars and coversProduct photos

Install with the shadcn CLI

$ npx shadcn@latest add https://hairlineui.com/r/mist-reveal.json

Registered the namespace? Then it’s shadcn add @hairline/mist-reveal. 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

  • Image generators

    The frame a prompt’s result appears in.

  • Chat with images

    An image a model is drawing inside a reply.

  • Avatars and covers

    A generated profile picture or cover photo arriving.

  • Product photos

    A background removal or a restyle being processed.

What it handles for you

Most image products show a spinner or a skeleton, then swap the image in with a hard cut, and many fake a progress bar that finishes before the image does.

Instead of wiring uploading spinnerskeleton loaderfake progress barblur-up placeholder
  1. Follows the real state

    It waits on your status and on the image actually decoding, so it never finishes early or shows a half-loaded picture.

  2. Calm while it works

    A slow band of your chart colours drifts at a pace you can ignore; nothing spins or pulses.

  3. One move to arrive

    The mist leaves for a corner as the picture sharpens out of a blur, in one 1.1s move.

  4. Honest progress

    A rolling percentage only when your API gives one; otherwise no number at all.

  5. Failure designed

    A failed generation says so in the frame with Try again, instead of an empty box.

  6. Already there, already shown

    An image that was ready on page load appears without replaying the reveal.

Overview

Waiting for an image model is the moment a product looks either alive or stuck. While your generation runs, Mist reveal fills the frame with a slow band of your theme’s chart colours drifting through a quiet well, enough to say it is working without a spinner. It never guesses: it waits on your status, and only once the image is ready and has actually loaded does the mist move off towards a corner while the picture sharpens out of a soft blur in the same move. If your API reports progress, a small figure rolls in the corner; if it fails, the frame says so and offers Try again. The calm one of the four, for consumer apps.

States

waiting
A band of --chart-1, --chart-2 and --chart-4, blurred 28px, drifts 16% each way over 4.6s in the muted well. aria-busy is set.
arriving
Once status is "ready" and the image has decoded: the mist fades over 0.9s while moving 32% towards the bottom-right corner, and the image goes from blur(14px) and scale(1.06) to sharp in 1.1s.
shown
The plain image, its alt text intact. onReady fires.
failed
The well with “This image couldn’t be created.” and Try again when onRetry is passed.

Usage

usage.tsx
import { MistReveal } from "@/components/mist-reveal";<MistReveal  src={image?.url}  status={job.status}  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 { MistReveal } from "@/components/mist-reveal";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">      <MistReveal        src={job?.url}        status={job?.status ?? "generating"}        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".

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.
  • The mist is one blurred layer moved by a CSS animation, so it costs no script while it waits.
  • 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";/* ───────────────────────────────────────────────────────── * MIST REVEAL: the calm wait for a generated image * * While your generation runs, a slow band of the theme's chart * colours drifts through a quiet well. When the image is ready * and has really loaded, the mist moves off towards a corner * and the picture sharpens out of a soft blur in the same move. * It follows your status, never a timer. * ───────────────────────────────────────────────────────── */import * as React from "react";import { Announce, ErrorFace, ProgressTag, frameClass, useArrival, useNextFrame, useReducedMotion, type RevealProps } from "./image-arrival";export type { GenerationStatus, RevealLabels } from "./image-arrival";export type MistRevealProps = RevealProps;const EASE = "cubic-bezier(0.16, 1, 0.3, 1)";const REVEAL = 1100;const BAND =  "linear-gradient(115deg, transparent 22%, color-mix(in oklab, var(--chart-1) 60%, transparent) 38%, color-mix(in oklab, var(--chart-2) 55%, transparent) 50%, color-mix(in oklab, var(--chart-4) 55%, transparent) 62%, transparent 78%)";export function MistReveal({ src, status, progress, alt, crossOrigin, onReady, onRetry, labels, className }: MistRevealProps) {  const reduced = useReducedMotion();  const { phase, onLoad, onError, imageRef, finish } = useArrival(src, status, onReady);  const revealing = phase === "revealing";  const go = useNextFrame(revealing && !reduced);  React.useEffect(() => {    if (!revealing) return;    const id = window.setTimeout(finish, reduced ? 0 : REVEAL);    return () => window.clearTimeout(id);  }, [revealing, reduced, finish]);  const showing = phase === "shown" || (revealing && (go || reduced));  const misty = phase === "waiting" || (revealing && !go && !reduced);  return (    <figure className={frameClass(className)} aria-busy={phase === "waiting"}>      {src && (        // eslint-disable-next-line @next/next/no-img-element        <img          ref={imageRef}          key={src}          src={src}          alt={alt}          crossOrigin={crossOrigin}          onLoad={onLoad}          onError={onError}          draggable={false}          className="absolute inset-0 size-full object-cover"          style={{            opacity: showing ? 1 : 0,            filter: showing ? "blur(0px)" : "blur(14px)",            transform: showing ? "scale(1)" : "scale(1.06)",            transition: revealing && !reduced ? `opacity 600ms ease-out, filter ${REVEAL}ms ${EASE}, transform ${REVEAL + 100}ms ${EASE}` : "none",          }}        />      )}      {(phase === "waiting" || revealing) && (        <div          aria-hidden="true"          className="pointer-events-none absolute -inset-[30%]"          style={{            opacity: misty ? 0.75 : 0,            transform: misty ? "translate3d(0,0,0) scale(1)" : "translate3d(32%,28%,0) scale(1.2)",            transition: revealing ? `opacity ${REVEAL - 200}ms ease-out, transform ${REVEAL}ms ${EASE}` : "none",          }}        >          <div className="absolute inset-0" style={{ background: BAND, filter: "blur(28px)", animation: reduced ? "none" : "ui-mist-drift 4.6s ease-in-out infinite alternate" }} />        </div>      )}      {phase === "waiting" && <ProgressTag progress={progress} label={labels?.generating ?? "Generating"} />}      {phase === "error" && <ErrorFace labels={labels} onRetry={onRetry} />}      <Announce phase={phase} labels={labels} />    </figure>  );}

Registry item: /r/mist-reveal.json