Swipe to Delete

A swipeable list item that reveals an iOS-style delete action on drag.

@spectrumui/swipe-to-delete
ACAva Chen9:41 AMDesign review notes — the new empty states look great
MRMarcus Reid8:17 AMRe: Q3 roadmap — can we move the sync to Thursday?
PNPriya NairYesterdayYour invoice for June is ready to download

Drag a row left to delete — or hover for the button

Installation

Login to view commandCreate a free account to access the install command

Usage

import { SwipeToDelete } from "@/components/spectrumui/swipe-to-delete"
<SwipeToDelete label="email from Ava" onDelete={() => removeEmail(id)}>
  <EmailRow />
</SwipeToDelete>

API Reference

SwipeToDelete

Wraps its children as the draggable row of a role="group" wrapper named by label. Pressing Delete or Backspace while the wrapper is focused deletes the row, and onDelete fires only after the collapse animation finishes — remove the item from state there.

PropTypeDefaultDescription
*onDelete() => void-Fires once the collapse animation finishes; remove the item here
*childrenReactNode-Row content rendered on the draggable surface
labelstring"item"Accessible name of the row; also used for the delete button label
actionWidthnumber96Width in pixels of the revealed delete zone
thresholdnumber0.6Fraction of actionWidth the drag must pass to commit the delete
showButtonOnHoverbooleantrueShow a fallback delete button on row hover/focus for non-touch users
disabledbooleanfalseDisables dragging, the delete button and keyboard deletion
classNamestring-Additional classes merged with the default wrapper styles

Examples

Custom action width and threshold

Ship onboarding flowToday
Review pull requestsToday
Update changelogTomorrow

A wider action zone (120px) that commits at 40% of the swipe