SwiftUI gesture and motion modifiers
Gesture modifiers with real physics you attach to your own views, starting with drag to dismiss for photos, cards and sheets.
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.
Keep browsing
Nearby collections, then every category in the library.
- AnimationsSprings, gesture physics, transitions and morphs, across every category.16
- MediaPhoto viewing and story playback.2
- CardsCards with depth, motion, parallax and gesture-driven stacks.4
- TextType that reveals, expands and renders as glass.3
- BackgroundsQuiet atmospheres: a Metal silk shader and a touch-reactive dot grid.2
- Liquid GlassCorrect iOS 26 Liquid Glass with Material fallbacks.3
- Buttons and controlsButtons and dials with press depth, hold, drag and outcome states.5
- Inputs and formsTracks, steppers, rails and fields built for the thumb.9
- ListsRows and carousels with swipe, depth and completion physics.5
- NavigationFloating docks, tracking tabs and stretchy headers.3
- SheetsToasts, confirmations and permission moments.3
- FeedbackReactions, ratings, status morphs, skeletons and outcomes.5
- Data and chartsScrubbable charts, rings, live stats and odometers.4
- AIStreaming replies, thinking states, prompt chips and code.6
- HapticsPieces that tick, tap and confirm at the moment that matters.19
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.