{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

ZIndexModifierKt

public final class ZIndexModifierKt


Summary

Public methods

static final @NonNull Modifier
zIndex(@NonNull Modifier receiver, float zIndex)

Creates a modifier that controls the drawing order for the children of the same layout parent.

Public methods

zIndex

public static final @NonNull Modifier zIndex(@NonNull Modifier receiver, float zIndex)

Creates a modifier that controls the drawing order for the children of the same layout parent. A child with larger zIndex will be drawn on top of all the children with smaller zIndex. When children have the same zIndex the original order in which the parent placed the children is used.

Note that if there would be multiple zIndex modifiers applied for the same layout the sum of their values will be used as the final zIndex. If no zIndex were applied for the layout then the default zIndex is 0.

import androidx.compose.foundation.layout.Box
import androidx.compose.material.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.zIndex

Box {
    Text("Drawn second", Modifier.zIndex(1f))
    Text("Drawn first")
}