Swiftpack.co - divadretlaw/CustomAlert as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by divadretlaw.
divadretlaw/CustomAlert v2.4.0
🔔 Custom Alert for SwiftUI
⭐️ 110
🕓 31 weeks ago
.package(url: "https://github.com/divadretlaw/CustomAlert.git", from: "v2.4.0")



In iOS Alerts cannot contain Images or anything other than Text. This allows you to easily customize the message part with any custom view.

While the alert is completely rebuilt in SwiftUI, it has been designed to look and behave exactly like a native alert. The alert uses it's own window to be displayed and utilizes accessibility scaling but with the advantage of a custom view.

If the content is too large because the text is too long or the text doesn't fit because of accessibility scaling the content will scroll just like in a SwiftUI Alert.


SwiftUI Alert Custom Alert
Native Alert Custom Alert

You can easily add an Image or change the Font used in src="https://raw.github.com/divadretlaw/CustomAlert/main/lert, or anything else to your imagination.

Something simple with an image and a text field

<img style="max-width:100%;" src="src="https://raw.github.com/divadretlaw/CustomAlert/main/es/CustomAlert/Documentation.docc/Resources/Fancy.png" width="300">

Or more complex layouts

The API is very similar to the SwiftUI Alerts

.customAlert("Some Fancy Alert", isPresented: $showAlert) {
    Text("I'm a custom Message")
        .font(.custom("Noteworthy", size: 24))
    Image(systemName: "swift")
        .frame(maxHeight: 100)
} actions: {
    Button {
        // some Action
    } label: {
        Label("Swift", systemImage: "swift")
    Button(role: .cancel) {
        // some Action
    } label: {

You can create Side by Side Buttons using MultiButton

.customAlert("Alert with Side by Side Buttons", isPresented: $showAlert) {
    Text("Choose left or right")
} actions: {
	MultiButton {
	    Button {
	        // some Action
	    } label: {
	    Button {
	        // some Action
	    } lasrc="https://raw.github.com/divadretlaw/CustomAlert/main/{

The alert is customizable via the Environment

.configureCustomAlert { configuration in
    // Adapt tsrc="https://raw.github.com/divadretlaw/CustomAlert/main/fault configuration

You can also display an Alert inline, within a List for example

InlineAlert {
    // Content
} actions: {
    // Actions






Copyright © 2024 David Walter (www.davidwalter.at)


Stars: 110
Last commit: Yesterday
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics