Skip to content

Swipe to Dismiss

B.Cem edited this page Jul 28, 2026 · 1 revision

Swipe to Dismiss

By default a dialog can be dragged away. Past a small threshold it dismisses; a shorter drag springs back.


Disabling it

Apply peekInteractiveDismissDisabled() inside the content closure (same place as .dialogStyle). Mirrors Apple's interactiveDismissDisabled on sheets.

.peekDialog(isPresented: $showDialog, dismissDelay: .long) {
    HStack {
        Text("You have a new message")
        Spacer()
        Button("View") { /* ... */ }
    }
    .padding()
    .peekInteractiveDismissDisabled()
}

When disabled, the dialog only leaves via dismissDelay or clearing the binding. Buttons and auto-dismiss still work — only the swipe gesture is off.

Toggle from state:

.peekInteractiveDismissDisabled(isLocked)

Where it belongs

Like .dialogStyle, this must sit on the content inside peekDialog. Outside the closure it is ignored — Common Mistakes.

Getting Started · Home

Clone this wiki locally