CSS Dark Glass Card

A smoky dark glass card with a light-catching gradient edge drawn with a masked pseudo-element.

  • glassmorphism
  • dark mode
  • frosted
  • gradient border
  • mask
  • neon
HTML
<article class="glass-dark">
  <span class="glass-dark-icon" aria-hidden="true">✦</span>
  <h3>Night mode</h3>
  <p>Smoked glass that still lets the color glow through.</p>
</article>
CSS
.glass-dark {
  position: relative;
  width: 220px;
  padding: 22px;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.45);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  color: #e2e8f0;
  font-family: system-ui, sans-serif;
}

.glass-dark::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.05) 40%, rgba(255, 255, 255, 0.05) 60%, rgba(255, 255, 255, 0.35));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
}

.glass-dark-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #67e8f9;
  font-size: 20px;
}

.glass-dark h3 {
  margin: 0 0 6px;
  color: #fff;
  font-size: 17px;
}

.glass-dark p {
  margin: 0;
  color: #94a3b8;
  font-size: 14px;
  line-height: 1.5;
}

About this CSS Dark Glass Card

This CSS Dark Glass Card is 49 lines of pure CSS (1.1 KB) with no JavaScript and no dependencies. It uses linear gradients, backdrop filters, masks and CSS Grid. 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:

  • #e2e8f0
  • #000
  • #67e8f9
  • #fff
  • #94a3b8

How to use this dark glass card

  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 .glass-dark 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