Astro has no built-in blur placeholder prop, but an Astro image placeholder takes a few lines: generate a tiny version of the image with getImage() (around 24 pixels wide), show it blurred behind the real <Image>, and let the full image cover it when it loads. Because <Image> always sets width and height, the space is reserved and nothing shifts.
Key Takeaways
<Image>and<Picture>have noplaceholderprop; build one fromgetImage().- A 24-pixel-wide WebP is typically a few hundred bytes.
- Blur the placeholder in a pseudo-element, not the image, so the final image stays sharp.
- A solid background color from the image is an even lighter alternative.
A reusable component
---
// src/components/BlurImage.astro
import { Image, getImage } from 'astro:assets';
import type { ImageMetadata } from 'astro';
interface Props {
src: ImageMetadata;
alt: string;
widths?: number[];
sizes?: string;
}
const { src, alt, widths = [640, 960, 1280], sizes = '100vw' } = Astro.props;
const tiny = await getImage({ src, width: 24, format: 'webp', quality: 'low' });
---
<div class="blur-wrap" style={`--lqip: url(${tiny.src}); aspect-ratio: ${src.width} / ${src.height};`}>
<Image src={src} alt={alt} widths={widths} sizes={sizes} />
</div>
<style>
.blur-wrap {
position: relative;
overflow: hidden;
}
.blur-wrap::before {
content: '';
position: absolute;
inset: 0;
background: var(--lqip) center / cover no-repeat;
filter: blur(16px);
transform: scale(1.1);
}
.blur-wrap :global(img) {
position: relative;
width: 100%;
height: 100%;
object-fit: cover;
}
</style>
Use it wherever you would use <Image>:
---
// src/pages/index.astro
import BlurImage from '../components/BlurImage.astro';
import cover from '../assets/cover.jpg';
---
<BlurImage src={cover} alt="Studio interior at dusk" sizes="(min-width: 960px) 50vw, 100vw" />
The scale(1.1) hides the soft edges the blur creates. :global(img) is needed because the <img> is rendered by the Image component, outside this component’s scope; our :global() tip explains why.
Make the swap smoother
The full image appears as soon as it decodes. For a short fade, start it transparent and reveal it on load:
<script>
document.querySelectorAll<HTMLImageElement>('.blur-wrap img').forEach((img) => {
if (img.complete) return;
img.style.opacity = '0';
img.style.transition = 'opacity 300ms';
img.addEventListener('load', () => (img.style.opacity = '1'), { once: true });
});
</script>
Images that are already cached stay visible, so there is no fade on repeat visits. Skip this script for the LCP image; any delay in showing it counts against LCP.
Lighter option: a dominant color
If a blur is more than you need, a background color close to the image’s average color is free at runtime:
<Image src={cover} alt="..." style="background-color: #c8b8a2" />
Pick the color by hand or compute it at build time with Sharp, which Astro already uses for image processing.
Trade-offs
The tiny image is a separate small request. On a page with many images, that is many requests; consider placeholders only for large, above-the-fold or gallery images. Our Astro Image component guide covers sizing, the getImage() reference lists its options, and image-heavy themes in our Architecture & Design category are a natural place to use this. See the theme styling docs for where image components live.
FAQ
Does Astro support blur placeholders for images?
Not as a built-in prop. Generate a tiny version with getImage() and display it blurred behind the full image, as shown above.
Do image placeholders prevent layout shift in Astro?
Layout shift is prevented by the width and height that <Image> adds automatically. A placeholder improves how loading looks; it does not change layout stability.
Should the LCP image have a blur placeholder?
It can, but do not hide the full image behind a fade. Load it with priority and let it paint as soon as it is ready, so the placeholder only covers the brief gap.