Scroll Snap for Galleries
Scroll snap turns an overflowing row into a gallery with no JavaScript.
The minimum setup
We asked a few readers to try it with a keyboard only. Two of them found problems in under a minute, which is exactly why we asked.
- Overflow on the row
- Snap type on the container
- Snap align on each item
Browser support is no longer the excuse it used to be. Everything in this post works in every current browser without a fallback.
We removed a 40 KB slider and nobody noticed.
If you only change one thing after reading this, make it the spacing. Consistent gaps make even a rough layout look intentional.
Colour is the last thing we add. Getting the structure right in black and white first saves a lot of arguing later.
None of this is new. It is the same advice print designers have given for a century, moved onto screens.
We keep a scratch file of small experiments like this one. Most of them go nowhere, but a few end up in every project.
Clients rarely notice these details directly. They notice that the site feels solid, and that nothing jumps around when it loads.
The code is short enough to read in one sitting. That matters, because code you can read is code you can change.
We still get it wrong sometimes. The difference now is that fixing it takes one line instead of an afternoon.
Try it on a small page first, not your whole site. You will learn more from one finished page than a half-finished redesign.
4 thoughts on “Scroll Snap for Galleries”
Finally someone says it plainly. Thank you.
Fair point, we should have mentioned it.
Same here. It took a week to get used to it.
I would add one thing: check it in dark mode too.