<h2 id="updatetransition-targetstate-label">updateTransition</h2>

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

```kotlin
@Composable
public fun <T> updateTransition(targetState: T, label: String? = null): Transition<T>
```

This sets up a [Transition](/jetpack-compose/androidx.compose.animation/animation-core/classes/Transition), and updates it with the target provided by `targetState`. When
`targetState` changes, [Transition](/jetpack-compose/androidx.compose.animation/animation-core/classes/Transition) will run all of its child animations towards their target
values specified for the new `targetState`. Child animations can be dynamically added using
[Transition.animateFloat], [animateColor][ androidx.compose.animation.animateColor],
[Transition.animateValue], etc.

[label](/jetpack-compose/androidx.compose.material3/material3/components/Label) is used to differentiate different transitions in Android Studio.

__Note__: There is another [rememberTransition](/jetpack-compose/androidx.compose.animation/animation-core/composable-functions/rememberTransition) overload that accepts a [MutableTransitionState](/jetpack-compose/androidx.compose.animation/animation-core/classes/MutableTransitionState).
The difference between the two is that the [MutableTransitionState](/jetpack-compose/androidx.compose.animation/animation-core/classes/MutableTransitionState) variant: 1) supports a
different initial state than target state (This would allow a transition to start as soon as it
enters composition.) 2) can be recreated to intentionally trigger a re-start of the transition.

#### Returns

| | |
| --- | --- |
|  | a [Transition](/jetpack-compose/androidx.compose.animation/animation-core/classes/Transition) object, to which animations can be added. |

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

> **Deprecated** Use rememberTransition() instead

<hr class="docs-overload-divider">

<h2 id="updatetransition-transitionstate-label">updateTransition</h2>

```kotlin
@Composable
public fun <T> updateTransition(
    transitionState: MutableTransitionState<T>,
    label: String? = null,
): Transition<T>
```

Creates a [Transition](/jetpack-compose/androidx.compose.animation/animation-core/classes/Transition) and puts it in the [currentState][MutableTransitionState.currentState] of
the provided [transitionState](/jetpack-compose/androidx.compose.animation/animation-core/classes/TransitionState). Whenever the [targetState][MutableTransitionState.targetState] of
the [transitionState](/jetpack-compose/androidx.compose.animation/animation-core/classes/TransitionState) changes, the [Transition](/jetpack-compose/androidx.compose.animation/animation-core/classes/Transition) will animate to the new target state.

__Remember__: The provided [transitionState](/jetpack-compose/androidx.compose.animation/animation-core/classes/TransitionState) needs to be [remember](/jetpack-compose/androidx.compose.runtime/runtime/composable-functions/remember)ed.

Compared to the [rememberTransition](/jetpack-compose/androidx.compose.animation/animation-core/composable-functions/rememberTransition) variant that takes a targetState, this function supports a
different initial state than the first targetState. Here is an example:

In most cases, it is recommended to reuse the same [transitionState](/jetpack-compose/androidx.compose.animation/animation-core/classes/TransitionState) that is [remember](/jetpack-compose/androidx.compose.runtime/runtime/composable-functions/remember)ed, such
that [Transition](/jetpack-compose/androidx.compose.animation/animation-core/classes/Transition) preserves continuity when [targetState][MutableTransitionState.targetState] is
changed. However, in some rare cases it is more critical to immediately *snap* to a state change
(e.g. in response to a user interaction). This can be achieved by creating a new
[transitionState](/jetpack-compose/androidx.compose.animation/animation-core/classes/TransitionState):