<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Animatable",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI10AnimatableP"
  },
  "title" : "Animatable"
}
-->

# Animatable

A type that describes how to animate a property of a view.

```
protocol Animatable
```

## Overview

When an animatable value changes inside a
[`withAnimation(_:_:)`](/documentation/SwiftUI/withAnimation(_:_:)) block (or is affected by an
`animation(_:value:)` modifier), SwiftUI reads the old and
new [`animatableData`](/documentation/SwiftUI/Animatable/animatableData-6nydg) values, then interpolates between them
over successive frames using [`VectorArithmetic`](/documentation/SwiftUI/VectorArithmetic) operations.
The framework calls the [`animatableData`](/documentation/SwiftUI/Animatable/animatableData-6nydg) setter on each
frame, giving your type a chance to update any derived state.

### Use the Animatable macro

To conform a type to the `Animatable` protocol, use the
[`Animatable()`](/documentation/SwiftUI/Animatable()) macro to avoid writing the
[`animatableData`](/documentation/SwiftUI/Animatable/animatableData-6nydg) property by hand:

```
@Animatable
struct RingSegment: Shape {
    var startAngle: Angle
    var endAngle: Angle
    // ...
}
```

The macro inspects every stored property. Properties whose
types conform to `VectorArithmetic` or `Animatable` are
included in the synthesized [`animatableData`](/documentation/SwiftUI/Animatable/animatableData-6nydg). If a
property cannot participate, the macro emits an error
suggesting you mark it with [`AnimatableIgnored()`](/documentation/SwiftUI/AnimatableIgnored()) or
conform its type to `VectorArithmetic` or `Animatable`:

```
@Animatable
struct RingSegment: Shape {
    var startAngle: Angle
    var endAngle: Angle
    @AnimatableIgnored var isOpaque: Bool
    // ...
}
```

### Manual conformance for custom interpolation

Reach for a handwritten [`animatableData`](/documentation/SwiftUI/Animatable/animatableData-6nydg) when the
interpolated value needs custom logic that does not
correspond one-to-one with a stored property, such as
normalization, clamping, or driving a derived value.

Use [`AnimatableValues`](/documentation/SwiftUI/AnimatableValues) (26.0+ releases) to group
multiple animated properties, or [`AnimatablePair`](/documentation/SwiftUI/AnimatablePair) on
earlier deployment targets:

```
struct WaveShape: Shape {
    var amplitude: CGFloat
    var phase: CGFloat
    var maxAmplitude: CGFloat

    var animatableData:
        AnimatableValues<CGFloat, CGFloat>
    {
        get {
            AnimatableValues(amplitude, phase)
        }
        set {
            amplitude = min(
                max(newValue.value.0, 0),
                maxAmplitude)
            phase = newValue.value.1
                .truncatingRemainder(
                    dividingBy: 2 * .pi)
        }
    }

    // ...
}
```

## Topics

### Animating data

[`Animatable()`](/documentation/SwiftUI/Animatable())

A member and extension macro that, when applied to a struct, class or enum
declaration, synthesizes the conformance to `Animatable` and its
requirement, the `animatableData` property using the existing animatable
properties of the type this macro is applied to.

[`AnimatableIgnored()`](/documentation/SwiftUI/AnimatableIgnored())

An accessor macro that marks a property of a type to be excluded from the
`animatableData` synthesis:

[`animatableData`](/documentation/SwiftUI/Animatable/animatableData-6nydg)

The data to animate.

[`AnimatableData`](/documentation/SwiftUI/Animatable/AnimatableData-swift.associatedtype)

The type defining the data to animate.



---

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)