About these pieces

One self-contained Swift file each, Apple frameworks only, from iOS 17.

Drag to Dismiss is a modifier that lets a photo, card or sheet follow a two-axis drag, rounds and shrinks it with progress over a scrim, reports its phase so your UI can say release to close, then springs back or flies off along the drag vector past a distance or velocity threshold.

For more motion across the library, see the animations collection: card stacks, flips, carousels, text reveals, number rolls and state morphs.

Learn the technique: SwiftUI animations guide.

Questions

How the pieces work, and how to build the same thing yourself. Every piece's page has its full notes.

How do I add drag to dismiss in SwiftUI?

Track a DragGesture's translation, scale and fade the view with progress, and on release dismiss if the distance or predictedEndTranslation passes a threshold, otherwise spring back. Drag to Dismiss wraps this in one modifier.

Next

Ready to build something better?

55 pieces, one file each, yours to keep. Start with the library or see what the whole app looks like.