# StyleResolver

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/StyleResolver.kt+class:androidx.compose.foundation.style.StyleResolver) Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.13.0-rc01) Common/All
- Cmn

  ```
  @ExperimentalFoundationStyleApi
  class StyleResolver : RememberObserver
  ```

*** ** * ** ***

A resolver that will resolve the properties of a given style lambda. An instance of this should be created and passed to the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/styleResolver.modifier#(androidx.compose.ui.Modifier).styleResolver(androidx.compose.foundation.style.StyleResolver)` modifier which will resolve the style lambda in context.

## Summary

| ### Public constructors |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/annotation/RememberInComposition https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver#StyleResolver(androidx.compose.foundation.style.CommonStyle,androidx.compose.foundation.style.StyleState)(style: https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/CommonStyle, styleState: https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleState)` | Cmn |

| ### Public functions |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver#onAbandoned()()` Implements `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RememberObserver` API to allow composition to manage the lifetime of the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver#onForgotten()()` Implements `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RememberObserver` API to allow composition to manage the lifetime of the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver#onRemembered()()` Implements `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RememberObserver` API to allow composition to manage the lifetime of the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver` | Cmn |
| `inline R` | `<R : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver#resolve(kotlin.Function1)(block: https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolverScope.() -> R)` Asks the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver` to resolve the properties of a given style lambda. | Cmn |

## Public constructors

### StyleResolver

Cmn Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.13.0-rc01)

```
@RememberInComposition
StyleResolver(
    style: CommonStyle,
    styleState: StyleState = MutableStyleState(null)
)
```

| Parameters |
|---|---|
| `style: https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/CommonStyle` | a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/CommonStyle` that will be invoked to resolve the style properties. `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/CustomStyle` types should provide a `toCommonStyle()` extension method that converts the custom style to `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/CommonStyle` to be passed as the value of the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver#style()` parameter. |
| `styleState: https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleState = MutableStyleState(null)` | a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleState` instance that is provided to the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleStateScope` as the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleStateScope#state(androidx.compose.foundation.style.StyleStateKey,kotlin.Function0,kotlin.Function2)` parameter. This allows the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver#style()` to read the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver#styleState()` during resolution to detect, for example, when the component being styled is focused, pressed, hovered, etc. in addition to custom states such as `isPlaying`. |

## Public functions

### onAbandoned

Cmn Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.13.0-rc01)

```
open fun onAbandoned(): Unit
```

Implements `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RememberObserver` API to allow composition to manage the lifetime of the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver`

### onForgotten

Cmn Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.13.0-rc01)

```
open fun onForgotten(): Unit
```

Implements `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RememberObserver` API to allow composition to manage the lifetime of the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver`

### onRemembered

Cmn Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.13.0-rc01)

```
open fun onRemembered(): Unit
```

Implements `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RememberObserver` API to allow composition to manage the lifetime of the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver`

### resolve

Cmn Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.13.0-rc01)

```
inline fun <R : Any?> resolve(block: StyleResolverScope.() -> R): R
```

Asks the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver` to resolve the properties of a given style lambda. The resolved properties can be read in `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver#resolve(kotlin.Function1)`.

| Parameters |
|---|---|
| `block: https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolverScope.() -> R` | called in a scope that allows style properties to be read. |