How to use Next Image fill for a square collection icon
Answer in brief
Give the parent a defined size and a positioning context before using fill. Choose the image fit according to whether the whole object needs to remain visible.
Build a square collection tile
Set the wrapper to position: relative with aspect-ratio: 1 / 1 and a grid-defined width. Use Image with fill, objectFit set to contain and sizes describing the grid slot. Check the parent has a nonzero height after layout.
Match the downloaded image to the grid slot
A fill image can look correct while downloading far more pixels than its tile needs. In a four-column gallery, inspect the tile's rendered width and the chosen candidate on a high-density display. Update sizes when changing the gallery breakpoint or the maximum width of the grid.
Sources
- [1] Image Component — Next.js, accessed November 23, 2026
Frequently asked questions
Why does the image cover more than its card?
Inspect the positioned ancestor. The fill image needs its intended wrapper to establish the containing block.