<div class='sourceset sourceset-android'>Android</div>

```kotlin
public class AnimatedSpatialVisibilityScope
internal constructor(override val transition: Transition<EnterExitState>) :
    AnimatedVisibilityScope
```

This is the scope for the content of [AnimatedSpatialVisibility](/jetpack-compose/androidx.xr.compose/compose/composable-functions/AnimatedSpatialVisibility). In this scope, direct and
indirect children of [AnimatedSpatialVisibility](/jetpack-compose/androidx.xr.compose/compose/composable-functions/AnimatedSpatialVisibility) will be able to define their own enter/exit
transitions using the built-in options via [SubspaceModifier.animateEnterExit](/jetpack-compose/androidx.xr.compose/compose/interfaces/SubspaceModifier). They will also be
able define custom enter/exit animations using the [transition](/jetpack-compose/androidx.compose.animation/animation-core/classes/Transition) object.
[AnimatedSpatialVisibility](/jetpack-compose/androidx.xr.compose/compose/composable-functions/AnimatedSpatialVisibility) will ensure both custom and built-in enter/exit animations finish
before it considers itself idle, and subsequently removes its content in the case of exit.

__Note:__ Custom enter/exit animations that are created *independent* of the
[AnimatedSpatialVisibilityScope.transition](/jetpack-compose/androidx.xr.compose/compose/classes/AnimatedSpatialVisibilityScope) will have no guarantee to finish when exiting, as
[AnimatedSpatialVisibility](/jetpack-compose/androidx.xr.compose/compose/composable-functions/AnimatedSpatialVisibility) would have no visibility of such animations.

## Functions

<h2 id="animateenterexit-enter-exit">animateEnterExit</h2>

```kotlin
@Composable
public fun SubspaceModifier.animateEnterExit(
    enter: SpatialEnterTransition = SpatialTransitionDefaults.DefaultEnter,
    exit: SpatialExitTransition = SpatialTransitionDefaults.DefaultExit,
): SubspaceModifier
```