04.22 · Micro-Interactions

Swipe to Dismiss

A card dragged sideways flies off and the list closes up. Best for inboxes.

Drag it

Drag a message sideways and let go, or press Show me.

Press Delete to remove this message.

Try it

Change a setting, then try it again or press Show me.

Distance to delete

How far to drag before letting go deletes it.

A red Delete strip shows behind the card as you drag.

Copy the prompt

Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.

Add swipe to dismiss to [the list items people should be able to remove]. While an item is dragged sideways, it follows the finger exactly and fades a little; when the settings include it, a red Delete label shows behind it. On release, remove it if it went far enough or was flicked quickly: it slides off the edge and its row closes up so the list moves up smoothly. Otherwise it springs back into place. Use pointer events so mouse, touch and pen all work, and let up-and-down scrolling still pass through. Offer an undo, and a button for people who cannot drag. If the visitor has reduced motion turned on, remove the row at once without sliding. Match the settings listed below.

Replace the words in brackets with your own element. Your settings are added at the end.

Free and open source. If this helped, a star on GitHub helps other people find it.

Star on GitHub

What it is

The full explanation is in README.md.

Good for

  • Inboxes
  • Notifications
  • Chat lists
  • To-do lists

Avoid on

  • Permanent deletes
  • Mouse-only tools