---
title: "movableContentOf"
description: "Convert a lambda into one that moves the remembered state and nodes created in a previous call to
the new location it is called.

Tracking compositions can be used to produce a composable that moves its content between a row
and a column based on a parameter, such as,


Or they can be used to ensure the composition state tracks with a model as moves in the layout,
such as,"
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
@RememberInComposition
public fun movableContentOf(content: @Composable () -> Unit): @Composable () -> Unit
```


Convert a lambda into one that moves the remembered state and nodes created in a previous call to
the new location it is called.

Tracking compositions can be used to produce a composable that moves its content between a row
and a column based on a parameter, such as,


Or they can be used to ensure the composition state tracks with a model as moves in the layout,
such as,

#### Parameters

| | |
| --- | --- |
| content | The composable lambda to convert into a state tracking lambda. |


#### Returns

| | |
| --- | --- |
|  | A tracking composable lambda |




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


```kotlin
@RememberInComposition
public fun <P> movableContentOf(content: @Composable (P) -> Unit): @Composable (P) -> Unit
```


Convert a lambda into one that moves the remembered state and nodes created in a previous call to
the new location it is called.

Tracking compositions can be used to produce a composable that moves its content between a row
and a column based on a parameter, such as,


Or they can be used to ensure the composition state tracks with a model as moves in the layout,
such as,

#### Parameters

| | |
| --- | --- |
| content | The composable lambda to convert into a state tracking lambda. |


#### Returns

| | |
| --- | --- |
|  | A tracking composable lambda |




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


```kotlin
@RememberInComposition
public fun <P1, P2> movableContentOf(
    content: @Composable (P1, P2) -> Unit
): @Composable (P1, P2) -> Unit
```


Convert a lambda into one that moves the remembered state and nodes created in a previous call to
the new location it is called.

Tracking compositions can be used to produce a composable that moves its content between a row
and a column based on a parameter, such as,


Or they can be used to ensure the composition state tracks with a model as moves in the layout,
such as,

#### Parameters

| | |
| --- | --- |
| content | The composable lambda to convert into a state tracking lambda. |


#### Returns

| | |
| --- | --- |
|  | A tracking composable lambda |




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


```kotlin
@RememberInComposition
public fun <P1, P2, P3> movableContentOf(
    content: @Composable (P1, P2, P3) -> Unit
): @Composable (P1, P2, P3) -> Unit
```


Convert a lambda into one that moves the remembered state and nodes created in a previous call to
the new location it is called.

Tracking compositions can be used to produce a composable that moves its content between a row
and a column based on a parameter, such as,


Or they can be used to ensure the composition state tracks with a model as moves in the layout,
such as,

#### Parameters

| | |
| --- | --- |
| content | The composable lambda to convert into a state tracking lambda. |


#### Returns

| | |
| --- | --- |
|  | A tracking composable lambda |




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


```kotlin
@RememberInComposition
public fun <P1, P2, P3, P4> movableContentOf(
    content: @Composable (P1, P2, P3, P4) -> Unit
): @Composable (P1, P2, P3, P4) -> Unit
```


Convert a lambda into one that moves the remembered state and nodes created in a previous call to
the new location it is called.

Tracking compositions can be used to produce a composable that moves its content between a row
and a column based on a parameter, such as,


Or they can be used to ensure the composition state tracks with a model as moves in the layout,
such as,

#### Parameters

| | |
| --- | --- |
| content | The composable lambda to convert into a state tracking lambda. |


#### Returns

| | |
| --- | --- |
|  | A tracking composable lambda |




## Code Examples
### MovableContentColumnRowSample
```kotlin
@Suppress("unused")
@Composable
fun MovableContentColumnRowSample(content: @Composable () -> Unit, vertical: Boolean) {
    val movableContent = remember(content) { movableContentOf(content) }
    if (vertical) {
        Column { movableContent() }
    } else {
        Row { movableContent() }
    }
}
```
### MovableContentMultiColumnSample
```kotlin
@Suppress("unused")
@Composable
fun MovableContentMultiColumnSample(items: List<Item>) {
    val itemMap = remember { mutableMapOf<Item, @Composable () -> Unit>() }
    val movableItems =
        remember(items) {
            val itemsToRemove = itemMap.keys.toMutableSet()
            val movableItems =
                items.map { item ->
                    itemsToRemove.remove(item)
                    itemMap.getOrPut(item) { movableContentOf { ItemView(item) } }
                }
            itemsToRemove.forEach { itemMap.remove(it) }
            movableItems
        }
    val itemsPerColumn = 10
    val columns = items.size / itemsPerColumn + (if (items.size % itemsPerColumn == 0) 0 else 1)
    Row {
        repeat(columns) { column ->
            Column {
                val base = column * itemsPerColumn
                val end = minOf(base + itemsPerColumn, items.size)
                for (index in base until end) {
                    movableItems[index]()
                }
            }
        }
    }
}
```

