<!--
{
  "availability" : [
    "macOS: 15.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/AlertScene",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI10AlertSceneV"
  },
  "title" : "AlertScene"
}
-->

# AlertScene

A scene that renders itself as a standalone alert dialog.

```
nonisolated struct AlertScene<Actions, Message> where Actions : View, Message : View
```

## Overview

Alert scenes present themselves in the center of the current display,
and don’t attach to any particular window. The system prevents interaction
with the app until someone dismisses the alert scene.

```
@main
struct MyApp: App {
    @State var showLoginAlert = true
    @State var loggedIn = false

    var body: some Scene {
        Window("Welcome User Window", id:"WelcomeWindow") {
            ...
        }
        .defaultLaunchBehavior(loggedIn ? .presented : .suppressed)

        AlertScene("Login Required", isPresented: $showLoginAlert) {
            Button("OK") {
                ...
            }
        }
    }
}
```

All the actions you provide in the [`ContentBuilder`](/documentation/SwiftUI/ContentBuilder) dismiss the alert
when someone invokes them. Like the alert modifier, specify the role of
the buttons with [`cancel`](/documentation/SwiftUI/ButtonRole/cancel) or [`destructive`](/documentation/SwiftUI/ButtonRole/destructive). If
you don’t provide any actions, the system automatically includes a button
with the title “OK” that dismisses the alert scene.

## Topics

### Initializers

[`init(_:isPresented:actions:)`](/documentation/SwiftUI/AlertScene/init(_:isPresented:actions:))

Creates an alert scene with a title and a set of actions.
Note that this creates a text view on your behalf.

[`init(_:isPresented:actions:message:)`](/documentation/SwiftUI/AlertScene/init(_:isPresented:actions:message:))

Creates an alert scene with a title, a set of actions, and a message.
Note that this creates a text view on your behalf.

[`init(_:isPresented:presenting:actions:)`](/documentation/SwiftUI/AlertScene/init(_:isPresented:presenting:actions:))

Creates an alert scene, using the given data to produce the alert’s
content with a title, and a set of actions.
Note that this creates a text view on your behalf.

[`init(_:isPresented:presenting:actions:message:)`](/documentation/SwiftUI/AlertScene/init(_:isPresented:presenting:actions:message:))

Creates an alert scene, using the given data to produce the alert’s
content with a title, a set of actions, and a message.
Note that this creates a text view on your behalf.

[`init(_:item:actions:)`](/documentation/SwiftUI/AlertScene/init(_:item:actions:))

Creates an alert scene, using the given data to produce the alert’s
content with a title, and a set of actions.
Note that this creates a text view on your behalf.

[`init(_:item:actions:message:)`](/documentation/SwiftUI/AlertScene/init(_:item:actions:message:))

Creates an alert scene, using the given data to produce the alert’s
content with a title, a set of actions, and a message.
Note that this creates a text view on your behalf.

## Relationships

### Conforms To

[`Scene`](/documentation/SwiftUI/Scene)

---

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)