CSS Material Elevation Levels

Material-style elevation at 1, 3, 6 and 12dp, each built from umbra, penumbra and ambient shadows.

  • material design
  • umbra
  • penumbra
  • ambient
  • dp
HTML
<div class="md-surface md-elevation-1">1</div>
<div class="md-surface md-elevation-3">3</div>
<div class="md-surface md-elevation-6">6</div>
<div class="md-surface md-elevation-12">12</div>
CSS
.md-surface {
  --umbra: #00000033;
  --penumbra: #00000024;
  --ambient: #0000001f;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: #ffffff;
  color: #616161;
  font: 500 14px system-ui, sans-serif;
}

.md-elevation-1 {
  box-shadow:
    0 2px 1px -1px var(--umbra),
    0 1px 1px 0 var(--penumbra),
    0 1px 3px 0 var(--ambient);
}

.md-elevation-3 {
  box-shadow:
    0 3px 3px -2px var(--umbra),
    0 3px 4px 0 var(--penumbra),
    0 1px 8px 0 var(--ambient);
}

.md-elevation-6 {
  box-shadow:
    0 3px 5px -1px var(--umbra),
    0 6px 10px 0 var(--penumbra),
    0 1px 18px 0 var(--ambient);
}

.md-elevation-12 {
  box-shadow:
    0 7px 8px -4px var(--umbra),
    0 12px 17px 2px var(--penumbra),
    0 5px 22px 4px var(--ambient);
}

About this CSS Material Elevation Levels

This CSS Material Elevation Levels is 41 lines of pure CSS (0.8 KB) with no JavaScript and no dependencies. It uses box shadows, CSS Grid and custom properties. 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

Change these custom properties to restyle the material elevation levels without touching the rest of the CSS:

PropertyDefault
--umbra#00000033
--penumbra#00000024
--ambient#0000001f

How to use this material elevation levels

  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 .md-surface 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