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-hapticsnpx dissolve-ui add swipe-to-delete toast --nativenpx shadcn@latest add https://dissolve.rselmi.com/r/native/swipe-to-delete.jsonReact
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 --webnpx shadcn@latest add https://dissolve.rselmi.com/r/swipe-to-delete.jsonUsage
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>
));
}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
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | required | The row. It slides with your finger over the delete action. |
onDelete | () => void | required | Called once the row has dissolved and collapsed: remove the item from your data here. |
preset | VariantName | 'dust' | Exit used when the row goes. |
threshold | number | 0.4 | Fraction of the row width to drag before release deletes. A flick faster than 900 pt/s deletes too. |
disabled | boolean | false | Turns the pan gesture off. |
className | string | Outer wrapper (margins, layout). This is the part that collapses. | |
rowClassName | string | 'overflow-hidden' | Clipping row. Corner radius goes here (rounded-2xl), the action follows it. |
actionClassName | string | 'bg-dissolve-danger' | Delete action revealed behind the row. |
Source
- React Native: registry/swipe-to-delete.tsx
- React: registry/web/swipe-to-delete.tsx and registry/web/swipe-to-delete.core.ts
Next: Toast · All components
dissolve is MIT licensed. Source on GitHub, package on npm. This page as markdown. For AI agents: llms.txt.