Grid Reveal React component for Tailwind CSS v4
v1.0.1Updated in 1.2.1
A React AI image loading placeholder: a canvas grid that splits while the image generates, then resolves into the real picture.
Press Generate and the frame opens as four cells, then keeps splitting the biggest one in two while the image is on its way. When the picture lands the cells take on its colors, busy parts of the image split first, the gutters close up and the photo fades in. A frosted status pill sits in the bottom left with a slow shimmer, crossfading between lines as the caption changes, and fades out once the reveal is done. Honors prefers-reduced-motion by holding a still frame.
Grid Reveal is a free React component in the React AI components category, written in TypeScript for React 19 and Tailwind CSS v4. It installs as source with npx wingo-ui@latest add grid-reveal, together with UIProvider and the npm package motion.
Add to a project
Requirements: React 19 and Tailwind CSS v4, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup
npx wingo-ui@latest add grid-revealUsage
Import GridReveal from @/components/ui/grid-reveal.
"use client"
import { useState } from "react"
import GridReveal from "@/components/ui/grid-reveal"
export function Demo() {
const [src, setSrc] = useState<string | null>(null)
async function generate() {
setSrc(null) // null is the waiting state, the grid runs while it is empty
setSrc(await createImage()) // setting it resolves the grid into the picture
}
return (
// the frame fills its parent, so give the parent a width
<div className="w-64">
<GridReveal src={src} alt="Generated image" caption="Creating image" />
<button onClick={generate}>Generate</button>
</div>
)
}
// Passing a src that is already loaded skips the wait, so the run flashes by.
// Pass progress when your API reports it: <GridReveal src={src} progress={job.progress} />Props
aspectdefault1numberWidth divided by height of the frame. The frame fills its parent's width, so constrain the parent to size it.
captiondefault""stringOptional status text, shown as a frosted pill in the bottom left of the frame and lit by a slow shimmer. Change it mid-run and the lines crossfade while the pill resizes to suit. Empty renders no pill.
altdefault""stringDescribes the finished image for screen readers. The frame is hidden from assistive tech when it is empty.
estimatedDurationdefault6000numberRoughly how long the work takes in milliseconds, used to pace the grid when no progress is passed. Overrunning it is fine, the grid keeps creeping instead of stopping.
cellsdefault180numberHow many cells the grid ends on before the photo fades in, from 8 to 400. Fewer cells read as big bold blocks, more as a fine mosaic. A new count shows on the next reveal.
radiusdefault16numberCorner radius of the frame in pixels, drawn as a squircle where the browser supports corner-shape.
captionPositiondefault"bottom-left""bottom-left" | "bottom-right" | "top-left" | "top-right"The corner the caption pill sits in, 12px from the edges.
captionColordefault"rgba(0, 0, 0, 0.45)"stringAny CSS color for the caption pill, drawn over a blur.
shimmerdefaulttruebooleanSweeps a highlight across the caption text while the image is on its way. Off (and under reduced motion) the text is plain white at 75%.
srcdefault""string | nullImage to reveal. Keep it null while the image is generating, since the grid only runs while this is empty and a src that is already loaded makes the whole run flash by. Cross-origin images need CORS headers for the color pass; without them the grid stays grey and the photo still fades in. In the playground an image URL replaces the sample when the wait is over.
progressdefault0numberPosition of the wait from 0 to 1, driving how far the grid has split. It holds at 0.72 until the image decodes, and the image landing is what finishes the reveal. Leave it out to pace by estimatedDuration.
onRevealComplete() => voidFires once the image has fully resolved.
onError() => voidFires when the image fails to load. Without it a broken src leaves the grid waiting, so use it to show your own fallback.
classNamestringExtra classes merged onto the root element (data-slot="grid-reveal"). Other div props are spread onto it too.
styleReact.CSSPropertiesInline styles merged after the aspect ratio, so an aspectRatio here overrides the aspect prop.
Examples
Driven by your API's progress
Pass progress (0 to 1) when your job reports it and the grid splits in step with it instead of pacing itself by estimatedDuration. Setting src is what completes the reveal.
A batch of four
Four generations in a grid, each finishing at its own time. Fewer cells (64) and a smaller radius read better at thumbnail size.
Wide header with a corner caption
A 16:9 frame with a fine 300-cell mosaic, a 24px radius and the caption pill in the top right corner.
Inside a chat reply
The assistant's message holds the frame while the image renders, then swaps its text once the picture lands.
Files
- components/ui/grid-reveal.tsx
FAQ
Is the React Grid Reveal component free?
Yes. The source is free and needs no account: copy it from the Code tab or install it with the CLI.
How do I install Grid Reveal?
Run npx wingo-ui@latest add grid-reveal. It also adds the Wingo UI item it builds on (UIProvider) and the npm package motion. With shadcn, run npx shadcn@latest add https://wingo-ui.com/r/grid-reveal.json.