Compose Unstyled 2.0 is out! Check the official announcement blog ->
Composable Function

DeferredAnimatedVisibility

AnimatedVisibility can be used to animate the appearance and disappearance of its content as the Transition state changes.

DeferredAnimatedVisibility

Source set: Common
@ExperimentalDeferredTransitionApi
@Composable
public fun <T> DeferredTransition<T>.DeferredAnimatedVisibility(
    visible: (T) -> Boolean,
    modifier: Modifier = Modifier,
    enter: EnterTransition = fadeIn() + expandIn(),
    exit: ExitTransition = shrinkOut() + fadeOut(),
    mutableTransform: MutableTransform? = null,
    content: @Composable() AnimatedVisibilityScope.() -> Unit,
)

AnimatedVisibility can be used to animate the appearance and disappearance of its content as the Transition state changes.

visible defines whether the content should be visible based on transition state T.

modifier modifier for the Layout created to contain the content

enter EnterTransition(s) used for the appearing animation, fading in while expanding vertically by default

exit ExitTransition(s) used for the disappearing animation, fading out while shrinking vertically by default

mutableTransform A block to control the visual transformations during the deferred phase (e.g., for predictive back gestures) before the main transition begins. This is only active if the Transition was created using rememberTransition with DeferredTransitionState. By default, this is null, meaning no manual transformations are applied. This phase starts when DeferredTransitionState.defer is called and ends when DeferredTransitionState.animateTo is called to start the automatic transition. During this phase, you can manually manipulate the content's transformations (like TransformScope.alpha and TransformScope.scale). These transformations are applied on top of the transition's initial state. Once the transition starts, the manually applied transformations are seamlessly handed off to the configured enter and exit transitions. For exiting content, a "sustain unless specified" policy is applied: if an exit transition (e.g. fadeOut) is specified, the hand-off will animate towards the target value of that transition. However, if no exit transition is specified for a given property (e.g. slideOut is missing), that property will sustain its last manual value until the entire transition completes. While in the deferred phase, entering content remains in the EnterExitState.PreEnter state, and exiting content remains in the EnterExitState.Visible state.

content Content to appear or disappear based on the visibility derived from the Transition.targetState and the provided visible lambda

Last updated: