Image Generation Loader

An image model's frame: queued, cells clearing with a scan line, then the reveal.

PROGet Image Generation Loader and 168 other Pro components with pro lifetime — Get Pro

Category
AI Chat
Access
Pro
Source
208 lines · one file
States
5 drawn

The decision inside it

Three signals that agree

The share of cells cleared, the scan line's height and the number in the corner all show the same progress. Each cell clears at a fixed point in a shuffle, so the reveal looks random but never flickers between renders.

When to use it

Use Image Generation Loader while a model makes an image: queued, generating with progress, then the picture, or an error with retry. It holds the final aspect ratio so nothing jumps when the image lands.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Image Generation Loader for this.
Install it: npx shadcn@latest add @liro/image-generation-loader
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/image-generation-loader.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/generated-cover.tsx
import { ImageGenerationLoader } from "@/components/ui/image-generation-loader";

export function GeneratedCover({ status, progress, url, retry }: { status: "queued" | "generating" | "done" | "error"; progress: number; url?: string; retry: () => void }) {
  return (
    <ImageGenerationLoader
      status={status}
      progress={progress}
      src={url}
      alt="Cover image for the Q3 proposal"
      aspectRatio={16 / 9}
      onRetry={retry}
    />
  );
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
status"queued" | "generating" | "done" | "error" YesWhere the job is.
progressnumber No0–100 while generating.
srcstring NoThe final image when done; a preview to show through the cells while generating.
altstring NoThe image's alt text when done. Default "Generated image".
aspectRationumber NoWidth over height. Default 1.
labelstring NoThe words under the progress, e.g. "Generating…". Defaults by status.
gridSizenumber NoThe size of one cell in pixels. Default 28.
errorMessagestring NoThe error's words. Default "The image could not be generated."
onRetry() => void NoShows Retry in the error state.

Dependencies

npm packages

clsxframer-motionlucide-reacttailwind-merge

Liro foundations, installed alongside it

liro-theme

States

All of them are drawn by the component. None is left for you to design.

  • Queued
  • Generating
  • Preview showing through
  • Done
  • Error

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances