0Pricing
Jetpack Compose Academy · Lesson

Compose State Slots & Content Lambdas

Make components flexible with slot APIs.

Make Components Flexible

A slot lets a component accept a chunk of UI as a parameter. The caller fills the slot, so one component fits many designs.

Meet the content Lambda

The most common slot is a trailing content lambda of type @Composable () -> Unit. Whatever you put in braces becomes the body.

fun Card(content: @Composable () -> Unit) {
  Surface { content() }
}

All lessons in this course

  1. Stateful vs Stateless Composables
  2. Hoist State with value & onValueChange
  3. Single Source of Truth
  4. Compose State Slots & Content Lambdas
← Back to Jetpack Compose Academy