# zIndex

Common/AllAndroid/JVM

## Functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.https://developer.android.com/reference/kotlin/androidx/compose/ui/zIndex.modifier#(androidx.compose.ui.Modifier).zIndex(kotlin.Float)(zIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Creates a modifier that controls the drawing order for the children of the same layout parent. | Cmn |

## Functions

### Modifier.zIndex

Cmn Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/ZIndexModifier.kt+function:zIndex) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun Modifier.zIndex(zIndex: Float): Modifier
```

Creates a modifier that controls the drawing order for the children of the same layout parent. A child with larger `https://developer.android.com/reference/kotlin/androidx/compose/ui/zIndex.modifier#(androidx.compose.ui.Modifier).zIndex(kotlin.Float)` will be drawn on top of all the children with smaller `https://developer.android.com/reference/kotlin/androidx/compose/ui/zIndex.modifier#(androidx.compose.ui.Modifier).zIndex(kotlin.Float)`. When children have the same `https://developer.android.com/reference/kotlin/androidx/compose/ui/zIndex.modifier#(androidx.compose.ui.Modifier).zIndex(kotlin.Float)` the original order in which the parent placed the children is used.

Note that if there would be multiple `https://developer.android.com/reference/kotlin/androidx/compose/ui/zIndex.modifier#(androidx.compose.ui.Modifier).zIndex(kotlin.Float)` modifiers applied for the same layout the sum of their values will be used as the final zIndex. If no `https://developer.android.com/reference/kotlin/androidx/compose/ui/zIndex.modifier#(androidx.compose.ui.Modifier).zIndex(kotlin.Float)` were applied for the layout then the default zIndex is 0.

```kotlin
import androidx.compose.foundation.layout.Box
import androidx.compose.material3.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.zIndex

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