pp-reset-scroll

Prisma PHP

Forces a container to reset its scroll position to the top (0px) when a navigation event occurs. Critical for dashboards with independent scroll areas.

Why is this needed?

Standard Behavior

In a standard SPA navigation, the browser often preserves the scroll position of the window. However, in modern dashboard layouts, the window (body) doesn't scroll—a specific internal div or main tag does.

The Issue

If a user scrolls down 500px on "Page A" and clicks a link to "Page B", they will arrive at "Page B" still scrolled down 500px. This feels broken to the user.

Implementation

Target Element

Add the attribute to the container that actually scrolls. In a typical dashboard, this is your main tag, not the body.

Note: If you are using Tailwind's scroll-smooth class, you might not need this directive, as smooth scrolling handles transitions gracefully. Use this for instant snapping.

dashboard-layout.php
<div class="flex h-screen">
  <Sidebar />

  <main
    class="flex-1 overflow-y-auto"
    pp-reset-scroll="true"
  >
    <!-- Dynamic Page Content -->
    <?php echo $content; ?>
  </main>
</div>