CSS Scroll Shadows
Shadows that appear at the top and bottom of a scroll box only while more content is hidden there.
- v2.6 Faster search
- v2.5 Keyboard shortcuts
- v2.4 Dark mode
- v2.3 Team folders
- v2.2 Export to PDF
- v2.1 Comments
- v2.0 New editor
<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>
/* 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;
}
About this CSS Scroll Shadows
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. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.
CSS features used
Customize it
The colors in this snippet. Search and replace them to match your brand:
#334155#ffffff#ffffff00#0f172a40#0f172a00#f1f5f9#2563eb
How to use this scroll shadows
- 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-shadowsclass 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.