Skip to main contentSkip to docs navigation

Chassis

Set the stack order of positioned elements with low-level z-index utilities.

@layer utilities

Overview

z-index utilities set the CSS z-index property, from .z-n1 (-1) to .z-5. z-index takes effect only on an element whose position is not static: set it with a position utility or in custom styles.

These utilities are low-level: their values, -1 through 5, order overlapping elements within a layout. Overlay components such as modals and tooltips use higher z-index values, defined separately.

z-3
z-2
z-1
z-0
z-n1
HTML
<div class="z-3 position-absolute p-4xl rounded"><span>z-3</span></div>
<div class="z-2 position-absolute p-4xl rounded"><span>z-2</span></div>
<div class="z-1 position-absolute p-4xl rounded"><span>z-1</span></div>
<div class="z-0 position-absolute p-4xl rounded"><span>z-0</span></div>
<div class="z-n1 position-absolute p-4xl rounded"><span>z-n1</span></div>

Overlays

Chassis overlay components — menus, modals, drawers, popovers, toasts, and tooltips — each have their own z-index value. The z-index layout page documents them.

Component approach

Some components use the low-level z-index values to order the elements of a repeating group, such as the buttons of a button group. The z-index scales section of the extend page describes the approach.

CSS

Z-index utilities are generated from Sass maps via the utilities API.

Reference

The table lists all z-index utilities and their CSS properties.

ClassProperties
.z-n1z-index: -1;
.z-0z-index: 0;
.z-1z-index: 1;
.z-2z-index: 2;
.z-3z-index: 3;
.z-4z-index: 4;
.z-5z-index: 5;

Sass maps

Z-index utilities are generated from Sass maps in scss/config/_defaults.scss.

$zindex-levels: (
  n1: -1,
  0: 0,
  1: 1,
  2: 2,
  3: 3,
  4: 4,
  5: 5
);

Utilities API

Z-index utilities are declared in scss/utilities/_index.scss using the utilities API.

"z-index": (
  property: z-index,
  class: z,
  values: $zindex-levels,
),