SwiftUI Animation
Choose the narrowest animation mechanism that communicates state change without obscuring ownership, accessibility, or performance.
Contents
Scope and Compatibility
This skill owns SwiftUI timing, transitions, phase/keyframe choreography, matched geometry, navigation zoom visuals, symbol effects, and animation accessibility. Route layout to swiftui-layout-components, route/path ownership to swiftui-navigation, state ownership to swiftui-patterns, and evidence-based profiling to swiftui-performance.
Inspect deployment target, Swift mode, and SDK before selecting APIs. Preserve project settings unless the user requests a change; gate newer APIs and verify availability in SDK headers or primary Apple documentation.
Triage
- Identify the state change and which owner mutates it.
- Decide whether the view is changing modifiers, entering/leaving the tree, changing content in place, or moving between related layouts.
- Select one mechanism and scope it to the smallest affected subtree.
- Test normal interaction, interruption, repeated triggers, and Reduce Motion.
- If motion hitches, measure before changing architecture or adding
Equatable/drawing workarounds.
Mechanism Selection
| Need |
Prefer |
| Animate a mutation owned by an action |
withAnimation |
| Animate selected modifiers |
scoped .animation(_:body:) |
| Simple value-bound implicit animation |
.animation(_:value:) |
| Insert or remove a view |
.transition paired with an animation |
| Change text, number, or symbol in place |
.contentTransition |
| Discrete multi-step sequence |
PhaseAnimator |
| Multi-property timeline |
KeyframeAnimator |
| Related layouts in one hierarchy |
matchedGeometryEffect |
| Push/pop hero effect |
matched transition source plus navigation zoom when available |
| Semantic SF Symbol motion |
.symbolEffect |
| Custom interpolated shape/value |
Animatable or a custom animation when synthesis is insufficient |
| Layer-level or display-link work |
Read Core Animation Bridge |
Use Advanced Animation Patterns for spring parameter variants, custom transitions, transactions, and keyframes. Use Symbol Effects and Accessible Motion for symbol animation effects, Reduce Motion adaptation, and animation performance.
Core Rules
- Animate state changes or visual properties, not expensive computation.
- Value-bound implicit animation must name the value that drives it.
- A transition only runs when insertion/removal occurs and an animation participates in that transaction.
contentTransition changes rendering of in-place content; it still needs an animation.
- Matched geometry needs stable IDs and one intended source for each ID.
- Apply navigation transitions to the destination boundary required by the API, while navigation ownership remains outside this skill.
- Capture values before per-frame
@Sendable closures when actor isolation would otherwise be crossed.
- Treat frame-rate ranges as hints and adapt work to the actual refresh rate.
Accessibility
Read accessibilityReduceMotion for motion that translates, scales, zooms, loops, or creates spatial disorientation. Replace large movement with a fade, content change, or no animation while preserving the state transition. Do not disable every subtle opacity or color change automatically; match the alternative to the user impact.
Indefinite symbol and timeline effects need a clear active condition and must stop when no longer visible or relevant.
Common Mistakes
- Mutating state outside
withAnimation when a transition depends on that state change.
- Animating custom types that do not conform to
VectorArithmetic or Animatable.
- Creating render feedback loops by triggering another state mutation inside an animation completion block.
- Forgetting to handle
accessibilityReduceMotion for disorienting full-screen motion or zoom effects.
- Using unconstrained repeating animations that run indefinitely while the view is off-screen.
Review Checklist
References
- Advanced SwiftUI animations and transitions: references/animation-advanced.md
- Symbol effects and accessible motion: references/symbol-effects-and-accessibility.md
- Core Animation and display-link bridging: references/core-animation-bridge.md
1---2name: swiftui-animation3description: Implement or diagnose SwiftUI motion, including state animations, transitions, springs, keyframes, matched geometry, navigation zoom, and symbol effects. Use when motion behavior is part of the request; route layout, navigation state, and performance profiling elsewhere.4---56# SwiftUI Animation78Choose the narrowest animation mechanism that communicates state change without obscuring ownership, accessibility, or performance.910## Contents1112- [Scope and Compatibility](#scope-and-compatibility)13- [Triage](#triage)14- [Mechanism Selection](#mechanism-selection)15- [Core Rules](#core-rules)16- [Accessibility](#accessibility)17- [Common Mistakes](#common-mistakes)18- [Review Checklist](#review-checklist)19- [References](#references)2021## Scope and Compatibility2223This skill owns SwiftUI timing, transitions, phase/keyframe choreography, matched geometry, navigation zoom visuals, symbol effects, and animation accessibility. Route layout to `swiftui-layout-components`, route/path ownership to `swiftui-navigation`, state ownership to `swiftui-patterns`, and evidence-based profiling to `swiftui-performance`.2425Inspect deployment target, Swift mode, and SDK before selecting APIs. Preserve project settings unless the user requests a change; gate newer APIs and verify availability in SDK headers or primary Apple documentation.2627## Triage28291. Identify the state change and which owner mutates it.302. Decide whether the view is changing modifiers, entering/leaving the tree, changing content in place, or moving between related layouts.313. Select one mechanism and scope it to the smallest affected subtree.324. Test normal interaction, interruption, repeated triggers, and Reduce Motion.335. If motion hitches, measure before changing architecture or adding `Equatable`/drawing workarounds.3435## Mechanism Selection3637| Need | Prefer |38|---|---|39| Animate a mutation owned by an action | `withAnimation` |40| Animate selected modifiers | scoped `.animation(_:body:)` |41| Simple value-bound implicit animation | `.animation(_:value:)` |42| Insert or remove a view | `.transition` paired with an animation |43| Change text, number, or symbol in place | `.contentTransition` |44| Discrete multi-step sequence | `PhaseAnimator` |45| Multi-property timeline | `KeyframeAnimator` |46| Related layouts in one hierarchy | `matchedGeometryEffect` |47| Push/pop hero effect | matched transition source plus navigation zoom when available |48| Semantic SF Symbol motion | `.symbolEffect` |49| Custom interpolated shape/value | `Animatable` or a custom animation when synthesis is insufficient |50| Layer-level or display-link work | Read [Core Animation Bridge](references/core-animation-bridge.md) |5152Use [Advanced Animation Patterns](references/animation-advanced.md) for spring parameter variants, custom transitions, transactions, and keyframes. Use [Symbol Effects and Accessible Motion](references/symbol-effects-and-accessibility.md) for symbol animation effects, Reduce Motion adaptation, and animation performance.5354## Core Rules5556- Animate state changes or visual properties, not expensive computation.57- Value-bound implicit animation must name the value that drives it.58- A transition only runs when insertion/removal occurs and an animation participates in that transaction.59- `contentTransition` changes rendering of in-place content; it still needs an animation.60- Matched geometry needs stable IDs and one intended source for each ID.61- Apply navigation transitions to the destination boundary required by the API, while navigation ownership remains outside this skill.62- Capture values before per-frame `@Sendable` closures when actor isolation would otherwise be crossed.63- Treat frame-rate ranges as hints and adapt work to the actual refresh rate.6465## Accessibility6667Read `accessibilityReduceMotion` for motion that translates, scales, zooms, loops, or creates spatial disorientation. Replace large movement with a fade, content change, or no animation while preserving the state transition. Do not disable every subtle opacity or color change automatically; match the alternative to the user impact.6869Indefinite symbol and timeline effects need a clear active condition and must stop when no longer visible or relevant.7071## Common Mistakes7273- Mutating state outside `withAnimation` when a transition depends on that state change.74- Animating custom types that do not conform to `VectorArithmetic` or `Animatable`.75- Creating render feedback loops by triggering another state mutation inside an animation completion block.76- Forgetting to handle `accessibilityReduceMotion` for disorienting full-screen motion or zoom effects.77- Using unconstrained repeating animations that run indefinitely while the view is off-screen.7879## Review Checklist8081- [ ] The state owner and animation trigger are explicit82- [ ] Animation scope is limited to intended modifiers or subtree83- [ ] Transition and content-transition semantics are correct84- [ ] Stable identity and namespace pairing are preserved85- [ ] Repeated and interrupted interactions produce valid state86- [ ] Reduce Motion has an appropriate alternative87- [ ] Per-frame closures avoid expensive work and unsafe actor reads88- [ ] Versioned APIs match the project target89- [ ] Core Animation bridges clean up delegates, display links, and resources9091## References9293- Advanced SwiftUI animations and transitions: [references/animation-advanced.md](references/animation-advanced.md)94- Symbol effects and accessible motion: [references/symbol-effects-and-accessibility.md](references/symbol-effects-and-accessibility.md)95- Core Animation and display-link bridging: [references/core-animation-bridge.md](references/core-animation-bridge.md)