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

# animation(_:)

Applies the given animation to all animatable values within this view.

## Declaration

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

```

## Parameters

- `animation`: The animation to apply to animatable values within this view.

## Return Value

Return Value A view that wraps this view and applies animation to all animatable values used within the view.

## Discussion

Discussion Use this modifier on leaf views rather than container views. The animation applies to all child views within this view; calling animation(_:) on a container view can lead to unbounded scope.
