PositioningZ-Index

Z-Index

Controls the element's stack order.

Widely available

This feature is well established and works across many devices and browser versions.

Chrome
Edge
Firefox
Safari
ClassStyle
zi-0z-index: 0;
zi-10z-index: 10;
zi-20z-index: 20;
zi-30z-index: 30;
zi-40z-index: 40;
zi-50z-index: 50;
zi-60z-index: 60;
zi-70z-index: 70;
zi-80z-index: 80;
zi-90z-index: 90;
zi-autoz-index: auto;

This example showcases various z-index utilities:

  • The zi-10 z index utility sets the z-index to 10, positioning the element above elements with a lower z-index value.
  • The zi-20 z index utility sets the z-index to 20, positioning the element even higher in the stacking context.
A
B
<div class="p-r">
<div class="ai-c bg-indigo d-30 d-f jc-c p-r zi-10">
<div class="tc-white">A</div>
</div>
<div class="ai-c bg-indigo-8 d-15 d-f jc-c l-0 p-a t-0 zi-20">
<div class="tc-white">B</div>
</div>
</div>

Using utility variants

Learn how to override existing utilities based on the user's screen size or other factors, such as hover states.

Target media queries

You can combine responsive breakpoints like sm:zi-*, md:zi-*, lg:zi-*, and xxl:zi-* to allow targeting specific utilities in different viewports.

Targeting hover states

Alternatively, you can apply :hover by using h:zi-* utility to override elements and change their values when hovering over them.