CSS Scroll Header Shadow
A sticky header that gains a soft shadow only once its panel scrolls, using a scroll-driven animation.
Design review moved to 3pm
New comment on Homepage v2
Invoice #1042 was paid
Weekly report is ready
Alex shared a file with you
Your trial ends in 3 days
<section class="scroll-panel" tabindex="0" aria-label="Inbox">
<header class="scroll-panel-head">Inbox</header>
<p>Design review moved to 3pm</p>
<p>New comment on Homepage v2</p>
<p>Invoice #1042 was paid</p>
<p>Weekly report is ready</p>
<p>Alex shared a file with you</p>
<p>Your trial ends in 3 days</p>
</section>
.scroll-panel {
width: 240px;
height: 170px;
overflow: auto;
border-radius: 14px;
background: #ffffff;
color: #334155;
font: 14px/1.4 system-ui, sans-serif;
box-shadow: 0 0 0 1px #e2e8f0;
scroll-timeline: --panel-scroll;
}
.scroll-panel:focus-visible {
outline: 2px solid #2563eb;
outline-offset: 2px;
}
.scroll-panel-head {
position: sticky;
top: 0;
padding: 12px 16px;
background: #ffffff;
color: #0f172a;
font-weight: 700;
}
.scroll-panel p {
margin: 0;
padding: 10px 16px;
border-top: 1px solid #f1f5f9;
}
/* Browsers without scroll-driven animations keep a flat header */
@supports (animation-timeline: scroll()) {
.scroll-panel-head {
animation: scroll-panel-lift linear both;
animation-timeline: --panel-scroll;
animation-range: 0 24px;
}
}
@keyframes scroll-panel-lift {
to { box-shadow: 0 6px 12px -6px #0f172a40; }
}
@media (prefers-reduced-motion: reduce) {
.scroll-panel-head { animation: none; }
}
About this CSS Scroll Header Shadow
This CSS Scroll Header Shadow is 48 lines of pure CSS (1.0 KB) with no JavaScript and no dependencies. It uses scroll-driven animations, keyframe animations, box shadows and sticky positioning. It relies on scroll-driven animations, which not every browser supports yet, so check the browser notes below. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.
CSS features used
- scroll-driven animationsChrome and Edge 115+ and Safari 26+. Firefox support is very recent; browsers without it skip the animation and show the content as is.
- keyframe animations
- box shadows
- sticky positioning
- keyboard focus styles
- reduced-motion support
Customize it
The colors in this snippet. Search and replace them to match your brand:
#ffffff#334155#e2e8f0#2563eb#0f172a#f1f5f9#0f172a40
How to use this scroll header shadow
- Copy the HTML and paste it where you want the element to appear.
- Copy the CSS into your stylesheet, or inside a
<style>tag. - Keep the
.scroll-panelclass name, or rename it in both places. Then tweak colors, sizes and timing to match your design. - Using React or Next.js? Change
classtoclassNamein the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).
Building with an AI tool?
“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.