CSS Frosted Modal Backdrop
A tinted, blurred overlay behind a modal, with the same look applied to a native dialog::backdrop.
Discard changes?
Your edits will be lost.
<div class="frost-scrim">
<div class="frost-modal" role="dialog" aria-modal="true" aria-labelledby="frost-title">
<h3 id="frost-title">Discard changes?</h3>
<p>Your edits will be lost.</p>
<button type="button">Keep editing</button>
</div>
</div>
.frost-scrim,
dialog.frost-modal::backdrop {
background: rgba(15, 23, 42, 0.3);
-webkit-backdrop-filter: blur(6px);
backdrop-filter: blur(6px);
}
.frost-scrim {
position: fixed;
inset: 0;
z-index: 50;
display: grid;
place-items: center;
padding: 16px;
}
.frost-modal {
width: min(100%, 240px);
padding: 20px;
border: 0;
border-radius: 16px;
background: #fff;
box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.45);
color: #0f172a;
font-family: system-ui, sans-serif;
}
.frost-modal h3 {
margin: 0 0 4px;
font-size: 17px;
}
.frost-modal p {
margin: 0 0 16px;
color: #64748b;
font-size: 14px;
}
.frost-modal button {
width: 100%;
padding: 10px;
border: 0;
border-radius: 10px;
background: #0f172a;
color: #fff;
font: 600 14px system-ui, sans-serif;
cursor: pointer;
}
.frost-modal button:focus-visible {
outline: 2px solid #0f172a;
outline-offset: 2px;
}
About this CSS Frosted Modal Backdrop
This CSS Frosted Modal Backdrop is 53 lines of pure CSS (0.9 KB) with no JavaScript and no dependencies. It uses box shadows, backdrop filters, CSS Grid 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
- box shadows
- backdrop filtersIncludes the -webkit- prefix for older Safari.
- CSS Grid
- keyboard focus styles
Customize it
The colors in this snippet. Search and replace them to match your brand:
#fff#0f172a#64748b
How to use this frosted modal backdrop
- 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
.frost-scrimclass 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.