Alert Toast Notification
Global toast-style alert overlay with preset styles (info, success, warning, error) and auto-dismiss
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
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
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()More in Components
- Add SheetFreeBottom sheet with text input field, Cancel and Continue buttons, presented as a medium detent sheet
- Bullet Point TextFreeText label with a colored capsule bullet point indicator that accepts any View content via @ViewBuilder
- Cached ImageFreeAsyncImage drop-in with a memory + disk cache, so re-created views show remote images on the first frame instead of flashing the placeholder
- Floating LabelsFreeAnimated floating capsule labels that fade in and out at specified positions around an image
- Gradient DividerFreeHorizontal divider with a center-fade gradient effect (clear to color to clear)
- Image ThumbnailFreeReusable rounded image thumbnail with same-named ColorSet fallback — perfect for product cards, avatars, and cover images