Skip to content

Jetpack Compose LazyColumn — Complete Guide

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about Jetpack Compose LazyColumn. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

The Problem

Your LazyColumn lists all items at once (no lazy benefit), janks on scroll, or items flash/reorder during updates.

Wrong Approach ❌

@Composable
fun BadList(items: List<String>) {
    // Column — not Lazy! Renders all items upfront
    Column {
        items.forEach { item ->
            Text(item) // Thousands of Text composables created
        }
    }
}

@Composable
fun KeylessLazy(items: List<Item>) {
    LazyColumn {
        items(items) { item -> // No key — items flash on update
            ItemRow(item)
        }
    }
}

Output: UI thread blocked for large lists. Items flicker during updates.

Right Approach ✅

@Composable
fun GoodLazyList(items: List<Item>) {
    LazyColumn(
        modifier = Modifier.fillMaxSize(),
        contentPadding = PaddingValues(horizontal = 16.dp),
        verticalArrangement = Arrangement.spacedBy(8.dp)
    ) {
        items(
            items = items,
            key = { it.id } // Stable key for efficient recomposition
        ) { item ->
            ItemRow(item)
        }

        // Headers, footers, and sticky headers
        stickyHeader {
            Text("Header", style = MaterialTheme.typography.h5)
        }

        item {
            Button(onClick = { /* load more */ }) {
                Text("Load More")
            }
        }
    }
}

Output: Smooth scrolling with proper lazy rendering and stable keys.

Prevention

  • Always use LazyColumn/LazyRow for lists of more than ~10 items.
  • Always provide stable key values in items() for diffing.
  • Use contentPadding instead of outer Modifier.padding for edge-to-edge scrolling.
  • Use stickyHeader for section headers that should stick to the top.

Common Mistakes with compose lazy column

  1. Mixing let bindings with <- bindings in do notation, producing type errors
  2. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
  3. Non-exhaustive pattern matches that compile with warnings then crash at runtime

These mistakes appear frequently in real-world Android code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What is the difference between Column and LazyColumn?

Column composes all children immediately — use it for small, known-size lists. LazyColumn composes only visible items and recycles them — use it for dynamic or large lists.

### How do I handle empty state in LazyColumn?

Use if (items.isEmpty()) { EmptyState() } else { LazyColumn { ... } } or use LazyColumn with a single footer item { EmptyState() } when the list is empty.

### Can I scroll to a specific item?

Yes. Use LazyListState with rememberLazyListState(). Call lazyListState.animateScrollToItem(index) or lazyListState.scrollToItem(index).

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro