Geometric image placeholders for Svelte 5
No blur. The placeholder is the image, approximated by geometric shapes fitted at build time — and because they're stored in fit order, replaying them makes the picture visibly sharpen until the real photo crossfades in.
In production on szkolyjogi.pl — 700+ listing photos resolve from their geometric preview — and kurcz.pl.
Playground
- Inline placeholder
- 8.0 KB 8.0 raw
- Lighter first paint
- — vs. the photo
- Shapes
- 100 in fit order
- Fit time
- build prebuilt
How it works
- 01
Fit at build time
A Vite plugin fits geometric shapes to each
?geometrizeimport — cached on disk by content hash, so clean rebuilds skip work you've already done. Or batch CMS photos withnpx svelte-geometrize. The expensive part never ships. - 02
Paint instantly, no layout shift
The placeholder is inline in the server-rendered HTML, so a real preview fills the box before the photo's first byte arrives — and because its aspect ratio is reserved, nothing below it ever jumps.
- 03
Reveal, then crossfade
revealMspaces the shapes across a fixed budget; pure CSS plays before hydration and respects reduced motion. Then the photo dissolves over the same structure — content-aware, not a blur.
Use it
import { GeometrizedImage } from '@nomideusz/svelte-geometrize';
import placeholder from './photo.jpg?geometrize';
import src from './photo.jpg';
<GeometrizedImage {placeholder} {src} alt="Sunset over mountains" revealMs={850} />
// build / ingest also need: pnpm add -D sharp
// npx svelte-geometrize ./photos --out ./placeholdersFull options and the Node API are in the docs.