01.10 · Scroll-Based

Snap Scrolling

The box settles on one whole section at a time. Best for slides and galleries.

Scroll it

Scroll inside the box and let go: it settles on the nearest section. Press Play and it glides through without snapping.

A stop lines up here

Past a dashed line, it settles on the next

Always snaps

Try it

Change a setting, then scroll again or press Play.

Snapping

Scroll by hand to see it; Play glides without snapping.

Copy the prompt

Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.

Add snap scrolling to [your page of full-height sections, slides or gallery]. Make each section exactly as tall as the scrolling area and mark its top as a snap point, so that, as the settings choose, the view settles on the nearest section instead of stopping between two. Use the browser's built-in scroll snapping rather than a script. Add small dots that show which section is in view and take the visitor to a section when pressed. Check scrolling with the arrow keys too, because strict snapping can feel stiff there. If the visitor has reduced motion turned on, let the view settle without a smooth glide. Match the settings listed below.

Replace the words in brackets with your own element. Your settings are added at the end.

Free and open source. If this helped, a star on GitHub helps other people find it.

Star on GitHub

What it is

The full explanation is in README.md.

Good for

  • Slides
  • Galleries
  • Onboarding
  • Full-screen sections

Avoid on

  • Long articles
  • Uneven sections