title: SwiftUI dismiss alert by tapping outside of it
body: <p>A similar question in the UIKit: <a href="https://stackoverflow.com/questions/30075832/how-to-dismiss-uialertcontroller-when-tap-outside-the-uialertcontroller">How to dismiss UIAlertController when tap outside the UIAlertController?</a></p>
  <p>I have a basic alert with a few buttons (cancel/delete style).
  I'd like to &quot;dismiss&quot; the alert by tapping outside of it, similarly to what would &quot;cancel&quot; button do:</p>
  <pre><code>struct ContentView: View {
      @State private var showingAlert = false
  
      var body: some View {
          Button(&quot;Show Alert&quot;) {
              showingAlert = true
          }
          .alert(&quot;Important message&quot;, isPresented: $showingAlert) {
              Button(&quot;First&quot;) { }
              Button(&quot;Second&quot;) { }
              Button(&quot;Third&quot;) { }
          }
      }
  }
  </code></pre>
  <p>I tried adding <code>onTapGesture</code> handler, but it didn't help.</p>