Alert is used in SwiftUI to show important messages or ask the user to make a quick decision.
It allows apps to:
display warnings
show important information
ask for confirmation
Core flow:
Button / State Change → Alert Appears → User Chooses Action
An alert presents a system dialog on top of the current screen.
It is commonly used for:
warnings
errors
confirmations
critical user actions
The alert usually contains:
a title
a message
one or more buttons
.alert("Title", isPresented: $showAlert) {
Button("OK") { }
} message: {
Text("Message")
}
Here:
"Title" → alert title
isPresented → controls when alert appears
Button → user action
Text("Message") → alert message