<!--
{
  "availability" : [
    "iOS: 13.0.0 - 27.0.0",
    "iPadOS: 13.0.0 - 27.0.0",
    "macCatalyst: 13.0.0 - 27.0.0",
    "macOS: 10.15.0 - 27.0.0",
    "tvOS: 13.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0",
    "watchOS: 6.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/alert(isPresented:content:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE5alert11isPresented7contentQrAA7BindingVySbG_AA5AlertVyXEtF"
  },
  "title" : "alert(isPresented:content:)"
}
-->

# alert(isPresented:content:)

Presents an alert to the user.

```
nonisolated func alert(isPresented: Binding<Bool>, content: () -> Alert) -> some View
```

## Parameters

`isPresented`

A binding to a Boolean value that determines whether
to present the alert that you create in the modifier’s `content` closure. When the
user presses or taps OK the system sets `isPresented` to `false`
which dismisses the alert.

`content`

A closure returning the alert to present.

## Discussion

Use this method when you need to show an alert to the user. The example
below displays an alert that is shown when the user toggles a
Boolean value that controls the presentation of the alert:

```
struct OrderCompleteAlert: View {
    @State private var isPresented = false
    var body: some View {
        Button("Show Alert", action: {
            isPresented = true
        })
        .alert(isPresented: $isPresented) {
            Alert(title: Text("Order Complete"),
                  message: Text("Thank you for shopping with us."),
                  dismissButton: .default(Text("OK")))
        }
    }
}
```

![An alert whose title reads Order Complete, with the message, Thank you for shopping with us placed underneath. The alert also includes an OK button for dismissing the alert.](images/com.apple.SwiftUI/SwiftUI-View-AlertIsPresentedContent@2x.png)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)