Skip to content
Browse documentation

A generated image seen through reeded glass: each reed bends its slice, then the glass clears from the centre outward.

Used forPremium generatorsInterior and architectureProduct shotsCovers and posters

Install with the shadcn CLI

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

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

  • Premium generators

    Image apps with a crafted, physical look.

  • Interior and architecture

    Renders arriving behind glass, the way they’re shown in studios.

  • Product shots

    Generated packshots and lifestyle photos.

  • Covers and posters

    Generated artwork landing in a card.

What it handles for you

Loading states are usually generic grey; nothing about them belongs to the product.

Instead of wiring uploading spinnerskeleton loaderglass effect cssfade-in image
  1. A real material

    Every reed shifts and squeezes its own slice of the image, and its edges catch light, so it reads as glass, not a filter.

  2. Clears from the centre

    The middle reeds relax first and the outer ones last, with one glint sweeping across.

  3. Follows the real state

    It waits on your status and on the image decoding.

  4. Sharp hand-over

    The glass is drawn at device resolution, so the real image takes over without a jump in sharpness.

  5. Any image host

    It only draws the image, so it needs no CORS, and it avoids canvas filters Safari lacks.

  6. Failure designed

    A failed generation says so with Try again.

Overview

A reveal with a material. While your generation runs, the frame is a pane of reeded glass with colour behind it and a glint crossing the reeds now and then. When the image has loaded you see it through the glass: every reed shifts and softens its own slice, as a cylinder lens does, and then the reeds relax from the centre outward while the glint sweeps once, until the picture is sharp, in 1.5s. It suits products with a crafted, premium feel. It needs no CORS.

States

waiting
Reeded glass (14 reeds by default) over two soft colour fields, with a glint crossing every 3.2s.
clearing
Once the image has decoded: each reed shows its slice shifted up to 16px and squeezed by a third, frosted and shaded at its edges; the reeds relax from the centre outward over 1.5s while the glint sweeps once.
shown
The plain image. onReady fires.
failed
The pane with “This image couldn’t be created.” and Try again when onRetry is passed.

Usage

usage.tsx
import { ReededReveal } from "@/components/reeded-reveal";<ReededReveal  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 { ReededReveal } from "@/components/reeded-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">      <ReededReveal        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".
reeds= 14
number
How many reeds across the glass (4 to 40).

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 frosting is a tenth-size copy scaled back up, not a canvas filter, so it looks the same in Safari.
  • 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";/* ───────────────────────────────────────────────────────── * REEDED REVEAL: the image behind reeded glass * * While your generation runs, the well is a pane of reeded * glass with colour behind it and a glint that crosses the * reeds. When the image has loaded, you see it through the * glass: each reed bends its own slice and softens it, then the * reeds relax from the centre outward, the glint sweeping once, * until the picture is sharp. Works with any image host. * ───────────────────────────────────────────────────────── */import * as React from "react";import { clamp01, drawFitted } from "./image-grains";import { Announce, ErrorFace, ProgressTag, frameClass, useArrival, useReducedMotion, type RevealProps } from "./image-arrival";export type { GenerationStatus, RevealLabels } from "./image-arrival";export interface ReededRevealProps extends RevealProps {  /** How many reeds across the glass. */  reeds?: number;}const CLEAR = 1500;/** How strongly reed i (of n) still refracts at time p: all of them at first, then clearing from the centre out. */function refraction(i: number, n: number, p: number) {  if (p >= 1) return 0;  const centre = (n - 1) / 2;  const fromCentre = Math.abs(i - centre) / Math.max(1, centre);  const local = clamp01((p - (0.18 + fromCentre * 0.36)) / 0.4);  return Math.pow(1 - local, 2.4);}const BEHIND =  "radial-gradient(50% 55% at 30% 45%, color-mix(in oklab, var(--chart-2) 38%, transparent), transparent 72%), radial-gradient(45% 50% at 72% 58%, color-mix(in oklab, var(--chart-4) 34%, transparent), transparent 72%)";const reedsOf = (n: number) =>  `repeating-linear-gradient(90deg, color-mix(in oklab, var(--background) 34%, transparent) 0, transparent calc(100% / ${n} * 0.18), transparent calc(100% / ${n} * 0.62), color-mix(in oklab, var(--foreground) 10%, transparent) calc(100% / ${n}))`;export function ReededReveal({ src, status, progress, alt, crossOrigin, onReady, onRetry, labels, className, reeds = 14 }: ReededRevealProps) {  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";  const n = Math.max(4, Math.min(40, Math.round(reeds)));  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;    el.width = Math.round(w * dpr);    el.height = Math.round(h * dpr);    const ctx = el.getContext("2d");    if (!ctx) return;    const fit = getComputedStyle(img).objectFit || "cover";    // Both copies at device resolution, so the hand-over to the real image never sharpens with a jump.    const W = el.width;    const H = el.height;    const sharp = document.createElement("canvas");    sharp.width = W;    sharp.height = H;    const sctx = sharp.getContext("2d");    if (sctx) drawFitted(sctx, img, img.naturalWidth, img.naturalHeight, 0, 0, W, H, fit);    // Frosted: a tenth-size copy scaled back up is soft without a canvas filter (which Safari lacks).    const tiny = document.createElement("canvas");    tiny.width = Math.max(4, Math.round(w / 10));    tiny.height = Math.max(4, Math.round(h / 10));    tiny.getContext("2d")?.drawImage(sharp, 0, 0, tiny.width, tiny.height);    const frost = document.createElement("canvas");    frost.width = W;    frost.height = H;    const fctx = frost.getContext("2d");    if (fctx) {      fctx.imageSmoothingQuality = "high";      fctx.drawImage(tiny, -8 * dpr, -8 * dpr, W + 16 * dpr, H + 16 * dpr);    }    const reedW = w / n;    let frame = 0;    const start = performance.now();    const step = (now: number) => {      const p = clamp01((now - start) / CLEAR);      ctx.setTransform(dpr, 0, 0, dpr, 0, 0);      ctx.drawImage(sharp, 0, 0, w, h);      const glint = -0.25 + p * 1.6;      for (let i = 0; i < n; i++) {        const r = refraction(i, n, p);        if (r <= 0.005) continue;        const x = i * reedW;        const rw = i === n - 1 ? w - x : reedW + 0.5;        // Each reed shows its slice shifted and squeezed, as a cylinder lens would.        const shift = ((i % 2 ? -1 : 1) * 11 + Math.sin(p * 6.9 + i * 0.62) * 5) * r;        const sx = Math.max(0, Math.min(w - rw, x + shift));        const sw = Math.max(4, rw * (1 - 0.34 * r));        ctx.globalAlpha = Math.min(1, r * 1.15);        ctx.drawImage(frost, sx * dpr, 0, sw * dpr, H, x, 0, rw, h);        const lit = Math.max(0, 1 - Math.abs(i / (n - 1) - glint) * 3.6);        const g = ctx.createLinearGradient(x, 0, x + rw, 0);        g.addColorStop(0, `rgba(255,255,255,${(r * (0.26 + lit * 0.3)).toFixed(3)})`);        g.addColorStop(0.16, `rgba(255,255,255,${(r * (0.08 + lit * 0.12)).toFixed(3)})`);        g.addColorStop(0.52, "rgba(255,255,255,0)");        g.addColorStop(1, `rgba(0,0,0,${(r * 0.36).toFixed(3)})`);        ctx.globalAlpha = 1;        ctx.fillStyle = g;        ctx.fillRect(x, 0, rw, h);      }      ctx.globalAlpha = 1;      if (p < 1) frame = requestAnimationFrame(step);      else finish();    };    frame = requestAnimationFrame(step);    return () => cancelAnimationFrame(frame);  }, [revealing, reduced, finish, n]);  const waiting = phase === "waiting";  return (    <figure ref={figure} className={frameClass(className)} aria-busy={waiting}>      {waiting && (        <div aria-hidden="true" className="pointer-events-none absolute inset-0 overflow-clip">          <div className="absolute inset-0" style={{ background: BEHIND }} />          <div className="absolute inset-0" style={{ background: reedsOf(n) }} />          <div            className="absolute inset-y-0 left-0 w-1/3"            style={{              background: "linear-gradient(90deg, transparent, color-mix(in oklab, var(--background) 40%, transparent), transparent)",              animation: reduced ? "none" : "ui-reed-glint 3.2s cubic-bezier(0.45,0,0.25,1) infinite",              opacity: reduced ? 0 : 1,            }}          />        </div>      )}      {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 ?? "Generating"} />}      {phase === "error" && <ErrorFace labels={labels} onRetry={onRetry} />}      <Announce phase={phase} labels={labels} />    </figure>  );}

Registry item: /r/reeded-reveal.json