---
title: "CompositionLocalConsumerModifierNode"
description: "Implementing this interface allows your [Modifier.Node] subclass to read
[CompositionLocals][CompositionLocal] via the [currentValueOf] function. The values of each
CompositionLocal will be resolved based on the context of the layout node that the modifier is
attached to, meaning that the modifier will see the same values of each CompositionLocal as its
corresponding layout node."
type: "interface"
---

<div class='type'>Interface</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>



```kotlin
interface CompositionLocalConsumerModifierNode : DelegatableNode
```


Implementing this interface allows your `Modifier.Node` subclass to read
`CompositionLocals` via the `currentValueOf` function. The values of each
CompositionLocal will be resolved based on the context of the layout node that the modifier is
attached to, meaning that the modifier will see the same values of each CompositionLocal as its
corresponding layout node.



## Code Examples

### CompositionLocalConsumingModifierSample
```kotlin
@Composable
fun CompositionLocalConsumingModifierSample() {
    val localBackgroundColor = compositionLocalOf { Color.White }
    class BackgroundColor :
        Modifier.Node(), DrawModifierNode, CompositionLocalConsumerModifierNode {
        override fun ContentDrawScope.draw() {
            val backgroundColor = currentValueOf(localBackgroundColor)
            drawRect(backgroundColor)
            drawContent()
        }
    }
    val backgroundColorElement =
        object : ModifierNodeElement<BackgroundColor>() {
            override fun create() = BackgroundColor()
            override fun update(node: BackgroundColor) {}
            override fun hashCode() = System.identityHashCode(this)
            override fun equals(other: Any?) = (other === this)
            override fun InspectorInfo.inspectableProperties() {
                name = "backgroundColor"
            }
        }
    fun Modifier.backgroundColor() = this then backgroundColorElement
    Box(Modifier.backgroundColor()) { Text("Hello, world!") }
}
```

