How to Dismiss a Sheet in SwiftUI
October 12, 2025·1 min read·by dockui

@Environment(\.dismiss) in SwiftUI
In iOS 15 and later, SwiftUI introduces a new environment value called dismiss.
Instead of accessing the presentationMode binding, you can simply call a dismiss action:
Code Snippet
Then, to close the current sheet or modal, just call:
Code Snippet
This approach is cleaner, safer, and recommended for all new SwiftUI apps.
Example: Dismissing a Sheet in iOS 15
Here’s a minimal, fully working example showing how to present and dismiss a sheet in SwiftUI.
Code Snippet
For Older Versions (iOS 14 and Below)
If you need to support older iOS versions, you can still fall back to the old approach:
Code Snippet
Just remember to prefer dismiss() on iOS 15+ for future compatibility.
Code copied to clipboard!