本文へ移動
日本語
「画像リビール」は Pro に含まれます。解除するとプレビューが表示されます。

仕組み

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.

向いている場面

  • 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.

向かない場面

  • 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.

使い方

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>
    </>
  )
}

プロパティ

プロパティ型既定値説明
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>.

アクセシビリティ

  • 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.

モーション

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.

プロジェクトに追加

Pro メンバーはプロンプトをコピーし、コーディングエージェントが無料コンポーネントと同じ手順でソースを導入します。

ImageReveal.jsximage-reveal.csstokens.cssREADME.md

2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。

読み込み
「オービットローダー」は Pro に含まれます。解除するとプレビューが表示されます。
「パーティクルオーブ」は Pro に含まれます。解除するとプレビューが表示されます。