<!--
{
  "availability" : [
    "iOS: 13.0.0 - 27.2.0",
    "iPadOS: 13.0.0 - 27.2.0",
    "macCatalyst: 13.0.0 - 27.2.0",
    "macOS: 10.15.0 - 27.2.0",
    "tvOS: 13.0.0 - 27.2.0",
    "visionOS: 1.0.0 - 27.2.0",
    "watchOS: 6.0.0 - 27.2.0"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Alert/init(title:message:primaryButton:secondaryButton:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI5AlertV5title7message13primaryButton09secondaryG0AcA4TextV_AISgAC0G0VALtcfc"
  },
  "title" : "init(title:message:primaryButton:secondaryButton:)"
}
-->

# init(title:message:primaryButton:secondaryButton:)

Creates an alert with two buttons.

```
init(title: Text, message: Text? = nil, primaryButton: Alert.Button, secondaryButton: Alert.Button)
```

## Parameters

`title`

The title of the alert.

`message`

The message to display in the body of the alert.

`primaryButton`

The first button to show in the alert.

`secondaryButton`

The second button to show in the alert.

## Discussion

The system determines the visual ordering of the buttons.

---

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)