CSS Frosted Modal Backdrop

A tinted, blurred overlay behind a modal, with the same look applied to a native dialog::backdrop.

  • modal
  • dialog
  • backdrop
  • blur
  • overlay
  • glassmorphism
HTML
<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>
CSS
.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

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

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .frost-scrim class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in 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.

Feedback