---
title: "animation(_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/animation(_:)"
---

# animation(_:)

Applies the given animation to this view when this view changes.

## Declaration

```swift
nonisolated func animation(_ animation: Animation?) -> some View

```

## Parameters

- `animation`: The animation to apply. If animation is nil, the view doesn’t animate.

## Return Value

Return Value A view that applies animation to this view whenever it changes.

## See Also

### Adding state-based animation to a view

- [animation(_:value:)](swiftui/view/animation(_:value:).md)
- [animation(_:body:)](swiftui/view/animation(_:body:).md)
