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.
Similar Blogs
View All Articles
SwiftUI: How To Reset a Form
Learn how to reset a SwiftUI form with one line. Clear text fields instantly using @State or a form model. Simple copy/paste SwiftUI code examples.

SwiftUI: How To Toggle a Switch Programmatically
Learn how to toggle a SwiftUI switch programmatically with @State and @Binding. Simple examples with code to trigger Toggle from buttons or other views.

How to use @AppStorage in SwiftUI
Learn how to use @AppStorage in SwiftUI to save user settings and preferences easily with UserDefaults

How to Navigate to Another View in SwiftUI
Starting from iOS 16, Apple introduced the new NavigationStack API, which replaces NavigationView and makes navigation more powerful and reliable.
Code copied to clipboard!