Skip to content

Radix UI Toast Swipe to Dismiss Not Working — Fix Gesture

DodaTech Updated 2026-06-24 1 min read

In this fix, you'll learn how to enable swipe-to-dismiss on Radix UI Toasts. This matters for mobile-friendly notification dismiss, and appears in notification systems and alert components.

The Problem

The following code demonstrates the typical mistake:

<Toast>
  <ToastTitle>Notification</ToastTitle>
  <ToastDescription>You have a new message</ToastDescription>
</Toast>
// Swiping doesn't dismiss the toast

The Fix

Here is the corrected version:

<Toast
  swipeDirection="right"
  swipeThreshold={50}
>
  <div className="flex items-start gap-3">
    <div className="flex-1">
      <ToastTitle>Notification</ToastTitle>
      <ToastDescription>You have a new message</ToastDescription>
    </div>
    <ToastClose />
  </div>
</Toast>
// Swiping right dismisses the toast with animation

Prevention

  • Set swipeDirection to 'right', 'left', 'up', 'down', or multiple: ['right', 'left'].
  • swipeThreshold controls how far the user must swipe (in pixels) before dismiss triggers.
  • Combine with AnimatePresence for smooth swipe-out animation.
  • onSwipeEnd callback fires when the swipe gesture completes.
  • ToastClose button still works alongside swipe gesture.

Common Mistakes with ui toast swipe

  1. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
  2. Using return to exit a function early instead of wrapping a pure value in the monad
  3. Mixing let bindings with <- bindings in do notation, producing type errors

These mistakes appear frequently in real-world RADIX code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Does Radix UI Toast support swipe-to-dismiss out of the box?

Yes — swipeDirection and swipeThreshold are built-in props. The Toast provider handles the gesture detection and dismiss animation.

Can I customize the swipe animation?

Yes — use the onSwipeStart, onSwipeMove, and onSwipeEnd callbacks. Or use the data-swipe-direction, data-swipe-move-x, and data-swipe-move-y attributes for CSS animations.

Does swipe work on mobile and desktop?

Yes — Radix UI Toast swipe works with both touch and mouse events. Test on both platforms for consistent behavior. swipeThreshold may need adjustment for mouse vs touch sensitivity.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro