Sticky Stuck Detection

Detect when a position-sticky element has hit its offset, then restyle it

CSS's position: sticky docks an element at an offset, but leaves you without a hook for when that docking actually happens. A sentinel fills the gap: a 1px element sits in normal flow just above the target, with a matching -1px margin so it doesn't shift layout. An IntersectionObserver watches it against the scroll container, and the moment the sentinel leaves view, the target has docked.

That boolean becomes a styling hook. Here, the bar reads isStuck and compacts the search input into a pill. Motion's layout prop drives this behavior, with shared layoutIds carrying the icon and label through the transition. This makes it render as one element morphing itself.

View source

Scroll to dock the search bar

  • Ada Lovelace
  • Grace Hopper
  • Alan Turing
  • Margaret Hamilton
  • Dennis Ritchie
  • Barbara Liskov
  • Linus Torvalds
  • Radia Perlman
  • Donald Knuth
  • Frances Allen
  • Tim Berners-Lee
  • Katherine Johnson
  • John von Neumann
  • Claude Shannon
  • Edsger Dijkstra
  • Sheryl Sandberg
  • Ken Thompson
  • Adele Goldberg
  • James Gosling
  • Marissa Mayer