Ir al contenido
Español
Revelado de imagen viene con Pro. La vista previa aparece al desbloquearlo.

Cómo funciona

A frame with a fixed aspect ratio holds the content, and over it a CSS grid of rounded tiles in a soft ink tint. While waiting, every tile's highlight runs the same keyframe with a delay of (column + row) × 90ms, so the light rolls across the grid as a diagonal wave; the delays are negative, so the wave is already moving on the first frame. On reveal each tile shrinks to half and fades after a delay proportional to its distance from the centre, while the content underneath fades in from a 14px blur and a 1.08 zoom, glimpsed first through the gaps. A centred caption shows the label and the percent and leaves as the tiles start to go.

Úsalo para

  • AI image generation, where the wait is several seconds and a progress figure is available.
  • Large photos or covers loading into a fixed slot: cards, galleries, hero areas.
  • Replacing an image (regenerate, next variant) where the change should feel deliberate.

Busca otra opción cuando

  • Small thumbnails and avatars that load in a moment: a plain tint is quieter.
  • Long lists of images: dozens of shimmering grids at once are noisy; use a simple skeleton.

Uso

import { useState } from 'react'
import { ImageReveal } from './ImageReveal.jsx'

export function Cover({ prompt }) {
  const [url, setUrl] = useState(null)
  const [progress, setProgress] = useState(0)

  const generate = async () => {
    setUrl(null)
    const result = await createImage(prompt, { onProgress: setProgress })
    setUrl(result.url)
  }

  return (
    <>
      <ImageReveal
        ready={Boolean(url)}
        src={url ?? undefined}
        alt={prompt}
        progress={progress}
        ratio={16 / 10}
      />
      <button onClick={generate}>Regenerate</button>
    </>
  )
}

Propiedades

PropiedadTipoPor defectoQué hace
readybooleanfalseControlled. true starts the reveal (with src, once the image has loaded); false brings the tiles back, corners first.
src / altstring / string—An image to reveal. The reveal waits for its load event (or error), so a slow download never shows half an image.
childrenReactNode—Any content to reveal instead of src: an inline SVG, a canvas, a video poster. It fills the frame; give it its own accessible name.
rationumber16 / 10Width ÷ height of the frame. It never changes size, so nothing around it moves.
cols / rowsnumber / number8 / cols ÷ ratioTiles across and down; rows follow the ratio unless given, so the tiles stay close to square.
radius / gapnumber / number8 / 4Corner radius of each tile and the space between tiles, in px.
progressnumber (0–1)—Optional. Shows a percent in the caption and makes the caption a progressbar for assistive tech.
onRevealed() => void—Called when the last tile is gone (after about 1.1 s, or 0.2 s with reduced motion).
labelsobject—Replaces built-in text: loading (the caption) and ready (announced once revealed). Shallow-merged over the English defaults.
...restHTMLAttributes—Other attributes go to the root <div>.

Accesibilidad

  • The root carries aria-busy while waiting; a polite status region says “Generating…” and then “Image ready” (both replaceable with labels).
  • With progress, the caption is a progressbar with aria-valuenow; without it the caption is plain text.
  • The content is hidden from assistive tech until it is revealed, then read with its own alt or accessible name.
  • Tiles and the shimmer are decorative and hidden.
  • Reduced motion: still tiles, no wave, and the reveal is a 200ms cross-fade without blur, zoom or stagger.

Movimiento

Wave: 1800ms ease-in-out loop, 90ms per diagonal step. Reveal: 560ms of stagger from centre to corners, each tile 520ms (scale to 0.5 on --ds-ease-out, fade linear); content opacity 420ms, blur 900ms and zoom 1100ms on --ds-ease-out. Back to loading: tiles return corners first over about 280ms each.

Añádelo a tu proyecto

Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.

ImageReveal.jsximage-reveal.csstokens.cssREADME.md

Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

Carga
Cargador orbital viene con Pro. La vista previa aparece al desbloquearlo.
Orbe de partículas viene con Pro. La vista previa aparece al desbloquearlo.