# LazyGridItemScope

Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/lazy/grid/LazyGridItemScope.kt+class:androidx.compose.foundation.lazy.grid.LazyGridItemScope) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.2.0) Common/All
- Cmn

  ```
  @LazyGridScopeMarker
  sealed interface LazyGridItemScope
  ```

*** ** * ** ***

Receiver scope being used by the item content parameter of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyVerticalGrid.composable#LazyVerticalGrid(androidx.compose.foundation.lazy.grid.GridCells,androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.grid.LazyGridState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.foundation.layout.Arrangement.Horizontal,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,androidx.compose.foundation.OverscrollEffect,androidx.compose.foundation.lazy.layout.LazyLayoutCacheWindow,kotlin.Function1)`.

## Summary

| ### Public functions |
|---|---|---|
| `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/compose/foundation/lazy/grid/LazyGridItemScope#(androidx.compose.ui.Modifier).animateItem(androidx.compose.animation.core.FiniteAnimationSpec,androidx.compose.animation.core.FiniteAnimationSpec,androidx.compose.animation.core.FiniteAnimationSpec)( fadeInSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FiniteAnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>?, placementSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FiniteAnimationSpec<https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntOffset>?, fadeOutSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FiniteAnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>? )` This modifier animates the item appearance (fade in), disappearance (fade out) and placement changes (such as an item reordering). | Cmn |

## Public functions

### Modifier.animateItem

Cmn Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/lazy/grid/LazyGridItemScope.kt+function:animateItem) Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.7.0)

```
fun Modifier.animateItem(
    fadeInSpec: FiniteAnimationSpec<Float>? = spring(stiffness = Spring.StiffnessMediumLow),
    placementSpec: FiniteAnimationSpec<IntOffset>? = spring(
                stiffness = Spring.StiffnessMediumLow,
                visibilityThreshold = IntOffset.VisibilityThreshold,
            ),
    fadeOutSpec: FiniteAnimationSpec<Float>? = spring(stiffness = Spring.StiffnessMediumLow)
): Modifier
```

This modifier animates the item appearance (fade in), disappearance (fade out) and placement changes (such as an item reordering).

You should also provide a key via `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridScope#item(kotlin.Any,kotlin.Function1,kotlin.Any,kotlin.Function1)`/`https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridScope#items(kotlin.Int,kotlin.Function1,kotlin.Function2,kotlin.Function1,kotlin.Function2)` for this modifier to enable animations.

```kotlin
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier

var list by remember { mutableStateOf(listOf("A", "B", "C")) }
Column {
    Button(onClick = { list = list + "D" }) { Text("Add new item") }
    Button(onClick = { list = list.shuffled() }) { Text("Shuffle") }
    LazyVerticalGrid(columns = GridCells.Fixed(1)) {
        items(list, key = { it }) { Text("Item $it", Modifier.animateItem()) }
    }
}
```

| Parameters |
|---|---|
| `fadeInSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FiniteAnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>? = spring(stiffness = Spring.StiffnessMediumLow)` | an animation specs to use for animating the item appearance. When null is provided the item will be appearing without animations. |
| `placementSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FiniteAnimationSpec<https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntOffset>? = spring( stiffness = Spring.StiffnessMediumLow, visibilityThreshold = IntOffset.VisibilityThreshold, )` | an animation specs that will be used to animate the item placement. Aside from item reordering all other position changes caused by events like arrangement or alignment changes will also be animated. When null is provided no animations will happen. |
| `fadeOutSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FiniteAnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>? = spring(stiffness = Spring.StiffnessMediumLow)` | an animation specs to use for animating the item disappearance. When null is provided the item will be disappearance without animations. |