<!--
{
  "availability" : [
    "iOS: 13.0.0 - 15.0.0",
    "iPadOS: 13.0.0 - 15.0.0",
    "macCatalyst: 13.0.0 - 15.0.0",
    "macOS: 10.15.0 - 12.0.0",
    "tvOS: 13.0.0 - 15.0.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 6.0.0 - 8.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/animation(_:)-1hc0p",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE9animationyQrAA9AnimationVSgF"
  },
  "title" : "animation(_:)"
}
-->

# animation(_:)

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

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

## Parameters

`animation`

The animation to apply to animatable values
within this view.

## Return Value

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

## 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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)