# androidx.compose.foundation.lazy.staggeredgrid

Common/All

## Interfaces

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridItemInfo` | Information about layout state of individual item in lazy staggered grid. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridItemScope` | Receiver scope for itemContent in `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridScope#item(kotlin.Any,kotlin.Any,androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridItemSpan,kotlin.Function1)` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridLayoutInfo` | Information about layout state of lazy staggered grids. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridScope` | Receiver scope for `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyVerticalStaggeredGrid.composable#LazyVerticalStaggeredGrid(androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells,androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.ui.unit.Dp,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)` and `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyHorizontalStaggeredGrid.composable#LazyHorizontalStaggeredGrid(androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells,androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.ui.unit.Dp,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,androidx.compose.foundation.OverscrollEffect,androidx.compose.foundation.lazy.layout.LazyLayoutCacheWindow,kotlin.Function1)` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridCells` | This class describes the count and the sizes of columns in vertical staggered grids, or rows in horizontal staggered grids. | Cmn |

## Classes

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridState` | Hoisted state object controlling `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyVerticalStaggeredGrid.composable#LazyVerticalStaggeredGrid(androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells,androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.ui.unit.Dp,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)` or `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyHorizontalStaggeredGrid.composable#LazyHorizontalStaggeredGrid(androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells,androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.ui.unit.Dp,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,androidx.compose.foundation.OverscrollEffect,androidx.compose.foundation.lazy.layout.LazyLayoutCacheWindow,kotlin.Function1)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridCells.Adaptive` | Defines a grid with as many rows or columns as possible on the condition that every cell has at least `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridCells.Adaptive#minSize()` space and all extra space distributed evenly. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridCells.Fixed` | Defines a grid with fixed number of rows or columns. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridCells.FixedSize` | Defines a grid with as many rows or columns as possible on the condition that every cell takes exactly `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridCells.FixedSize#size()` space. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridItemSpan` | Span defines a number of lanes (columns in vertical grid/rows in horizontal grid) for staggered grid items. | Cmn |

## Composables

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyHorizontalStaggeredGrid.composable` | Horizontal staggered grid layout that composes and lays out only items currently visible on screen. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyVerticalStaggeredGrid.composable` | Vertical staggered grid layout that composes and lays out only items currently visible on screen. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/rememberLazyStaggeredGridState.composable` | Creates a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridState` that is remembered across composition. | Cmn |

## Top-level functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutScrollScope` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/package-summary#LazyLayoutScrollScope(androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridState,androidx.compose.foundation.gestures.ScrollScope)( state: https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridState, scrollScope: https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollScope )` An implementation of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/package-summary#LazyLayoutScrollScope(androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridState,androidx.compose.foundation.gestures.ScrollScope)` that can be used with LazyStaggeredGrids. | Cmn |

## Extension functions summary

|---|---|---|
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridScope.https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/package-summary#(androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridScope).items(kotlin.Array,kotlin.Function1,kotlin.Function1,kotlin.Function1,kotlin.Function2)( items: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<T>, noinline key: ((item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)?, crossinline contentType: (item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, noinline span: ((item) -> https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridItemSpan)?, crossinline itemContent: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridItemScope.(item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Add an array of items to the staggered grid. | Cmn |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridScope.https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/package-summary#(androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridScope).items(kotlin.collections.List,kotlin.Function1,kotlin.Function1,kotlin.Function1,kotlin.Function2)( items: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T>, noinline key: ((item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)?, crossinline contentType: (item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, noinline span: ((item) -> https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridItemSpan)?, crossinline itemContent: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridItemScope.(item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Add a list of items to the staggered grid. | Cmn |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridScope.https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/package-summary#(androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridScope).itemsIndexed(kotlin.Array,kotlin.Function2,kotlin.Function2,kotlin.Function2,kotlin.Function3)( items: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<T>, noinline key: ((index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)?, crossinline contentType: (index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, noinline span: ((index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item) -> https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridItemSpan)?, crossinline itemContent: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridItemScope.(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Add an array of items with index-aware content to the staggered grid. | Cmn |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridScope.https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/package-summary#(androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridScope).itemsIndexed(kotlin.collections.List,kotlin.Function2,kotlin.Function2,kotlin.Function2,kotlin.Function3)( items: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T>, noinline key: ((index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)?, crossinline contentType: (index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, noinline span: ((index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item) -> https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridItemSpan)?, crossinline itemContent: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridItemScope.(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Add a list of items with index-aware content to the staggered grid. | Cmn |

## Top-level functions

### LazyLayoutScrollScope

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/staggeredgrid/LazyStaggeredGridScrollScope.kt+function:LazyLayoutScrollScope) Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.8.0)

```
fun LazyLayoutScrollScope(
    state: LazyStaggeredGridState,
    scrollScope: ScrollScope
): LazyLayoutScrollScope
```

An implementation of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/package-summary#LazyLayoutScrollScope(androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridState,androidx.compose.foundation.gestures.ScrollScope)` that can be used with LazyStaggeredGrids.

```kotlin
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.layout.LazyLayoutScrollScope
import androidx.compose.foundation.lazy.staggeredgrid.LazyHorizontalStaggeredGrid
import androidx.compose.foundation.lazy.staggeredgrid.LazyLayoutScrollScope
import androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridState
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells
import androidx.compose.foundation.lazy.staggeredgrid.items
import androidx.compose.foundation.lazy.staggeredgrid.rememberLazyStaggeredGridState
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

suspend fun LazyStaggeredGridState.customScroll(
    block: suspend LazyLayoutScrollScope.() -> Unit
) = scroll { block.invoke(LazyLayoutScrollScope(this@customScroll, this)) }

val itemsList = (0..100).toList()
val state = rememberLazyStaggeredGridState()
val scope = rememberCoroutineScope()

Column(Modifier.verticalScroll(rememberScrollState())) {
    Button(
        onClick = {
            scope.launch {
                state.customScroll {
                    snapToItem(40, 0) // teleport to item 40
                    val distance = calculateDistanceTo(50).toFloat()
                    var previousValue = 0f
                    androidx.compose.animation.core.animate(
                        0f,
                        distance,
                        animationSpec = tween(5_000),
                    ) { currentValue, _ ->
                        previousValue += scrollBy(currentValue - previousValue)
                    }
                }
            }
        }
    ) {
        Text("Scroll To Item 50")
    }
    LazyHorizontalStaggeredGrid(
        state = state,
        rows = StaggeredGridCells.Fixed(3),
        modifier = Modifier.height(600.dp).fillMaxWidth(),
    ) {
        items(itemsList) {
            Box(Modifier.padding(2.dp).background(Color.Red).size(45.dp)) {
                Text(it.toString())
            }
        }
    }
}
```

| Parameters |
|---|---|
| `state: https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridState` | The `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridState` associated with the layout where this custom scroll should be performed. |
| `scrollScope: https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollScope` | The base `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollScope` where the scroll session was created. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutScrollScope` | An implementation of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/package-summary#LazyLayoutScrollScope(androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridState,androidx.compose.foundation.gestures.ScrollScope)` that works with `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyHorizontalStaggeredGrid.composable#LazyHorizontalStaggeredGrid(androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells,androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.ui.unit.Dp,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,androidx.compose.foundation.OverscrollEffect,androidx.compose.foundation.lazy.layout.LazyLayoutCacheWindow,kotlin.Function1)` and `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyVerticalStaggeredGrid.composable#LazyVerticalStaggeredGrid(androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells,androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.ui.unit.Dp,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)`. |

## Extension functions

### LazyStaggeredGridScope.items

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/staggeredgrid/LazyStaggeredGridDsl.kt+function:items) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.4.0)

```
inline fun <T : Any?> LazyStaggeredGridScope.items(
    items: Array<T>,
    noinline key: ((item) -> Any)? = null,
    crossinline contentType: (item) -> Any? = { null },
    noinline span: ((item) -> StaggeredGridItemSpan)? = null,
    crossinline itemContent: @Composable LazyStaggeredGridItemScope.(item) -> Unit
): Unit
```

Add an array of items to the staggered grid.

| Parameters |
|---|---|
| `items: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<T>` | a data array to present |
| `noinline key: ((item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)? = null` | a factory of stable and unique keys representing the item. The key MUST be saveable via Bundle on Android. If set to null (by default), the position of the item will be used as a key instead. Using the same key for multiple items in the staggered grid is not allowed. This can be overridden by calling `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridState#requestScrollToItem(kotlin.Int,kotlin.Int)`. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one. |
| `crossinline contentType: (item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html? = { null }` | a factory of content types representing the item. Content for item of the same type can be reused more efficiently. null is a valid type as well and items of such type will be considered compatible. |
| `noinline span: ((item) -> https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridItemSpan)? = null` | a factory of custom spans for this item. Spans configure how many lanes defined by `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridCells` the item will occupy. By default each item will take one lane. |
| `crossinline itemContent: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridItemScope.(item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | composable content displayed by the provided item |

### LazyStaggeredGridScope.items

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/staggeredgrid/LazyStaggeredGridDsl.kt+function:items)

```
inline fun <T : Any?> LazyStaggeredGridScope.items(
    items: List<T>,
    noinline key: ((item) -> Any)? = null,
    crossinline contentType: (item) -> Any? = { null },
    noinline span: ((item) -> StaggeredGridItemSpan)? = null,
    crossinline itemContent: @Composable LazyStaggeredGridItemScope.(item) -> Unit
): Unit
```

Add a list of items to the staggered grid.

| Parameters |
|---|---|
| `items: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T>` | a data list to present |
| `noinline key: ((item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)? = null` | a factory of stable and unique keys representing the item. The key MUST be saveable via Bundle on Android. If set to null (by default), the position of the item will be used as a key instead. Using the same key for multiple items in the staggered grid is not allowed. This can be overridden by calling `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridState#requestScrollToItem(kotlin.Int,kotlin.Int)`. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one. |
| `crossinline contentType: (item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html? = { null }` | a factory of content types representing the item. Content for item of the same type can be reused more efficiently. null is a valid type as well and items of such type will be considered compatible. |
| `noinline span: ((item) -> https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridItemSpan)? = null` | a factory of custom spans for this item. Spans configure how many lanes defined by `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridCells` the item will occupy. By default each item will take one lane. |
| `crossinline itemContent: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridItemScope.(item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | composable content displayed by the provided item |

### LazyStaggeredGridScope.itemsIndexed

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/staggeredgrid/LazyStaggeredGridDsl.kt+function:itemsIndexed) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.4.0)

```
inline fun <T : Any?> LazyStaggeredGridScope.itemsIndexed(
    items: Array<T>,
    noinline key: ((index: Int, item) -> Any)? = null,
    crossinline contentType: (index: Int, item) -> Any? = { _, _ -> null },
    noinline span: ((index: Int, item) -> StaggeredGridItemSpan)? = null,
    crossinline itemContent: @Composable LazyStaggeredGridItemScope.(index: Int, item) -> Unit
): Unit
```

Add an array of items with index-aware content to the staggered grid.

| Parameters |
|---|---|
| `items: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<T>` | a data array to present |
| `noinline key: ((index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)? = null` | a factory of stable and unique keys representing the item. The key MUST be saveable via Bundle on Android. If set to null (by default), the position of the item will be used as a key instead. Using the same key for multiple items in the staggered grid is not allowed. This can be overridden by calling `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridState#requestScrollToItem(kotlin.Int,kotlin.Int)`. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one. |
| `crossinline contentType: (index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html? = { _, _ -> null }` | a factory of content types representing the item. Content for item of the same type can be reused more efficiently. null is a valid type as well and items of such type will be considered compatible. |
| `noinline span: ((index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item) -> https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridItemSpan)? = null` | a factory of custom spans for this item. Spans configure how many lanes defined by `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridCells` the item will occupy. By default each item will take one lane. |
| `crossinline itemContent: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridItemScope.(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | composable content displayed given item and index |

### LazyStaggeredGridScope.itemsIndexed

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/staggeredgrid/LazyStaggeredGridDsl.kt+function:itemsIndexed)

```
inline fun <T : Any?> LazyStaggeredGridScope.itemsIndexed(
    items: List<T>,
    noinline key: ((index: Int, item) -> Any)? = null,
    crossinline contentType: (index: Int, item) -> Any? = { _, _ -> null },
    noinline span: ((index: Int, item) -> StaggeredGridItemSpan)? = null,
    crossinline itemContent: @Composable LazyStaggeredGridItemScope.(index: Int, item) -> Unit
): Unit
```

Add a list of items with index-aware content to the staggered grid.

| Parameters |
|---|---|
| `items: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T>` | a data list to present |
| `noinline key: ((index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)? = null` | a factory of stable and unique keys representing the item. The key MUST be saveable via Bundle on Android. If set to null (by default), the position of the item will be used as a key instead. Using the same key for multiple items in the staggered grid is not allowed. This can be overridden by calling `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridState#requestScrollToItem(kotlin.Int,kotlin.Int)`. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one. |
| `crossinline contentType: (index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html? = { _, _ -> null }` | a factory of content types representing the item. Content for item of the same type can be reused more efficiently. null is a valid type as well and items of such type will be considered compatible. |
| `noinline span: ((index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item) -> https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridItemSpan)? = null` | a factory of custom spans for this item. Spans configure how many lanes defined by `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/StaggeredGridCells` the item will occupy. By default each item will take one lane. |
| `crossinline itemContent: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridItemScope.(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | composable content displayed given item and index |