Installation
Usage
import { ImageTransition } from "@/components/image-transition"
const places = [
{ src: "/photos/dunes.jpg", alt: "Sand dunes at dusk", title: "Wadi Rum", caption: "Jordan" },
{ src: "/photos/fjord.jpg", alt: "Red cabins on a fjord", title: "Lofoten", caption: "Norway" },
{ src: "/photos/city.jpg", alt: "Office towers at night", title: "Shinjuku", caption: "Tokyo" },
]
export function Gallery() {
return <ImageTransition images={places} effect="liquid" autoplay aria-label="Places" className="rounded-2xl" />
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| images | TransitionImage[] | — | Each picture: src, alt, and an optional title and caption. Same origin, or served with CORS. |
| effect | "liquid" | "ripple" | "tiles" | "prism" | "liquid" | How one picture turns into the next. |
| index | number | — | The picture shown, when you control it. Pair with onIndexChange. |
| defaultIndex | number | 0 | The first picture, when the component keeps its own place. |
| onIndexChange | (index: number) => void | — | Called with the new picture's index. |
| duration | number | 1400 | Length of one change, 600–3000 ms. |
| autoplay | boolean | false | Moves on by itself; waits while hovered, focused or off-screen, has a pause button, and stays still with reduced motion. |
| interval | number | 5000 | Time between pictures when autoplaying, in ms. |
| controls | boolean | true | Previous, next, pause and a dot per picture. |
| captions | boolean | true | Each picture's title and caption over its lower corner. |
| glow | string | "var(--primary)" | Colour of the light along the edge of a change. Any CSS colour. |
| progress | number | — | Holds a change from the current picture to the next at this point, 0–1. |
| ...props | HTMLAttributes<HTMLDivElement> | — | Children sit above the pictures and stay interactive; aria-label names the set. |
Accessibility
- The pictures are real img elements, so the one shown is announced with its alt text and the first paints before any script; the canvas is decorative and hidden from assistive technology.
- It is a labelled carousel region: arrow keys, Home and End move it, and every dot is a button that names its picture and reports the current one.
- Changes made by you are announced politely; while it plays by itself the announcements stay off, and autoplay has a pause button and waits while the pointer or focus is inside.
- With prefers-reduced-motion a change is a short fade and nothing plays by itself.
- Without WebGL2, on a software renderer, on a device that can't keep up, or for pictures served without CORS, pictures cross-fade instead.
Changelog
- v1.0.0Latest
First release.

