LayerwiseLayerwise
  • Features
  • Pricing
  • Templates
  • Docs
DownloadDownload
FeaturesPricingTemplatesDocsAI Website BuilderVibe CodingPersonal Software
DownloadDownload
  1. Glossary
  2. /
  3. Interaction feedback

Swipe to dismiss

Also called swipe away or swipe to delete

A gesture where you drag an item sideways past a threshold to remove it, while a shorter swipe lets it spring back into place.

import { useRef } from 'react';
import { animate, motion, useMotionValue, useTransform } from 'motion/react';

const DISTANCE_THRESHOLD = 0.4; // share of the card's width
const VELOCITY_THRESHOLD = 500; // px per second, so a quick flick counts

type NotificationCardProps = {
  title: string;
  body: string;
  onDismiss: () => void;
};

// Render inside a list: `layout` slides the cards below up when one leaves.
export function NotificationCard({
  title,
  body,
  onDismiss
}: NotificationCardProps) {
  const ref = useRef<HTMLLIElement>(null);
  const x = useMotionValue(0);
  const opacity = useTransform(x, [-200, 0, 200], [0, 1, 0]);

  async function flyOut(direction: number) {
    const width = ref.current!.offsetWidth;
    await animate(x, direction * width, { duration: 0.25, ease: 'easeIn' });
    onDismiss();
  }

  return (
    <motion.li
      ref={ref}
      layout
      drag='x' // horizontal only, so vertical scrolling still works
      dragSnapToOrigin // a short swipe springs back into place
      style={{ x, opacity }}
      onDragEnd={(_, { offset, velocity }) => {
        const width = ref.current!.offsetWidth;
        const far = Math.abs(offset.x) > width * DISTANCE_THRESHOLD;
        const fast = Math.abs(velocity.x) > VELOCITY_THRESHOLD;
        if (far || fast) flyOut(Math.sign(fast ? velocity.x : offset.x));
      }}
      className='flex items-start gap-3 rounded-xl border bg-background p-3 shadow-sm'
    >
      <div className='flex-1'>
        <p className='text-sm font-medium'>{title}</p>
        <p className='text-sm text-muted-foreground'>{body}</p>
      </div>
      {/* Swiping is invisible, so mouse and keyboard users get a button. */}
      <button
        type='button'
        onClick={() => flyOut(1)}
        aria-label='Dismiss notification'
        className='rounded-md px-1.5 text-muted-foreground hover:bg-muted'
      >
        ✕
      </button>
    </motion.li>
  );
}
Make the notification cards swipe to dismiss with Motion: drag only on the x axis, fade the card as it moves, and dismiss it when released past 40% of its width or faster than 500px/s, animating it off screen over 250ms. Otherwise spring it back to its place. Slide the remaining cards up to close the gap, and keep a visible close button for mouse and keyboard users.

Paste into Layerwise or any AI coding tool.

What is Swipe to dismiss?

Swipe to dismiss lets people clear a notification, toast, or list item by flicking it away. The item follows the finger sideways and fades as it goes. Past a threshold, often 30 to 50% of its width, it flies off and the items below slide up to close the gap. A shorter drag springs it back.

Check speed as well as distance: a quick flick should dismiss even when the finger travels only a little. Lock the gesture to the horizontal axis so vertical scrolling still works.

Swiping is invisible until someone tries it, so also show a close button or menu action for mouse and keyboard users, and offer undo when dismissing deletes something.

Related terms

All terms

Drag gesture

Moving an element by pressing on it and sliding the pointer or finger, usually within set bounds and with a glide after release.

Velocity

The speed and direction an element already has when an animation starts, which a spring carries forward so a flick flows into what follows.

Toast notification

A brief message that slides into a corner of the screen to confirm an action, then disappears on its own after a few seconds.

Undo

A way to reverse an action right after doing it, often a toast with an Undo button that appears after deleting or archiving something.

Build it with Layerwise

Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.

DownloadDownloadRead the docs
LayerwiseLayerwise

Build full-stack web apps in minutes with AI.

Product

  • Features
  • Pricing
  • Download
  • Templates

Solutions

  • AI Website Builder
  • Vibe Coding
  • Personal Software

Resources

  • Documentation
  • Changelog
  • Blog
  • Vibe Coding Glossary
  • llms.txt
  • llms-full.txt

Company

  • About
  • Contact

Legal

  • Privacy
  • Analytics Privacy
  • Terms
  • Security
  • Abuse

© 2026 Layerwise. All rights reserved.

Entrances & exits

  • Fade in
  • Slide in
  • Scale in
  • Pop in
  • Blur in
  • Reveal animation
  • Enter and exit animations

Timing & sequencing

  • Duration
  • Delay
  • Keyframes
  • Tweening
  • Stagger
  • Orchestration
  • Fill mode
  • Stepped animation
  • Looping animation
  • Yoyo animation

Easing

  • Easing
  • Linear easing
  • Ease-in
  • Ease-out
  • Ease-in-out
  • Cubic-bezier
  • Asymmetric easing
  • Overshoot easing

Springs & physics

  • Spring animation
  • Stiffness
  • Damping
  • Mass
  • Bounce
  • Velocity
  • Momentum
  • Interruptible animation
  • Rubber-banding

Transforms

  • Translate
  • Scale
  • Rotate
  • Skew
  • 3D flip
  • Perspective
  • Transform origin
  • Origin-aware animation

State transitions

  • Crossfade
  • Morph
  • Shared element transition
  • Layout animation
  • Height auto animation
  • Direction-aware transition
  • Continuity transition
  • Page transition
  • View Transitions API

Scroll effects

  • Scroll reveal
  • Scroll-driven animation
  • Parallax scrolling
  • Scrollytelling
  • Scroll pinning
  • Horizontal scroll section
  • Scroll progress bar
  • Scroll snap
  • Smooth scrolling

Interaction feedback

  • Hover effect
  • Press feedback
  • Ripple effect
  • Shake animation
  • Hold to confirm
  • Drag gesture
  • Drag to reorder
  • Swipe to dismiss
  • Pull to refresh
  • Magnetic button
  • Custom cursor
  • 3D tilt card
  • Spotlight card

Text effects

  • Typewriter effect
  • Text scramble
  • Split text animation
  • Text morph
  • Rotating words
  • Gradient text
  • Shimmer text
  • Number ticker
  • Tabular numbers
  • Underline animation

Loops & ambient motion

  • Marquee
  • Pulse animation
  • Float animation
  • Orbit animation
  • Idle animation
  • Particle background
  • Border beam
  • Confetti
  • Animated gradient

Visual effects

  • Blur
  • Clip-path
  • Mask
  • Before/after slider
  • SVG line drawing
  • Lottie animation

Motion principles

  • Purposeful animation
  • Anticipation
  • Follow-through
  • Squash and stretch
  • Perceived performance
  • Frequency of use
  • Spatial consistency
  • Reduced motion

Animation performance

  • Frame rate (FPS)
  • Jank
  • GPU acceleration
  • will-change
  • Layout thrashing

Layout

  • Hero section
  • Above the fold
  • Sticky header
  • Sidebar
  • Bento grid
  • Card
  • Flexbox
  • CSS Grid
  • Padding vs margin
  • Responsive design
  • Container
  • Masonry layout
  • Split screen
  • Z-index
  • Overflow

Components

  • Button variants
  • Modal
  • Drawer
  • Popover
  • Tooltip
  • Dropdown menu
  • Context menu
  • Toast notification
  • Tabs
  • Segmented control
  • Accordion
  • Carousel
  • Command palette
  • Combobox
  • Toggle switch
  • Checkbox
  • Radio button
  • Date picker
  • Breadcrumb
  • Pagination
  • Infinite scroll
  • Badge
  • Avatar stack
  • Empty state
  • Skeleton screen
  • Spinner
  • Progress bar
  • Data table
  • Stepper
  • Floating label
  • Inline validation
  • Alert banner
  • Tag input

States & patterns

  • Interaction states
  • Focus ring
  • Loading state
  • Optimistic UI
  • Debounce
  • Lazy loading
  • Dark mode
  • Micro-interaction
  • Affordance
  • Undo
  • Drag and drop
  • Keyboard shortcut

Visual styles

  • Glassmorphism
  • Liquid glass
  • Neumorphism
  • Claymorphism
  • Neo-brutalism
  • Skeuomorphism
  • Flat design
  • Mesh gradient
  • Aurora background
  • Grain texture
  • Glow effect
  • Drop shadow
  • Border radius
  • Grid background
  • Typographic hierarchy
  • Accent color
  • Color contrast

Vibe coding & AI

  • Vibe coding
  • Prompt
  • Context window
  • Token
  • AI agent
  • Tool call
  • Hallucination
  • Diff
  • Live preview
  • Checkpoint
  • Git commit
  • Deploy
  • Frontend and backend
  • API
  • Database
  • Rules file
  • MCP
  • Plan mode
  • Visual edit
Maya ChenSent the final mockupsnow
Build succeededYour site is live2m
Design reviewStarts in 10 minutes5m