CSS Popover Shadow
A crisp, high-elevation shadow for popovers and dropdowns, with a hairline edge and a matching arrow.
Find it under Favorites any time.
<div class="popover-panel">
<strong>Saved to library</strong>
<p>Find it under Favorites any time.</p>
</div>
.popover-panel {
position: relative;
width: 220px;
padding: 14px 16px;
border-radius: 12px;
background: #ffffff;
color: #475569;
font: 14px/1.45 system-ui, sans-serif;
box-shadow:
0 0 0 1px #0f172a14,
0 4px 6px -2px #0f172a14,
0 12px 24px -6px #0f172a29,
0 24px 48px -12px #0f172a1f;
}
/* Arrow: a rotated square sharing the hairline edge */
.popover-panel::before {
content: "";
position: absolute;
top: -6px;
left: 24px;
width: 12px;
height: 12px;
background: #ffffff;
box-shadow: -1px -1px 0 #0f172a14;
transform: rotate(45deg);
}
.popover-panel strong {
display: block;
margin-bottom: 2px;
color: #0f172a;
}
.popover-panel p {
margin: 0;
}
About this CSS Popover Shadow
This CSS Popover Shadow is 37 lines of pure CSS (0.7 KB) with no JavaScript and no dependencies. It uses transforms and box shadows. 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:
#ffffff#475569#0f172a14#0f172a29#0f172a1f#0f172a
How to use this popover 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
.popover-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.