swiftui-animation▌
jamesrochabrun/skills · updated Apr 10, 2026
Advanced SwiftUI animations, transitions, matched geometry effects, and Metal shader integration for iOS and macOS.
- ›Covers animation curves, springs, keyframe animators, and phase animators for orchestrated multi-step sequences
- ›Includes built-in transitions (fade, slide, scale, move) and asymmetric transitions for directional entry/exit effects
- ›Provides matched geometry effect patterns for hero animations and smooth view transitions
- ›Supports GPU-accelerated Metal shader effects in
SwiftUI Animation Expert
Expert guidance for implementing advanced SwiftUI animations and Metal shader integration. Covers animation curves, springs, transitions, matched geometry effects, PhaseAnimator, KeyframeAnimator, and GPU-accelerated shader effects.
When to Use This Skill
- Understanding motion design principles and when to use animation
- Making animations accessible and platform-appropriate
- Implementing animations in SwiftUI (springs, easing, keyframes)
- Creating view transitions (fade, slide, scale, custom)
- Building hero animations with matchedGeometryEffect
- Adding GPU-accelerated effects with Metal shaders
- Optimizing animation performance
- Creating multi-phase orchestrated animations
Quick Reference
Animation Basics
// Explicit animation (preferred)
withAnimation(.spring(response: 0.4, dampingFraction: 0.75)) {
isExpanded.toggle()
}
// iOS 17+ spring presets
withAnimation(.snappy) { ... } // Fast, small bounce
withAnimation(.smooth) { ... } // Gentle, no bounce
withAnimation(.bouncy) { ... } // More bounce
Common Transitions
// Basic
.transition(.opacity)
.transition(.scale)
.transition(.slide)
.transition(.move(edge: .bottom))
// Combined
.transition(.move(edge: .trailing).combined(with: .opacity))
// Asymmetric
.transition(.asymmetric(
insertion: .move(edge: .bottom),
removal: .opacity
))
Matched Geometry Effect
@Namespace var namespace
// Source view
ThumbnailView()
.matchedGeometryEffect(id: "hero", in: namespace)
// Destination view
DetailView()
.matchedGeometryEffect(id: "hero", in: namespace)
Metal Shader Effects (iOS 17+)
// Color manipulation
.colorEffect(ShaderLibrary.invert())
// Pixel displacement
.distortionEffect(
ShaderLibrary.wave(.float(time)),
maxSampleOffset: CGSize(width: 20, height: 20)
)
// Full layer access
.layerEffect(ShaderLibrary.blur(.float(radius)), maxSampleOffset: .zero)
Reference Materials
Detailed documentation is available in references/:
-
motion-guidelines.md - HIG Motion design principles
- Purpose-driven motion philosophy
- Accessibility requirements
- Platform-specific considerations (iOS, visionOS, watchOS)
- Animation anti-patterns to avoid
-
animations.md - Complete animation API guide
- Implicit vs explicit animations
- Spring parameters and presets
- Animation modifiers (speed, delay, repeat)
- PhaseAnimator for multi-step sequences
- KeyframeAnimator for property-specific timelines
- Custom animatable properties
-
transitions.md - View transition guide
- Built-in transitions (opacity, scale, slide, move)
- Combined and asymmetric transitions
- Matched geometry effect implementation
- Hero animation patterns
- Content transitions (iOS 17+)
- Custom transition creation
-
metal-shaders.md - GPU shader integration
- SwiftUI shader modifiers (colorEffect, distortionEffect, layerEffect)
- Writing Metal shader functions
- Embedding MTKView with UIViewRepresentable
- Cross-platform Metal integration (iOS/macOS)
- Performance considerations
Common Patterns
Expandable Card
struct ExpandableCard: View {
@State private var isExpanded = false
var body: some View {
VStack {
RoundedRectangle(cornerRadius: isExpanded ? 20 : 12)
.fill(.blue)
.frame(
width: isExpanded ? 300 : 150,
height: isExpanded ? 400 : 100
)
}
.onTapGesture {
withAnimation(.spring(response: 0.35, dampingFraction: 0.75)) {
isExpanded.toggle()
}
}
}
}
List Item Appearance
ForEach(Array(items.enumerated()), id: \.element.id) { index, item in
ItemRow(item: item)
.transition(.asymmetric(
insertion: .move(edge: .trailing).combined(with: .opacity),
removal: .move(edge: .leading).combined(with: .opacity)
))
.animation(.spring().delay(Double(index) * 0.05), value: items)
}
Pulsing Indicator
Circle()
.fill(.blue)
.frame(width: 20, height: 20)
.scaleEffect(isPulsing ? 1.2 : 1.0)
.opacity(isPulsing ? 0.6 : 1.0)
.onAppear {
withAnimation(.easeInOut(duration: 1.0).repeatForever(autoreverses: true)) {
isPulsing = true
}
}
Best Practices
- Motion should be purposeful - Don't add animation for its own sake; support the experience without overshadowing it
- Make motion optional - Supplement with haptics and audio; never use motion as the only way to communicate
- Aim for brevity - Brief, precise animations feel lightweight and convey information effectively
- Prefer explicit animations - Use
withAnimationover.animation()modifier for clarity - Use spring animations - They feel more natural and iOS-native
- Start with
.spring(response: 0.35, dampingFraction: 0.8)- Good default for most interactions - Keep animations under 400ms - Longer feels sluggish
- Let people cancel motion - Don't force users to wait for animations to complete
- Test on device - Simulator animation timing differs
- Profile shader performance - GPU time matters for complex effects
Troubleshooting
Animation not working
- Ensure state change is wrapped in
withAnimation - Check that the property is animatable
- Verify the view is actually changing
Matched geometry jumps
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
Ratings
4.7★★★★★35 reviews- ★★★★★Layla Flores· Dec 28, 2024
swiftui-animation fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Omar Nasser· Dec 28, 2024
swiftui-animation reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Ganesh Mohane· Dec 16, 2024
Registry listing for swiftui-animation matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Ama Chen· Dec 16, 2024
swiftui-animation is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
- ★★★★★James Yang· Nov 19, 2024
We added swiftui-animation from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Soo Sanchez· Nov 19, 2024
swiftui-animation has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Anika Bhatia· Nov 7, 2024
Solid pick for teams standardizing on skills: swiftui-animation is focused, and the summary matches what you get after install.
- ★★★★★Anaya Srinivasan· Nov 3, 2024
Keeps context tight: swiftui-animation is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Kwame Wang· Oct 26, 2024
We added swiftui-animation from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Aarav Malhotra· Oct 22, 2024
Registry listing for swiftui-animation matched our evaluation — installs cleanly and behaves as described in the markdown.
showing 1-10 of 35