When you are inserting and removing views from your SwiftUI screen, you can use built-in animations with the use of the transition modifier.
But getting them to work right (especially in iOS 15/Xcode 13) can be a challenge.
Your transition modifier is in place. You defined your animation to use.
But why can't you see the transition happening on the canvas when previewing it inside of Xcode?
Structuring Views for Transitions
I updated the book SwiftUI Animations Mastery to help with this problem.
In this example, you see I put the animation on a Group view:
I found this is one of the most reliable ways to do transitions so it works with the Preview, Simulator & Device.
Here's the full example:
You have Options
This doesn't have to be the ONLY way to do transitions.
And this might improve in SwiftUI as time goes on.
Here are some other options for structuring transitions:
You can see there are other options but your results may vary.
SwiftUI Animations Mastery
These are screenshots right out of the book SwiftUI Animations Mastery
Learn the many different ways of using transitions in SwiftUI as well as composing your own custom transitions with this book.