---
title: "alert(isPresented:content:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/alert(ispresented:content:)"
---

# alert(isPresented:content:)

Presents an alert to the user.

## Declaration

```swift
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

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")))         }     } }

## See Also

### View presentation modifiers

- [actionSheet(isPresented:content:)](swiftui/view/actionsheet(ispresented:content:).md)
- [actionSheet(item:content:)](swiftui/view/actionsheet(item:content:).md)
- [alert(item:content:)](swiftui/view/alert(item:content:).md)
