# Lazy Lists, Grids & Pagers (https://crow.build/docs/ui/lists)

Crow's virtualized layouts share a renderer-agnostic, property-fuzzed layout algorithm (`LazyListLayout` / `LazyGridLayout` in `crow-runtime`) so only visible items (plus a configurable mount-ahead prefetch window) ever exist in memory.

## `LazyColumn` & `LazyRow` [#lazycolumn--lazyrow]

Use the `LazyListScope` DSL (`pinnedHeader`, `stickyHeader`, `item`, `items`, `itemsIndexed`, `empty`):

```kotlin
LazyColumn(
    modifier = Modifier.fillMaxSize(),
    contentPadding = PaddingValues(horizontal = 16.dp, vertical = 12.dp),
) {
    stickyHeader(key = "header-today") {
        SectionHeader("Today")
    }

    items(brews, key = { it.id }) { brew ->
        BrewCard(brew, modifier = Modifier.padding(bottom = 10.dp))
    }
}
```

### Key Guarantees [#key-guarantees]

- **Anchor preservation**: Prepending items above the current viewport keeps the visible anchor rock-steady without jumping.
- **In-place item updates**: Because `@Ui` lambda parameters are live props, updating a row's data updates only the bound leaf properties without remounting the item.
- **Layer-phase `stickyHeader`**: Sticky headers pin and push out in the layer phase with zero relayout per scroll frame.
- **Dormant off-screen retention**: Recently scrolled-out items within half a viewport stay mounted in an inactive owner (effects paused) so fast back-and-forth flings stay silky smooth at 120 Hz.
- **RenderNode stretch overscroll**: Overscroll runs in the draw phase inside its own `RenderNode`, so pinned headers never distort.

## `LazyVerticalGrid` [#lazyverticalgrid]

Build multi-column grids with fixed column counts and item spacing:

```kotlin
LazyVerticalGrid(
    items = pokemon,
    columns = 2,
    key = { it.id },
    modifier = Modifier.fillMaxSize().padding(12.dp),
    horizontalSpacing = 12.dp,
    verticalSpacing = 12.dp,
) { entry ->
    PokemonCard(entry)
}
```

## `HorizontalPager` & `VerticalPager` [#horizontalpager--verticalpager]

Signal-first pagers with velocity-continuous spring snapping, lazy mounting, and peeking carousels via `contentPadding`:

```kotlin
val pager = PagerState(pageCount = { slides.size })

HorizontalPager(
    state = pager,
    contentPadding = PaddingValues(horizontal = 32.dp),
    pageSpacing = 12.dp,
) { page ->
    Box(
        Modifier
            .fillMaxWidth()
            .graphicsLayer {
                val offset = pager.offsetForPage(page).absoluteValue.coerceIn(0f, 1f)
                scale = 1f - offset * 0.08f
                alpha = 1f - offset * 0.35f
            },
    ) {
        SlideCard(slides[page])
    }
}
```

Because `pager.offsetForPage(page)` and `pager.currentPageOffsetFraction` are immediate-lane signals read inside `graphicsLayer { }`, parallax and carousel scaling execute purely in the GPU layer phase with **zero recomposition and zero layout passes**.