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
- Stateful vs Stateless Composables
- Hoist State with value & onValueChange
- Single Source of Truth
- Compose State Slots & Content Lambdas