Single scroller + sticky chrome

#tech#design

Single scroller + sticky chrome

Hello Gio

One scroll container. A bar that pins. Content below stays in normal flow. After the bar docks, the same scroller keeps moving the list under it. No JS, no nested overflow.


Layout

┌─ app (100dvh, overflow: hidden) ─────────┐
│                                          │
│  ┌─ scrollport (overflow-y: auto) ────┐  │
│  │  hero          ← scrolls away      │  │
│  │  sticky bar    ← pins at top       │  │
│  │  list          ← grows, no overflow│  │
│  └────────────────────────────────────┘  │
└──────────────────────────────────────────┘
<div class="app">
  <div class="scrollport">
    <header class="hero">…</header>
    <div class="bar">filters / tabs</div>
    <div class="list">…</div>
  </div>
</div>
.app {
  height: 100dvh;
  overflow: hidden;
}

.scrollport {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
}

.bar {
  position: sticky;
  top: 0;
  z-index: 1;
  flex-shrink: 0;
}

.list {
  /* no height, no overflow */
}

Rules

  1. Lock the shell — height: 100dvh; overflow: hidden so the window does not scroll.
  2. One scrollport — the child that actually moves: min-height: 0; overflow-y: auto.
  3. Order — departing header → sticky bar → growing content.
  4. List is in-flow — do not set overflow or a fixed height on the content under the bar.
  5. No overflow between bar and scrollport — any ancestor with overflow: hidden | auto | scroll | clip kills sticky. Force those to visible (or height: auto) if a UI kit sets them.

Stacked sticky (optional)

A second column that pins under the bar:

.sidebar {
  position: sticky;
  top: var(--bar-height); /* measured height of the bar above */
  align-self: start;      /* required: stretched columns never stick */
}

Do not

.list {
  height: 100%;
  overflow-y: auto; /* second scroller — different pattern */
}

That pins the header forever and splits the gesture. This pattern uses one scroller the whole time.