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

```kotlin
public object SpatialTransitions
```

Public transition spec APIs for use with [AnimatedSpatialVisibility](/jetpack-compose/androidx.xr.compose/compose/composable-functions/AnimatedSpatialVisibility).

## Functions

<h2 id="fadein-animationspec-initialalpha">fadeIn</h2>

```kotlin
public fun fadeIn(
        animationSpec: FiniteAnimationSpec<Float> =
            SpatialTransitionDefaults.DefaultAlphaAnimationSpec,
        initialAlpha: Float = 0f,
    ): SpatialEnterTransition
```

This fades in the content of the transition, from the specified starting alpha (i.e.
`initialAlpha`) to 1f, using the supplied [animationSpec](/jetpack-compose/androidx.compose.animation/animation-core/interfaces/AnimationSpec). `initialAlpha` defaults to 0f, and
[spring](/jetpack-compose/androidx.compose.animation/animation-core/objects/Spring) is used by default.

#### Parameters

| | |
| --- | --- |
| animationSpec | the [FiniteAnimationSpec](/jetpack-compose/androidx.compose.animation/animation-core/interfaces/FiniteAnimationSpec) for this animation, [spring](/jetpack-compose/androidx.compose.animation/animation-core/objects/Spring) by default |
| initialAlpha | the starting alpha of the enter transition, 0f by default |

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

<h2 id="fadeout-animationspec-targetalpha">fadeOut</h2>

```kotlin
public fun fadeOut(
        animationSpec: FiniteAnimationSpec<Float> =
            SpatialTransitionDefaults.DefaultAlphaAnimationSpec,
        targetAlpha: Float = 0f,
    ): SpatialExitTransition
```

This fades out the content of the transition, from full opacity to the specified target alpha
(i.e. `targetAlpha`), using the supplied [animationSpec](/jetpack-compose/androidx.compose.animation/animation-core/interfaces/AnimationSpec). By default, the content will be
faded out to fully transparent (i.e. `targetAlpha` defaults to 0), and [animationSpec](/jetpack-compose/androidx.compose.animation/animation-core/interfaces/AnimationSpec) uses
[spring](/jetpack-compose/androidx.compose.animation/animation-core/objects/Spring) by default.

#### Parameters

| | |
| --- | --- |
| animationSpec | the [FiniteAnimationSpec](/jetpack-compose/androidx.compose.animation/animation-core/interfaces/FiniteAnimationSpec) for this animation, [spring](/jetpack-compose/androidx.compose.animation/animation-core/objects/Spring) by default |
| targetAlpha | the target alpha of the exit transition, 0f by default |

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

<h2 id="slidein-animationspec-initialoffset">slideIn</h2>

```kotlin
public fun slideIn(
        animationSpec: FiniteAnimationSpec<IntVolumeOffset> =
            SpatialTransitionDefaults.DefaultSlideAnimationSpec,
        initialOffset: Density.(fullSize: IntVolumeSize) -> IntVolumeOffset,
    ): SpatialEnterTransition
```

This slides in the content of the transition, from a starting offset defined in
`initialOffset` to `IntVolumeOffset(0, 0, 0)`. The direction of the slide can be controlled
by configuring the `initialOffset`. A positive x value means sliding from right to left,
whereas a negative x value will slide the content to the right. Similarly positive and
negative y values correspond to sliding up and down, respectively, and positive and negative
z values correspond to sliding closer and further, respectively.

If the sliding is only desired along one axis, consider using [slideInHorizontally](/jetpack-compose/androidx.compose.animation/animation/functions/slideInHorizontally),
[slideInVertically](/jetpack-compose/androidx.compose.animation/animation/functions/slideInVertically), or [slideInDepth](#slideindepth).

`initialOffset` is a lambda that takes the full size of the content and returns an offset.
This allows the offset to be defined proportional to the full size, or as an absolute value.

#### Parameters

| | |
| --- | --- |
| animationSpec | the animation used for the slide-in, [spring](/jetpack-compose/androidx.compose.animation/animation-core/objects/Spring) by default. |
| initialOffset | a lambda that takes the full size of the content and returns the initial offset for the slide-in |

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

<h2 id="slideinhorizontally-animationspec-initialoffsetx">slideInHorizontally</h2>

```kotlin
public fun slideInHorizontally(
        animationSpec: FiniteAnimationSpec<IntVolumeOffset> =
            SpatialTransitionDefaults.DefaultSlideAnimationSpec,
        initialOffsetX: Density.(fullWidth: Int) -> Int = { -it / 2 },
    ): SpatialEnterTransition
```

This slides in the content horizontally, from a starting offset defined in `initialOffsetX`
to `0` **pixels**. The direction of the slide can be controlled by configuring the
`initialOffsetX`. A positive value means sliding from right to left, whereas a negative value
would slide the content from left to right.

`initialOffsetX` is a lambda that takes the full width of the content and returns an offset.
This allows the starting offset to be defined proportional to the full size, or as an
absolute value. It defaults to return half of negative width, which would offset the content
to the left by half of its width, and slide towards the right.

#### Parameters

| | |
| --- | --- |
| animationSpec | the animation used for the slide-in, [spring](/jetpack-compose/androidx.compose.animation/animation-core/objects/Spring) by default. |
| initialOffsetX | a lambda that takes the full width of the content in pixels and returns the initial offset for the slide-in, by default it returns `-fullWidth/2` |

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

<h2 id="slideinvertically-animationspec-initialoffsety">slideInVertically</h2>

```kotlin
public fun slideInVertically(
        animationSpec: FiniteAnimationSpec<IntVolumeOffset> =
            SpatialTransitionDefaults.DefaultSlideAnimationSpec,
        initialOffsetY: Density.(fullHeight: Int) -> Int = { -it / 2 },
    ): SpatialEnterTransition
```

This slides in the content vertically, from a starting offset defined in `initialOffsetY` to
`0` **pixels**. The direction of the slide can be controlled by configuring the
`initialOffsetY`. A positive value means sliding from top to bottom, whereas a negative value
would slide the content from bottom to top.

`initialOffsetY` is a lambda that takes the full height of the content and returns an offset.
This allows the starting offset to be defined proportional to the full size, or as an
absolute value. It defaults to return half of negative height, which would offset the content
down by half of its height, and slide upwards.

#### Parameters

| | |
| --- | --- |
| animationSpec | the animation used for the slide-in, [spring](/jetpack-compose/androidx.compose.animation/animation-core/objects/Spring) by default. |
| initialOffsetY | a lambda that takes the full height of the content in pixels and returns the initial offset for the slide-in, by default it returns `-fullHeight/2` |

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

<h2 id="slideindepth-animationspec-initialoffsetz">slideInDepth</h2>

```kotlin
public fun slideInDepth(
        animationSpec: FiniteAnimationSpec<IntVolumeOffset> =
            SpatialTransitionDefaults.DefaultSlideAnimationSpec,
        initialOffsetZ: Density.(fullDepth: Int) -> Int = { -20.dp.roundToPx() },
    ): SpatialEnterTransition
```

This slides in the content depthwise, from a starting offset defined in `initialOffsetZ` to
`0` **pixels**. The direction of the slide can be controlled by configuring the
`initialOffsetZ`. A positive value means sliding from close to far, whereas a negative value
would slide the content from far to close.

`initialOffsetZ` is a lambda that takes the full depth of the content and returns an offset.
This allows the starting offset to be defined proportional to the full size, or as an
absolute value.

Unlike [slideInVertically](/jetpack-compose/androidx.compose.animation/animation/functions/slideInVertically) and [slideInHorizontally](/jetpack-compose/androidx.compose.animation/animation/functions/slideInHorizontally), this defaults to sliding in from `20dp`
**away** from the neutral depth point. This is because many commonly-animated Spatial
elements, such as `SpatialPanel`, report a depth of 0.

#### Parameters

| | |
| --- | --- |
| animationSpec | the animation used for the slide-in, [spring](/jetpack-compose/androidx.compose.animation/animation-core/objects/Spring) by default. |
| initialOffsetZ | a lambda that takes the full height of the content in pixels and returns the initial offset for the slide-in, by default it returns `-20.dp.toPx()` |

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

<h2 id="slideout-animationspec-targetoffset">slideOut</h2>

```kotlin
public fun slideOut(
        animationSpec: FiniteAnimationSpec<IntVolumeOffset> =
            SpatialTransitionDefaults.DefaultSlideAnimationSpec,
        targetOffset: Density.(fullSize: IntVolumeSize) -> IntVolumeOffset,
    ): SpatialExitTransition
```

This slides out the content of the transition, from an offset of `IntVolumeOffset(0, 0, 0)`
to the target offset defined in `targetOffset`. The direction of the slide can be controlled
by configuring the `targetOffset`. A positive x value means sliding from left to right,
whereas a negative x value would slide the content from right to left. Similarly, positive
and negative y values correspond to sliding down and up, respectively, and positive and
negative z values correspond to sliding closer and further, respectively.

If the sliding is only desired along one axis, consider using [slideOutHorizontally](/jetpack-compose/androidx.compose.animation/animation/functions/slideOutHorizontally),
[slideOutVertically](/jetpack-compose/androidx.compose.animation/animation/functions/slideOutVertically), or [slideOutDepth](#slideoutdepth).

`targetOffset` is a lambda that takes the full size of the content and returns an offset.
This allows the offset to be defined proportional to the full size, or as an absolute value.

#### Parameters

| | |
| --- | --- |
| animationSpec | the animation used for the slide-out, [spring](/jetpack-compose/androidx.compose.animation/animation-core/objects/Spring) by default. |
| targetOffset | a lambda that takes the full size of the content and returns the target offset for the slide-out |

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

<h2 id="slideouthorizontally-animationspec-targetoffsetx">slideOutHorizontally</h2>

```kotlin
public fun slideOutHorizontally(
        animationSpec: FiniteAnimationSpec<IntVolumeOffset> =
            SpatialTransitionDefaults.DefaultSlideAnimationSpec,
        targetOffsetX: Density.(fullWidth: Int) -> Int = { -it / 2 },
    ): SpatialExitTransition
```

This slides out the content horizontally, from 0 to a target offset defined in
`targetOffsetX` in **pixels**. The direction of the slide can be controlled by configuring
the `targetOffsetX`. A positive value means sliding to the right, whereas a negative value
would slide the content towards the left.

`targetOffsetX` is a lambda that takes the full width of the content and returns an offset.
This allows the target offset to be defined proportional to the full size, or as an absolute
value. It defaults to return half of negative width, which would slide the content to the
left by half of its width.

#### Parameters

| | |
| --- | --- |
| animationSpec | the animation used for the slide-out, [spring](/jetpack-compose/androidx.compose.animation/animation-core/objects/Spring) by default. |
| targetOffsetX | a lambda that takes the full width of the content and returns the initial offset for the slide-in, by default it returns `fullWidth/2` |

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

<h2 id="slideoutvertically-animationspec-targetoffsety">slideOutVertically</h2>

```kotlin
public fun slideOutVertically(
        animationSpec: FiniteAnimationSpec<IntVolumeOffset> =
            SpatialTransitionDefaults.DefaultSlideAnimationSpec,
        targetOffsetY: Density.(fullHeight: Int) -> Int = { -it / 2 },
    ): SpatialExitTransition
```

This slides out the content vertically, from 0 to a target offset defined in `targetOffsetY`
in **pixels**. The direction of the slide-out can be controlled by configuring the
`targetOffsetY`. A positive target offset means sliding down, whereas a negative value would
slide the content up.

`targetOffsetY` is a lambda that takes the full Height of the content and returns an offset.
This allows the target offset to be defined proportional to the full height, or as an
absolute value. It defaults to return half of the negative height, which would slide the
content up by half of its Height.

#### Parameters

| | |
| --- | --- |
| animationSpec | the animation used for the slide-out, [spring](/jetpack-compose/androidx.compose.animation/animation-core/objects/Spring) by default. |
| targetOffsetY | a lambda that takes the full Height of the content and returns the target offset for the slide-out, by default it returns `fullHeight/2` |

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

<h2 id="slideoutdepth-animationspec-targetoffsetz">slideOutDepth</h2>

```kotlin
public fun slideOutDepth(
        animationSpec: FiniteAnimationSpec<IntVolumeOffset> =
            SpatialTransitionDefaults.DefaultSlideAnimationSpec,
        targetOffsetZ: Density.(fullDepth: Int) -> Int = { -20.dp.roundToPx() },
    ): SpatialExitTransition
```

This slides out the content depthwise, from 0 to a target offset defined in `targetOffsetZ`
in **pixels**. The direction of the slide-out can be controlled by configuring the
`targetOffsetZ`. A positive value means sliding from close to far, whereas a negative value
would slide the content from far to close.

`targetOffsetZ` is a lambda that takes the full depth of the content and returns an offset.
This allows the target offset to be defined proportional to the full depth, or as an absolute
value.

Unlike [slideInVertically](/jetpack-compose/androidx.compose.animation/animation/functions/slideInVertically) and [slideInHorizontally](/jetpack-compose/androidx.compose.animation/animation/functions/slideInHorizontally), this defaults to sliding in from `20dp`
**away** from the neutral depth point. This is because many commonly-animated Spatial
elements, such as `SpatialPanel`, report a depth of 0.

#### Parameters

| | |
| --- | --- |
| animationSpec | the animation used for the slide-out, [spring](/jetpack-compose/androidx.compose.animation/animation-core/objects/Spring) by default. |
| targetOffsetZ | a lambda that takes the full depth of the content and returns the target offset for the slide-out, by default it returns `-20.dp.toPx()` |