# Scroll Shadows

> Shadows that appear at the top and bottom of a scroll box only while more content is hidden there.

- Category: [CSS Box Shadows](https://copy-css.com/category/shadows)
- Tags: overflow, scroll hint, background-attachment, list, no javascript
- Live preview: https://copy-css.com/snippets/scroll-shadows
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<ul class="scroll-shadows" tabindex="0" aria-label="Release notes">
  <li>v2.6 Faster search</li>
  <li>v2.5 Keyboard shortcuts</li>
  <li>v2.4 Dark mode</li>
  <li>v2.3 Team folders</li>
  <li>v2.2 Export to PDF</li>
  <li>v2.1 Comments</li>
  <li>v2.0 New editor</li>
</ul>
```

## CSS

```css
/* White covers move with the content (local) and hide the shadows at either end */
.scroll-shadows {
  box-sizing: border-box;
  width: 220px;
  max-height: 150px;
  margin: 0;
  padding: 0 16px;
  overflow: auto;
  border-radius: 12px;
  list-style: none;
  color: #334155;
  font: 14px/1.4 system-ui, sans-serif;
  background:
    linear-gradient(#ffffff 30%, #ffffff00) top / 100% 40px no-repeat local,
    linear-gradient(#ffffff00, #ffffff 70%) bottom / 100% 40px no-repeat local,
    radial-gradient(farthest-side at 50% 0, #0f172a40, #0f172a00) top / 100% 14px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, #0f172a40, #0f172a00) bottom / 100% 14px no-repeat scroll,
    #ffffff;
}

.scroll-shadows li {
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}

.scroll-shadows:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}
```

## Notes

- This CSS Scroll Shadows is 29 lines of pure CSS (0.9 KB) with no JavaScript and no dependencies. It uses linear gradients, radial gradients and keyboard focus styles.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
