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
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.

SwiftUI: iOS Confirmation Alert (Confirm + Cancel)
SwiftUI iOS confirmation alert with Confirm and Cancel buttons. Beginners guide to building safe actions, destructive deletes, and commit dialogs.

SwiftUI: IOS Haptic Feedback Guide 2026
Add click to vibrate haptic feedback in SwiftUI. Full guide to UIImpactFeedbackgenerator, success, error, selection, and tap vibration patterns with code.

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.
Code copied to clipboard!