THE PLAYGROUND · SCROLL & NAVIGATION
Sticky Header Animation
A header becomes compact as content scrolls beneath it.
Sticky Header AnimationScroll & Navigation · A header becomes compact as content scrolls beneath it.
SCROLLFIELD NOTES
Find your rhythmA moment worth noticing.
Make space for ideasA moment worth noticing.
Follow the feelingA moment worth noticing.
Stay curiousA moment worth noticing.
Keep exploringA moment worth noticing.
1import { useState } from "react";2import { motion } from "motion/react";3 4const surface = { width: 100, height: 100, borderRadius: 16, background: "#b8ed79", display: "grid", placeItems: "center", color: "#141714" };5 6export default function StickyDemo() {7 const [scroll, setScroll] = useState(0);8 return <div onScroll={e => setScroll(e.currentTarget.scrollTop)} style={{height: 260, overflowY: "auto"}}>9 <header style={{position: "sticky", top: 0, background: "#202420", height: 40, color: "white"}}>Field notes</header>10 11 {[0,1,2,3,4,5,6].map(n => <motion.div key={n} style={{...surface, width: 260, height: 80, margin: 12}} >Note {n+1}</motion.div>)}12 </div>;13}Install: npm install motion. A sticky surface stays in the same scroll context. This compact example illustrates the core technique; the styled playground contains additional presentation details.