# AnimateStyleScope

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

  ```
  @ExperimentalFoundationStyleApi
  interface AnimateStyleScope
  ```
Known direct subclasses [CommonStyleScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/CommonStyleScope), [StyleScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleScope)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/CommonStyleScope` | A `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/CommonStyleScope` is the scope used by a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/CommonStyle`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleScope` | A `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleScope` is the receiver scope of a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/Style` lambda. |

*** ** * ** ***

An interface that introduces `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/AnimateStyleScope#animate(androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec,kotlin.Function0)` functions to a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/Style` receiver scope.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleScope` |   |

## Summary

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/AnimateStyleScope#animate(androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec,kotlin.Function0)( toSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>, fromSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>, block: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Specifies a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/Style` whose properties will be animated to when they change, using the provided `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec`. | Cmn |

| ### Extension functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/ExperimentalFoundationStyleApi https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/AnimateStyleScope.https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/AnimateStyleScope#(androidx.compose.foundation.style.AnimateStyleScope).animate(kotlin.Function0)(block: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Specifies a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/Style` whose properties will be animated to when they change. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/ExperimentalFoundationStyleApi https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/AnimateStyleScope.https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/AnimateStyleScope#(androidx.compose.foundation.style.AnimateStyleScope).animate(androidx.compose.animation.core.AnimationSpec,kotlin.Function0)(spec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>, block: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Specifies a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/Style` whose properties will be animated to when they change, using the provided `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec`. | Cmn |

## Public functions

### animate

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

```
fun animate(
    toSpec: AnimationSpec<Float>,
    fromSpec: AnimationSpec<Float>,
    block: () -> Unit
): Unit
```

Specifies a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/Style` whose properties will be animated to when they change, using the provided `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec`. This allows for smooth transitions between style states with custom animation curves.

| Parameters |
|---|---|
| `toSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>` | The `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec` to use for the animation to the values set in `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/AnimateStyleScope#animate(androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec,kotlin.Function0)`. This animation is used when the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/AnimateStyleScope#animate(androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec,kotlin.Function0)` call is added to the style. |
| `fromSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>` | The `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec` to use for the animation from the values set in `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/AnimateStyleScope#animate(androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec,kotlin.Function0)`. This animation is used when the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/AnimateStyleScope#animate(androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec,kotlin.Function0)` call is removed from the style. |
| `block: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The block containing the properties values to animate |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/Style` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec` |   |

## Extension functions

### AnimateStyleScope.animate

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/StyleScope.kt+function:animate)

```
@ExperimentalFoundationStyleApi
fun AnimateStyleScope.animate(block: () -> Unit): Unit
```

Specifies a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/Style` whose properties will be animated to when they change. This uses a default animation specification. This allows for smooth transitions between style states without manual animation setup. A `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#spring(kotlin.Float,kotlin.Float,kotlin.Any)` will be used for the animation for both animating to and from the style.

| Parameters |
|---|---|
| `block: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The target `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/Style` whose properties should be animated. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/Style` |   |

### AnimateStyleScope.animate

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/StyleScope.kt+function:animate)

```
@ExperimentalFoundationStyleApi
fun AnimateStyleScope.animate(spec: AnimationSpec<Float>, block: () -> Unit): Unit
```

Specifies a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/Style` whose properties will be animated to when they change, using the provided `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec`. This allows for smooth transitions between style states with custom animation curves. The same animation `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/package-summary#(androidx.compose.foundation.style.AnimateStyleScope).animate(androidx.compose.animation.core.AnimationSpec,kotlin.Function0)` will be used for animating both to and from the style.

| Parameters |
|---|---|
| `spec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>` | The `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec` to use for the animation. |
| `block: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The target `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/Style` whose properties should be animated. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/Style` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec` |   |