Skip to main content

Open-WebUI-Functions is here! New Pipelines, Filters, and more. Learn more

Scale Animations

Here are some examples of how to create scale animations in WinUI using the Windows.UI.Composition namespace.

Learn more

Button

You can create a scale animation for a button using the SpringVector3NaturalMotionAnimation class from the Windows.UI.Composition namespace. This allows you to create a spring-like effect when the button is hovered over.

Reuse the animation

Extract the animation creation logic into a helper so multiple controls can share it:

public sealed class ScaleAnimationService
{
private readonly Compositor compositor;
public ScaleAnimationService(Compositor compositor)
{
this.compositor = compositor;
}
public SpringVector3NaturalMotionAnimation Create(float finalValue)
{
var animation = compositor.CreateSpringVector3Animation();
animation.Target = "Scale";
animation.FinalValue = new Vector3(finalValue);
animation.DampingRatio = 0.6f;
animation.Period = TimeSpan.FromMilliseconds(250);
return animation;
}
}

You can cache instances of the service in your view model or dependency injection container to keep animations consistent across the app.

Tune the spring

  • Use DampingRatio to control how bouncy the animation feels—a lower value adds more overshoot.
  • Adjust FinalValue and CenterPoint together when animating items of different sizes to prevent jarring jumps.
  • Pair the scale effect with subtle opacity or shadow changes for richer affordances, but keep the duration short to maintain responsiveness.