Skip to content
Sign in
EffectsMosaic shuffleMenu

Mosaic shufflePro

The image starts as a shuffled mosaic and every tile slides home, for reroll and remix moments.

ProReroll: the next variation loads first, then arrives shuffled and slides home.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/mosaic-shuffle

Usage

tsx
import { MosaicShuffle } from "@/components/ui/chatcn/pro/mosaic-shuffle"

<MosaicShuffle key={variation.id} src={variation.url} alt={variation.prompt} seed={rollCount} />

No tile starts in its own slot, so the whole picture visibly moves. Tiles are plain elements moved with transforms; a hairline gap closes as each one lands, and the real image takes over once all are home. Load the next variation before you swap src so the shuffle starts at once.

Examples

States

Waiting for the image, running at 40%, running with no numbers, held by revealed={false}, revealed, a missing file, a timer and right to left.

ProEvery state of the mosaic shuffle.

Props

PropTypeNotes
src, altstringalt is required: the accessible name, announced once the image is in
progressnumber | nullReal job progress, 0 to 1. null means running with no numbers. Leave it out for timer mode
revealedbooleanTimer mode: false holds the first frame, true plays once the image loads. Default true
durationnumberTimer length in ms. Default 1600
onRevealed() => voidOnce per image, when the plain image shows
onStatusChange(status: "loading" | "ready" | "revealing" | "revealed" | "error") => void
aspectRatio, width, heightSet the frame before the image loads, so nothing shifts
paperstringThe ground under the effect. Token or CSS color. Default var(--chatcn-bg)
announcementstring | falseWhat the live region says once revealed. Default Image ready: <alt>
errorText, retryLabelCopy for the error state and its reload button
columnsnumberTiles across. Default 4
rowsnumberTiles down. Defaults to the count that keeps tiles closest to square
order"random" | "bayer" | "rows" | "diagonal" | "center"Which tiles move first. Default diagonal
seednumberSeeds the shuffle; change it per reroll. Default 1

Keyboard

KeyAction
TabReaches the Reload image button in the error state. The reveal itself takes no focus

Accessibility

  • The effect layer is aria-hidden. The real <img> with your alt is always there, and the frame is aria-busy until the reveal ends.
  • A polite live region says Image ready: <alt> once, when the plain image shows. Progress ticks are never announced.
  • Under forced-colors: active the effect hides and the plain image shows with system colors.
  • A broken file shows what happened and a Reload image button that retries the download.

Motion

  • Each tile slides over half the run on the kit out curve, starts staggered over the other half. transform and clip-path only, no bounce.
  • Under reduced motion one still frame holds while the job runs, then the image crossfades in over 200 ms. Nothing moves.
  • The timer only runs on screen in a visible tab; offscreen it waits where it was.