Swipe to Delete
A list row that slides aside to show its actions; swipe all the way to run the main one.
PROGet Swipe to Delete and 168 other Pro components with pro lifetime — Get Pro
- Category
- Data & feedback
- Access
- ProPro · unlocked
- Source
- 214 lines · one file
- States
- 5 drawn
The decision inside it
Never swipe-only
A More button on every row opens the same actions, and they are real buttons in the tab order only while showing.
When to use it
Use SwipeRow in a list people manage on a phone (an inbox, notifications, a queue) for quick actions like archive and delete. Every row also gets a More button, so it works without swiping.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Liro's Swipe to Delete for this.
Install it: npx shadcn@latest add @liro/swipe-to-delete
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/swipe-to-delete.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.
Usage
import { Archive, Trash2 } from "lucide-react";
import { SwipeRow } from "@/components/ui/swipe-to-delete";
export function InboxRow({ title, archive, remove }: { title: string; archive: () => void; remove: () => void }) {
return (
<SwipeRow
fullSwipeAction={1}
actions={[
{ label: "Archive", icon: <Archive />, onAction: archive },
{ label: "Delete", icon: <Trash2 />, tone: "destructive", onAction: remove },
]}
>
<div className="px-4 py-3">{title}</div>
</SwipeRow>
);
}API reference
“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Type | Notes | ||
|---|---|---|---|
children | React.ReactNode | Yes | – |
actions | SwipeAction[] | Yes | One to three actions, nearest the content first. |
side | "left" | "right" | No | Which side the actions sit on. "right" means swipe left to see them. Default "right". |
threshold | number | No | Share of the row's width (0 to 1) past which a full swipe runs the action. Default 0.6. |
fullSwipeAction | number | No | Index in `actions` that a full swipe runs. Leave out for no full swipe. |
actionWidth | number | No | Width of each action, in pixels. Default 76. |
open | boolean | No | – |
onOpenChange | (open: boolean) => void | No | – |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-themeStates
All of them are drawn by the component. None is left for you to design.
- Rest
- Open
- Armed for full swipe
- Left side
- Keyboard
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances