Alert Toast Notification

Global toast-style alert overlay with preset styles (info, success, warning, error) and auto-dismiss

Free
Free with a ShipSwift account.

Copies a short instruction with your private download link. Paste it into your agent: it downloads the whole skill (the source code, the setup steps and the mistakes we already made for you) and builds the screen.

Works with

+70

What it does

Global alert overlay that displays toast-style notifications at the top of the screen. Supports four preset styles (info, success, warning, error) and fully custom styling. Auto-dismisses after a configurable duration.

On iOS the toast renders in a dedicated top-level UIWindow (windowLevel above system alerts, hit-test passthrough) — it is never covered by sheets or fullScreenCovers, so alerts fired from inside a sheet show instantly. On macOS it stays a root-view overlay. Public API is identical on both platforms.

What you get

  • ✓357 lines of source code, ready to paste
  • ✓Source Code
  • ✓Usage
componentfeedbackalerttoastnotificationSwiftUI

Usage

// 1. Attach the modifier at your App entry point (once):
@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .swAlert()
        }
    }
}

// 2. Show an alert from anywhere using the singleton:
SWAlertManager.shared.show(.success, message: "Saved!")
SWAlertManager.shared.show(.error, message: "Something went wrong")
SWAlertManager.shared.show(.warning, message: "Slow connection", duration: .seconds(5))

// 3. Fully custom style:
SWAlertManager.shared.show(
    icon: "star.fill",
    message: "Custom alert",
    textColor: .yellow,
    backgroundStyle: AnyShapeStyle(.black),
    borderColor: .yellow
)

// 4. Dismiss programmatically (optional -- alerts auto-dismiss):
SWAlertManager.shared.dismiss()