Back to demos

Responsive images

Responsive layout

size={100} declares the image occupies 100vw, which becomes the sizes attribute. The browser then picks a width from srcset for its own viewport and DPR — which is why no import here asks for a width above 1120, the intrinsic width of these files. The plugin would report the requested width regardless, and a srcset that overstates a candidate misleads exactly the calculation it exists to feed.

A guitar finished in a racing livery
import
racing.jpg?w=640;828;1120
formats
jpeg, webp, avif
widths
640, 828, 1120
aspect ratio
1.000
largest candidate
/_astro/example-guitar-racing-1120w.DVFKOgIG.jpg

Fixed layout

width without size switches to the fixed strategy: a 240px box, with the 480px candidate reserved for 2x displays. Height is derived from the aspect ratio, so the box never shifts while loading.

The same guitar at a fixed 240px
import
racing.jpg?w=240;480&format=original;webp
formats
jpeg, webp
widths
240, 480
aspect ratio
1.000
largest candidate
/_astro/example-guitar-racing-480w.DTLcnsmb.jpg

Placeholders (LQIP)

Throttle the network in devtools and reload — each tile shows a different placeholder while the full image streams in. The cost is paid in the HTML, not in an extra request.

Guitar with travel stickers, dominant-colour placeholder
colorplaceholder present
Guitar with travel stickers, inline blurred placeholder
inlineplaceholder present
blurhashplaceholder present