Swift95

Alert95

A modal Swift95 alert presented from any SwiftUI view.

The alert95 modifier renders a themed modal while preserving native Button roles, enabled state, keyboard shortcuts, and dismissal semantics.

Swift95 alert with actions
The open alert produced after activating the button in the snippet below.

Use it

import Swift95
import SwiftUI

struct Alert95Example: View {
  @State private var isPresented = false

  var body: some View {
    Button95("Replace file") {
      isPresented = true
    }
    .alert95(
      "Replace file?",
      isPresented: $isPresented,
      isCloseButtonEnabled: false,
      icon: {
        Image(systemName: "exclamationmark.triangle.fill")
          .font(.system(size: 40))
      },
      actions: {
        Button("Replace", role: .destructive) {}
        Button("Cancel", role: .cancel) {}
      },
      message: {
        Text("A file with this name already exists.")
      }
    )
  }
}

Essential behavior

ActionsSupply native SwiftUI Button values; Swift95 renders their labels and roles.
DismissalActions and the enabled close control set isPresented to false.
PlatformUses an app modal on compact platforms and a child panel on macOS.

Related

Open the complete Alert95 API reference →