Animations in Compose

June 02, 2026 1 min read

Compose makes animation declarative — you animate a value and the UI follows. Most needs are covered by a few simple APIs.

Animate a value

var expanded by remember { mutableStateOf(false) }
val height by animateDpAsState(if (expanded) 200.dp else 80.dp, label = "h")
Box(Modifier.height(height).clickable { expanded = !expanded })

Show/hide with animation

AnimatedVisibility(visible = expanded) {
    Text("Extra details revealed with a smooth animation")
}
  • animateColorAsState, animateFloatAsState, animateDpAsState for single values.
  • AnimatedVisibility for enter/exit.
  • updateTransition for several values that change together.
Tip: Reach for animate*AsState and AnimatedVisibility first — they cover the vast majority of UI animation with almost no code.

Summary

Animate values with animate*AsState and use AnimatedVisibility for enter/exit. Compose interpolates the UI automatically — declarative, smooth motion.