# MotionLayoutScope

Artifact: [androidx.constraintlayout:constraintlayout-compose](https://developer.android.com/jetpack/androidx/releases/constraintlayout) [View Source](https://cs.android.com/search?q=file:androidx/constraintlayout/compose/MotionLayout.kt+class:androidx.constraintlayout.compose.MotionLayoutScope) Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)


```
@ExperimentalMotionApi
@LayoutScopeMarker
class MotionLayoutScope
```

<br />

*** ** * ** ***

## Summary

| ### Nested types |
|---|
| `inner class https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope.CustomProperties` |
| `inner class https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope.MotionProperties` |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customColor(kotlin.String,kotlin.String)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Return the current `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` value of the custom property `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customColor(kotlin.String,kotlin.String)`, of the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customColor(kotlin.String,kotlin.String)` layout. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customDistance(kotlin.String,kotlin.String)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Return the current `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` value of the custom property `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customDistance(kotlin.String,kotlin.String)`, of the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customDistance(kotlin.String,kotlin.String)` layout. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customFloat(kotlin.String,kotlin.String)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Return the current `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` value of the custom property `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customFloat(kotlin.String,kotlin.String)`, of the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customFloat(kotlin.String,kotlin.String)` layout. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customFontSize(kotlin.String,kotlin.String)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Return the current `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` value of the custom property `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customFontSize(kotlin.String,kotlin.String)`, of the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customFontSize(kotlin.String,kotlin.String)` layout. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customInt(kotlin.String,kotlin.String)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Return the current `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` value of the custom property `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customInt(kotlin.String,kotlin.String)`, of the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customInt(kotlin.String,kotlin.String)` layout. |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope.CustomProperties` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customProperties(kotlin.String)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Returns a `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope.CustomProperties` instance to access the values of custom properties defined for `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customProperties(kotlin.String)` in different return types: Color, Float, Int, Dp, TextUnit. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `[motionColor](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#motionColor(kotlin.String,kotlin.String))(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` **This function is deprecated.** Deprecated for naming consistency |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` | `[motionDistance](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#motionDistance(kotlin.String,kotlin.String))(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` **This function is deprecated.** Deprecated for naming consistency |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `[motionFloat](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#motionFloat(kotlin.String,kotlin.String))(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` **This function is deprecated.** Deprecated for naming consistency |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` | `[motionFontSize](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#motionFontSize(kotlin.String,kotlin.String))(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` **This function is deprecated.** Deprecated for naming consistency |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `[motionInt](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#motionInt(kotlin.String,kotlin.String))(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` **This function is deprecated.** Deprecated for naming consistency |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope.MotionProperties>` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable [motionProperties](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#motionProperties(kotlin.String))(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` **This function is deprecated.** Unnecessary composable, name is also inconsistent for custom properties |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope.MotionProperties` | `[motionProperties](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#motionProperties(kotlin.String,kotlin.String))(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` **This function is deprecated.** Deprecated for naming consistency |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#(androidx.compose.ui.Modifier).onStartEndBoundsChanged(kotlin.Any,kotlin.Function2)( layoutId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html, onBoundsChanged: (startBounds: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect, endBounds: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Invokes `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#(androidx.compose.ui.Modifier).onStartEndBoundsChanged(kotlin.Any,kotlin.Function2)` whenever the Start or End bounds may have changed for the Composable corresponding to the given `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#(androidx.compose.ui.Modifier).onStartEndBoundsChanged(kotlin.Any,kotlin.Function2)` during positioning. |

## Public functions

### customColor

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
fun customColor(id: String, name: String): Color
```

Return the current `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` value of the custom property `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customColor(kotlin.String,kotlin.String)`, of the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customColor(kotlin.String,kotlin.String)` layout.

Returns `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Unspecified()` if the property does not exist.

This is a short version of: `customProperties(id).color(name)`.

### customDistance

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
fun customDistance(id: String, name: String): Dp
```

Return the current `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` value of the custom property `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customDistance(kotlin.String,kotlin.String)`, of the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customDistance(kotlin.String,kotlin.String)` layout.

Returns `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp#Unspecified()` if the property does not exist.

This is a short version of: `customProperties(id).distance(name)`.

### customFloat

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
fun customFloat(id: String, name: String): Float
```

Return the current `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` value of the custom property `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customFloat(kotlin.String,kotlin.String)`, of the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customFloat(kotlin.String,kotlin.String)` layout.

Returns `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Unspecified()` if the property does not exist.

This is a short version of: `customProperties(id).float(name)`.

### customFontSize

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
fun customFontSize(id: String, name: String): TextUnit
```

Return the current `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` value of the custom property `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customFontSize(kotlin.String,kotlin.String)`, of the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customFontSize(kotlin.String,kotlin.String)` layout.

Returns `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit#Unspecified()` if the property does not exist.

This is a short version of: `customProperties(id).fontSize(name)`.

### customInt

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
fun customInt(id: String, name: String): Int
```

Return the current `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` value of the custom property `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customInt(kotlin.String,kotlin.String)`, of the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customInt(kotlin.String,kotlin.String)` layout.

Returns `0` if the property does not exist.

This is a short version of: `customProperties(id).int(name)`.

### customProperties

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
fun customProperties(id: String): MotionLayoutScope.CustomProperties
```

Returns a `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope.CustomProperties` instance to access the values of custom properties defined for `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#customProperties(kotlin.String)` in different return types: Color, Float, Int, Dp, TextUnit.

Note that there are no type guarantees when setting or getting custom properties, so be mindful of the value type used for it in the MotionScene.

### motionColor

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2) Deprecated in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
fun [motionColor](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#motionColor(kotlin.String,kotlin.String))(id: String, name: String): Color
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated for naming consistency, use this instead:
>
> ```kotlin
> customColor(id, name)
> ```

### motionDistance

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2) Deprecated in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
fun [motionDistance](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#motionDistance(kotlin.String,kotlin.String))(id: String, name: String): Dp
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated for naming consistency, use this instead:
>
> ```kotlin
> customDistance(id, name)
> ```

### motionFloat

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2) Deprecated in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
fun [motionFloat](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#motionFloat(kotlin.String,kotlin.String))(id: String, name: String): Float
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated for naming consistency, use this instead:
>
> ```kotlin
> customFloat(id, name)
> ```

### motionFontSize

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2) Deprecated in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
fun [motionFontSize](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#motionFontSize(kotlin.String,kotlin.String))(id: String, name: String): TextUnit
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated for naming consistency, use this instead:
>
> ```kotlin
> customFontSize(id, name)
> ```

### motionInt

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2) Deprecated in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
fun [motionInt](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#motionInt(kotlin.String,kotlin.String))(id: String, name: String): Int
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated for naming consistency, use this instead:
>
> ```kotlin
> customInt(id, name)
> ```

### motionProperties

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2) Deprecated in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
@Composable
fun [motionProperties](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#motionProperties(kotlin.String))(id: String): State<MotionLayoutScope.MotionProperties>
```

> [!CAUTION]
> **This function is deprecated.**   
> Unnecessary composable, name is also inconsistent for custom properties, use this instead:
>
> ```kotlin
> customProperties(id)
> ```

### motionProperties

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2) Deprecated in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
fun [motionProperties](https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#motionProperties(kotlin.String,kotlin.String))(id: String, tag: String): MotionLayoutScope.MotionProperties
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated for naming consistency, use this instead:
>
> ```kotlin
> customProperties(id)
> ```

### Modifier.onStartEndBoundsChanged

Artifact: [androidx.constraintlayout:constraintlayout-compose](https://developer.android.com/jetpack/androidx/releases/constraintlayout) [View Source](https://cs.android.com/search?q=file:androidx/constraintlayout/compose/MotionLayout.kt+function:onStartEndBoundsChanged) Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
fun Modifier.onStartEndBoundsChanged(
    layoutId: Any,
    onBoundsChanged: (startBounds: Rect, endBounds: Rect) -> Unit
): Modifier
```

Invokes `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#(androidx.compose.ui.Modifier).onStartEndBoundsChanged(kotlin.Any,kotlin.Function2)` whenever the Start or End bounds may have changed for the Composable corresponding to the given `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#(androidx.compose.ui.Modifier).onStartEndBoundsChanged(kotlin.Any,kotlin.Function2)` during positioning. This may happen if the current Transition for `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayout.composable#MotionLayout(androidx.constraintlayout.compose.ConstraintSet,androidx.constraintlayout.compose.ConstraintSet,kotlin.Float,androidx.compose.ui.Modifier,androidx.constraintlayout.compose.Transition,androidx.constraintlayout.compose.DebugFlags,kotlin.Int,androidx.constraintlayout.compose.InvalidationStrategy,kotlin.Function1)` changes.

`https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayoutScope#(androidx.compose.ui.Modifier).onStartEndBoundsChanged(kotlin.Any,kotlin.Function2)` will be invoked at least once when the content is placed the first time.

Use this `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` instead of `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/onGloballyPositioned.modifier#(androidx.compose.ui.Modifier).onGloballyPositioned(kotlin.Function1)` if you wish to keep track of Composable bounds while ignoring their positioning during animation. Such as when implementing DragAndDrop logic.