
Alert Dialog
From syxUI — written for both platforms, not translated between them.
A two-button iOS alert.
Cards · SwiftUI · iOS 17
- cards
- swiftui
The actual source
AlertDialog.swift
// Alert Dialog · syxUI · https://syxui.dev/components/sheet-alert
// Free in any project. Keep this line and credit syxUI where a person can read it.
import SwiftUI
let shBlue = Color(red: 0.0, green: 0.47, blue: 1.0)
func shCard<C: View>(_ w: CGFloat, radius: CGFloat = 18, @ViewBuilder _ c: () -> C) -> some View {
c().frame(width: w).background(Color(.systemBackground), in: RoundedRectangle(cornerRadius: radius, style: .continuous)).overlay(RoundedRectangle(cornerRadius: radius, style: .continuous).stroke(Color.primary.opacity(0.07), lineWidth: 1)).shadow(color: .black.opacity(0.05), radius: 12, y: 5)
}
// iOS two-button alert
struct AlertDialog: View {
var body: some View {
shCard(272) {
VStack(spacing: 0) {
VStack(spacing: 6) { Text("Enable Notifications?").font(.system(size: 16, weight: .semibold)); Text("Stay up to date with activity and messages.").font(.system(size: 13)).foregroundStyle(.secondary).multilineTextAlignment(.center) }.padding(18)
Divider()
HStack(spacing: 0) { Text("Not Now").font(.system(size: 16)).foregroundStyle(shBlue).frame(maxWidth: .infinity).padding(.vertical, 12); Divider().frame(height: 44); Text("Allow").font(.system(size: 16, weight: .semibold)).foregroundStyle(shBlue).frame(maxWidth: .infinity).padding(.vertical, 12) }
}
}
}
}
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17


