Go back

The root scroller and how not to lose it 📜

Why you should preserve the page’s root scroller and avoid losing native scrolling features.

The root scroller and how not to lose it 📜

Kilian Valkhof explains in detail what the page’s main scroll container can do: it automatically restores the scroll position, handles keyboard navigation (the space bar and arrow keys), and on mobile can hide the address bar and enable pull-to-refresh.

The main problem: if you put all your content inside a fixed-height wrapper with overflow: auto, you effectively replace the root scroller. Native features stop working, and window.scrollY gets permanently stuck at zero.

The author shows that most common cases, whether full-screen layouts, sticky headers or locking scrolling behind modals, have solutions that preserve genuine page scrolling.

Read the full article

Copied