---
title: "graphicsLayer"
description: "A [Modifier.Node] that makes content draw into a draw layer."
type: "modifier"
lastmod: "2026-09-24"
---
## API Reference

### graphicsLayer

> Source set: Common

```kotlin
public fun Modifier.graphicsLayer(
    layerRequired: (() -> Boolean)? = null,
    block: GraphicsLayerScope.() -> Unit,
): Modifier
```

A `Modifier.Node` that makes content draw into a draw layer. The draw layer can be invalidated
separately from parents. A [graphicsLayer](/jetpack-compose/androidx.compose.foundation/foundation/modifiers/graphicsLayer/api) should be used when the content updates independently
from anything above it to minimize the invalidated content.

[graphicsLayer](/jetpack-compose/androidx.compose.foundation/foundation/modifiers/graphicsLayer/api) can be used to apply effects to content, such as scaling, rotation, opacity,
shadow, and clipping. Prefer this version when you have layer properties backed by a
`androidx.compose.runtime.State` or an animated value as reading a state inside `block` will only
cause the layer properties update without triggering recomposition and relayout.

NOTE: `block` can be invoked multiple times, which is why it's important for performance to
minimize work done inside of it. `block` may also be invoked before effects.

`layerRequired` can be used to avoid creating a layer that will do nothing. The avoids the
overhead of the layer if no properties will be modified from their default value.

#### Parameters

| | |
| --- | --- |
| layerRequired | return whether the layer is required. If the parameter is `null` or `layerRequired` returns `true`, a layer is created. If `layerRequired` returns `false` then the layer is not created and `block` is not invoked. This can be used to determine if a layer is necessary based on the properties that will be set by `block`. |
| block | block on [GraphicsLayerScope](/jetpack-compose/androidx.compose.ui/ui/interfaces/GraphicsLayerScope) where you define the layer properties. |
