---
title: "animationSpec"
description: "Applies an animation specification for shared bounds and visibility transitions to a component."
type: "function"
lastmod: "2026-09-24"
---
## API Reference

### animationSpec

> Source set: Android

```kotlin
public fun RemoteModifier.animationSpec(
    animationId: Int = -1,
    motionSpec: RemoteTweenSpec = remoteTween(),
    visibilitySpec: RemoteTweenSpec = motionSpec,
    enter: RemoteEnterTransition = RemoteEnterTransition.FadeIn,
    exit: RemoteExitTransition = RemoteExitTransition.FadeOut,
): RemoteModifier
```

Applies an animation specification for shared bounds and visibility transitions to a component.

#### Parameters

| | |
| --- | --- |
| animationId | identifier used to match elements for shared transitions (-1 for auto) |
| motionSpec | animation specification for motion/bounds transitions (e.g. [remoteTween](/jetpack-compose/androidx.compose.remote/remote-creation-compose/functions/remoteTween)) |
| visibilitySpec | animation specification for enter/exit visibility transitions |
| enter | transition effect when component enters the layout |
| exit | transition effect when component exits the layout |

### animationSpec

> Source set: Android

```kotlin
public fun RemoteModifier.animationSpec(
    animationId: Int,
    enabled: Boolean,
): RemoteModifier
```

Applies an animation specification to match elements for shared transitions across states.

#### Parameters

| | |
| --- | --- |
| animationId | identifier used to match elements for shared transitions |
| enabled | whether animation transitions are enabled for this component |

### animationSpec

> Source set: Android

```kotlin
public fun RemoteModifier.animationSpec(enabled: Boolean): RemoteModifier
```

Enables or disables animation transitions for this component.

#### Parameters

| | |
| --- | --- |
| enabled | whether animation transitions are enabled for this component |

### animationSpec

> Source set: Android

```kotlin
@Deprecated(
    "Use sharedElement, animateEnterExit, or animationSpec taking RemoteAnimationSpec instead",
    ReplaceWith(
        "sharedElement(key = animationId, spec = remoteTween(motionDuration.toInt()))",
        "androidx.compose.remote.creation.compose.state.remoteTween",
    ),
)
public fun RemoteModifier.animationSpec(
    animationId: Int = -1,
    motionDuration: Float = 300f,
    motionEasingType: Int = GeneralEasing.CUBIC_STANDARD,
    visibilityDuration: Float = motionDuration,
    visibilityEasingType: Int = motionEasingType,
    enterAnimation: ANIMATION = ANIMATION.FADE_IN,
    exitAnimation: ANIMATION = ANIMATION.FADE_OUT,
    enabled: Boolean = true,
): RemoteModifier
```

Applies an animation specification to a component using explicit durations and easing types.
