---
title: "withAnimation(_:_:)"
framework: swiftui
role: symbol
role_heading: Function
path: "swiftui/withanimation(_:_:)"
---

# withAnimation(_:_:)

Returns the result of recomputing the view’s body with the provided animation.

## Declaration

```swift
func withAnimation<Result>(_ animation: Animation? = .default, _ body: () throws -> Result) rethrows -> Result
```

## Mentioned in

Applying Liquid Glass to custom views Managing user interface state

## Discussion

Discussion This function sets the given Animation as the animation property of the thread’s current Transaction.

## See Also

### Adding state-based animation to an action

- [withAnimation(_:completionCriteria:_:completion:)](swiftui/withanimation(_:completioncriteria:_:completion:).md)
- [AnimationCompletionCriteria](swiftui/animationcompletioncriteria.md)
- [Animation](swiftui/animation.md)
