dialogSeverity(_:)
Sets the severity for alerts.
Declaration
nonisolated func dialogSeverity(_ severity: DialogSeverity) -> some Scene
Parameters
- severity:
The severity to use for alerts.
Discussion
The following example configures an alert for erasing some number of items. Since this operation is destructive and non-recoverable, a .critical severity is used.
struct MyApp: App {
@State private var isShowingDialog = false
var body: some Scene {
Window(...) {
Button("Delete items") {
isShowingDialog = true
}
}
AlertScene(
"Are you sure you want to erase these items?",
isPresented: $isShowingDialog
) {
Button("Erase", role: .destructive) {
// Handle item deletion.
}
Button("Cancel", role: .cancel) {
// Handle cancellation
}
}
.dialogSeverity(.critical)
}
}