Utilities for controlling the stack order of an element.
2025-04-12
Written by: tdtc
| Class | Styles |
|---|---|
z-<number> | z-index: <number>; |
| z-auto | z-index: auto; |
z-[<value>] | z-index: <value>; |
z-(<custom-property>) | z-index: var(<custom-property>); |
Use the z- utilities like z-10
and z-50 to control the stack order (or three-dimensional positioning)
of an element, regardless of the order it has been displayed:
<div class="z-40 ...">05</div>
<div class="z-30 ...">04</div>
<div class="z-20 ...">03</div>
<div class="z-10 ...">02</div>
<div class="z-0 ...">01</div>
To use a negative z-index value, prefix the class name with a dash to convert it to a negative value:
<div class="...">05</div>
<div class="...">04</div>
<div class="-z-10 ...">03</div>
<div class="...">02</div>
<div class="...">01</div>
Use the z-[ syntax to set the stack order based on a completely custom value:
<div class="z-[calc(var(--index)+1)] ...">
<!-- ... -->
</div>