SwipeToDelete

SwipeToDelete is an animated swipe to delete component for React Native and React, from the dissolve library. Swipe a row left to delete it: it dissolves, then the list closes up.

A row you swipe left to delete, like Mail or WhatsApp. Past 40 percent, or with a quick flick, the row dissolves, the list closes up behind it, then onDelete runs.

Install

React Native

Install the engine once per app and wrap the root layout in <DissolveProvider> (see Installation), then copy the component into components/dissolve:

npx expo install dissolve-ui @shopify/react-native-skia react-native-reanimated react-native-worklets react-native-gesture-handler expo-haptics
npx dissolve-ui add swipe-to-delete toast --native
npx shadcn@latest add https://dissolve.rselmi.com/r/native/swipe-to-delete.json

React

Needs React 19 and react-dom, nothing else: no engine, no provider, no Tailwind. Works in the Next.js App Router.

npx dissolve-ui add swipe-to-delete toast --web
npx shadcn@latest add https://dissolve.rselmi.com/r/swipe-to-delete.json

Usage

SwipeToDelete.tsx (React Native)
import { useState } from 'react';
import { SwipeToDelete } from '@/components/dissolve/swipe-to-delete';
import { useToast } from '@/components/dissolve/toast';

export function Inbox() {
  const [mails, setMails] = useState(MAILS);
  const toast = useToast();

  return mails.map((m) => (
    <SwipeToDelete
      key={m.id}
      rowClassName="rounded-[18px]"
      onDelete={() => {
        setMails((l) => l.filter((x) => x.id !== m.id));
        toast.show({
          title: 'Conversation deleted',
          message: m.from,
          action: { label: 'Undo', onPress: () => restore(m) },
        });
      }}
    >
      <MailRow mail={m} />
    </SwipeToDelete>
  ));
}
SwipeToDelete.tsx (React)
import { useState } from 'react';
import { SwipeToDelete } from '@/components/dissolve/swipe-to-delete';
import { useToast } from '@/components/dissolve/toast';

export function Inbox() {
  const [mails, setMails] = useState(MAILS);
  const toast = useToast();

  return mails.map((m) => (
    <SwipeToDelete
      key={m.id}
      rowClassName="rounded-[18px]"
      onDelete={() => {
        setMails((l) => l.filter((x) => x.id !== m.id));
        toast.show({
          title: 'Conversation deleted',
          message: m.from,
          action: { label: 'Undo', onPress: () => restore(m) },
        });
      }}
    >
      <MailRow mail={m} />
    </SwipeToDelete>
  ));
}

Props

PropTypeDefaultDescription
childrenReactNoderequiredThe row. It slides with your finger over the delete action.
onDelete() => voidrequiredCalled once the row has dissolved and collapsed: remove the item from your data here.
presetVariantName'dust'Exit used when the row goes.
thresholdnumber0.4Fraction of the row width to drag before release deletes. A flick faster than 900 pt/s deletes too.
disabledbooleanfalseTurns the pan gesture off.
classNamestringOuter wrapper (margins, layout). This is the part that collapses.
rowClassNamestring'overflow-hidden'Clipping row. Corner radius goes here (rounded-2xl), the action follows it.
actionClassNamestring'bg-dissolve-danger'Delete action revealed behind the row.

Source

Next: Toast · All components

dissolve is MIT licensed. Source on GitHub, package on npm. This page as markdown. For AI agents: llms.txt.