Skip to content

ExpressiveCSS

Browse documentation

Shadow

Raise or flatten an element with the z-depth elevation classes.

View as Markdown

On this page

In Material Design, every element has a z-depth. The z-depth sets how far the element rises above the page.

To apply a shadow, add a class such as class="z-depth-2" to an HTML tag. In Sass, include the mixin instead of extending the class, as in @include z-depth("2"). To remove the shadow from an element that has a z-depth by default, use z-depth-0.

0
1
2
3
4
5
<div class="row">
  <div class="s12 m4 l3">
    <div class="z-depth-0">0</div>
  </div>
  <div class="s12 m4 l3">
    <div class="z-depth-1">1</div>
  </div>
  <div class="s12 m4 l3">
    <div class="z-depth-2">2</div>
  </div>
  <div class="s12 m4 l3">
    <div class="z-depth-3">3</div>
  </div>
  <div class="s12 m4 l3">
    <div class="z-depth-4">4</div>
  </div>
  <div class="s12 m4 l3">
    <div class="z-depth-5">5</div>
  </div>
</div>
Sass

The build generates the classes from the same map as the mixin, so the two always match. Use the mixin inside component styles. @extend .z-depth-2 across files is not supported.

.my-panel {
  @include z-depth("2");
}

z-depth-1-half adds an in-between level from the same elevation map.

To soften or deepen a level at runtime, override its custom property in your theme. The properties run from --md-sys-elevation-level0 to --md-sys-elevation-level5, plus --md-sys-elevation-level1-half. The classes, the mixin and every component read them.

<style>
  :root { --md-sys-elevation-level1: 0 1px 3px rgb(0 0 0 / 0.3); }
</style>

Stacking order

A shadow does not decide what sits on top. Surfaces that float over the page take their z-index from these properties, listed lowest first. Dialogs, modal sheets, open menus, an open lightbox and open popovers sit in the browser's top layer, above all of them.

PropertyValueUsed by
--expressive-z-toolbar996A fixed toolbar.
--expressive-z-app-bar997A pinned top app bar and a fixed navigation bar.
--expressive-z-modal-rail998An expanded navigation rail over the page.
--expressive-z-sheet1100A bottom or side sheet opened without showModal().
--expressive-z-lightbox1200Nothing. An open lightbox is in the top layer.
--expressive-z-tooltip2000Tooltips.
--expressive-z-menu9999The docked date and time pickers. Open menus are in the top layer.
--expressive-z-snackbar10000Snackbars.
--expressive-z-confetti10001The confetti overlay, in browsers without popovers.
<style>
  /* A site banner that should cover the app bar but stay under sheets. */
  :root { --site-banner-z: calc(var(--expressive-z-app-bar) + 1); }
  .site-banner { position: sticky; top: 0; z-index: var(--site-banner-z); }
</style>

No matching pages

  • Source color

    The seed every generated ramp derives from. Pick one and browse the docs — the whole theme follows. Error does not: it is a fixed hue.

    Default source: Mist Iris.

    ExpressiveCSS presets: Lagoon, Harbor, Breeze, Cobalt, Iris.

    Bold

    Soft

    Mist

    Glow