-
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
B.Cem edited this page Jul 28, 2026
·
3 revisions
Toast and banner notifications for SwiftUI — same binding-based API as .sheet and .alert. Drop in any view as content, auto-dismiss or swipe away, style it however you want.
On iOS, dialogs live in their own overlay window so they sit above sheets, alerts, and the rest of your UI. Multiple notifications can stack into a queue.
| Familiar API |
isPresented: and with: bindings, just like Apple's presentation modifiers |
| Any content | Text, buttons, images, custom layouts — it's just a SwiftUI view |
| Auto-dismiss |
.short / .medium / .long / .custom(seconds:) / .persistent
|
| Swipe to dismiss | On by default; turn it off with .peekInteractiveDismissDisabled()
|
| Styles |
.plain for full control, glass styles on iOS 26+, or roll your own DialogStyle
|
| Stacking (iOS) |
peekDialog(items:) queues notifications; top two stay visible |
| Over everything (iOS) | Window-based presentation above sheets and alerts |
import SwiftUI
import PeekDialog
struct ContentView: View {
@State private var showDialog = false
var body: some View {
Button("Show") { showDialog = true }
.peekDialog(isPresented: $showDialog, dismissDelay: .medium) {
HStack {
Image(systemName: "checkmark.circle.fill")
.foregroundColor(.green)
Text("Saved")
Spacer()
}
.padding()
}
}
}That's it. Bind state → describe content → PeekDialog handles the rest.
Gotcha:
.dialogStyleand.peekInteractiveDismissDisabledmust go inside the content closure. Putting them on the view that has.peekDialogdoes nothing. See Common Mistakes.
| Guide | What's in it |
|---|---|
| Installation | SPM / Xcode setup |
| Getting Started | Boolean & optional bindings, dismissal, onDismiss
|
| Duration and Placement | Delay presets and top / center / bottom placement |
| Swipe to Dismiss | Enabling / disabling drag-to-dismiss |
| Stacking | Queued notifications with peekDialog(items:) (iOS)
|
| Styling | Built-in styles and .plain
|
| Custom Styles | Writing your own DialogStyle
|
| Common Mistakes | Preference keys outside the closure, and other traps |
| Platform | Presentation | Stacking |
|---|---|---|
| iOS | Overlay window (above sheets) | Yes — peekDialog(items:)
|
| macOS / watchOS / visionOS | In-hierarchy overlay | Single dialog only |