reactolith automatically manages scroll position during
navigation, just like a traditional multi-page website:
| Navigation | Behavior |
|---|---|
| Link click / Form submit | Scrolls to top |
URL with #hash | Scrolls to the hash element |
| Browser Back / Forward | Restores previous scroll position |
Scroll positions are stored in sessionStorage, so they
survive page refreshes within the same tab.
Sometimes you don't want to scroll to the top after navigation
(e.g., in-page filters, pagination). Add
data-scroll="preserve" to the link or form:
By default, reactolith auto-detects the scroll container
by walking up the DOM from the root element and finding the nearest
ancestor with overflow-y: auto|scroll. If none is found,
window is used.
You can override this with an explicit selector: