useAnimatedFloat
fun ComponentScope.useAnimatedFloat(targetValue: Float, spec: FiniteAnimationSpec<Float> = spring(), trigger: AnimationTrigger = AnimationTrigger.Immediate, label: String = "float"): Value<Float>
Animates a Float value, automatically starting a new animation whenever targetValue changes.
val alpha = useAnimatedFloat(if (visible) 1f else 0f)
Style.alpha(alpha)Content copied to clipboard
If the target changes while an animation is running, the current animation is interrupted with velocity preservation for smooth retargeting.
Return
A Value containing the current animated value.
Parameters
targetValue
The value to animate toward. Changes trigger new animations.
spec
The animation specification. Defaults to spring.
trigger
Controls when the animation begins receiving frame callbacks. Defaults to AnimationTrigger.Immediate.
label
Optional label for debugging and tracing attribution.