Installnpx shadcn@latest add https://motion-lexicon.pages.dev/r/primitive-swipe-to-dismiss.json
- Purpose
- Map swipe distance to travel and opacity so the dismissal outcome stays predictable.
- Trigger
- Trigger after drag crosses an activation threshold, locking to the primary axis first.
- Interruptibility
- Reverse progress immediately with drag direction, using current position to settle after pointercancel.
- Reduced motion
- Use a static close button and immediate removal with undo feedback, removing large off-screen travel.
swipe-to-dismissSwipe to dismissA directional drag removes a surface after distance or velocity crosses a dismissal threshold.
rubber-bandingRubber-bandingMovement beyond a boundary is attenuated, then restored toward the valid range after release.