Color & size
Tap to toggle; color and size animate to their new targets.
var toggled by remember { mutableStateOf(false) }
val color by animateColorAsState(
targetValue = if (toggled) Color(0xFF6750A4) else Color(0xFF7D5260),
label = "color"
)
val size by animateDpAsState(
targetValue = if (toggled) 120.dp else 72.dp,
animationSpec = spring(dampingRatio = Spring.DampingRatioMediumBouncy),
label = "size"
)
Box(Modifier.size(size).clip(RoundedCornerShape(16.dp)).background(color))
Button(onClick = { toggled = !toggled }) { Text("Toggle") }