stax-monorepo
    Preparing search index...

    Type Alias ScrollBehavior

    ScrollBehavior:
        | "top"
        | "preserve"
        | ((from: string, to: string) => Effect.Effect<void>)

    How the outlet's scroll container should be reset after client-side navigation.

    • "top" — scroll the outlet's nearest scrollable ancestor back to the top. For a window-scrolled document that's document.scrollingElement (matches what a full page load would do). For an app-shell layout where scrolling lives inside a nested overflow-y: auto container (a common 100vh + overflow-y: auto main region), it's that inner container — window.scrollTo would have been a no-op on such apps.
    • "preserve" — leave scroll position untouched. Useful for e.g. a sidebar layout where sibling nav shouldn't disturb the main viewport.
    • Custom function — receives the from/to paths and returns an effect the runtime awaits before the transition completes. Use for sessionStorage-backed restoration, hash-anchor scrolling, or when the auto-detected "top" target picks the wrong container.

    ScrollBehavior only fires for pushPath / replacePath. Popstate navigations (browser back/forward) are left to the browser's history.scrollRestoration = "auto", which restores per-history-entry positions correctly — better than a URL-keyed approximation could.