# Scroll Header Shadow

> A sticky header that gains a soft shadow only once its panel scrolls, using a scroll-driven animation.

- Category: [CSS Box Shadows](https://copy-css.com/category/shadows)
- Tags: sticky header, scroll-driven, animation-timeline, elevation, panel
- Live preview: https://copy-css.com/snippets/scroll-header-shadow
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<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>
```

## CSS

```css
.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; }
}
```

## Notes

- 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.
- scroll-driven animations: Chrome and Edge 115+ and Safari 26+. Firefox support is very recent; browsers without it skip the animation and show the content as is.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
