# rememberUpdatedStyleState

Common/All

## Functions summary

|---|---|---|
| `inline https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleState` | `@https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/ExperimentalFoundationStyleApi @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/rememberUpdatedStyleState.composable#rememberUpdatedStyleState(androidx.compose.foundation.interaction.InteractionSource,kotlin.Function1)( interactionSource: https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource?, block: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable (https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/MutableStyleState) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Create, remember and update a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleState` for use as a parameter of a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/styleable.modifier#(androidx.compose.ui.Modifier).styleable(androidx.compose.foundation.style.StyleState,androidx.compose.foundation.style.Style)` modifier. | Cmn |

## Functions

### rememberUpdatedStyleState

Cmn Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/style/StyleState.kt+function:rememberUpdatedStyleState)

```
@ExperimentalFoundationStyleApi
@Composable
inline fun rememberUpdatedStyleState(
    interactionSource: InteractionSource?,
    block: @Composable (MutableStyleState) -> Unit = {}
): StyleState
```

Create, remember and update a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleState` for use as a parameter of a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/styleable.modifier#(androidx.compose.ui.Modifier).styleable(androidx.compose.foundation.style.StyleState,androidx.compose.foundation.style.Style)` modifier.

```kotlin
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.style.Style
import androidx.compose.foundation.style.disabled
import androidx.compose.foundation.style.hovered
import androidx.compose.foundation.style.pressed
import androidx.compose.foundation.style.rememberUpdatedStyleState
import androidx.compose.foundation.style.size
import androidx.compose.foundation.style.styleable
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

// Create a styleable clickable box
@Composable
fun ClickableStyleableBox(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    style: Style = Style,
    enabled: Boolean = true,
) {
    val interactionSource = remember { MutableInteractionSource() }
    val styleState = rememberUpdatedStyleState(interactionSource) { it.isEnabled = enabled }
    Box(
        modifier =
            modifier
                .clickable(interactionSource = interactionSource, onClick = onClick)
                .styleable(styleState, style)
    )
}

// Create a 150x150 green box that is clickable
ClickableStyleableBox(
    onClick = {},
    style = {
        background(Color.Green)
        size(150.dp)
        hovered { background(Color.Yellow) }
        pressed { background(Color.Red) }
        disabled { background(Color.Gray) }
    },
)
```

| Parameters |
|---|---|
| `interactionSource: https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource?` | the interaction source to observe for the style state. |
| `block: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable (https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/MutableStyleState) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html = {}` | a lambda that will initializes or updates the style state. |