Snap Delete
ComponentsSnap Delete
ExperimentsNew

Snap Delete

Delete text, images, or cards in a cloud of dust. Undo restores the content.

USE IT FOREditable canvasesImage collectionsDraft content
React + CSS
Explore the full-width experienceOpen preview
Canvas

Coastal escape

3 objects
FIELD NOTE01

Take the
scenic route.

Leave Friday.
Back on Sunday.

01 Text

Coastal cliffs and a winding road above the ocean at sunset
Coastline study, 01↗

02 Image

off
grid.

03 Sticker

Snap Delete

Delete an object. Undo brings it back.

Live component. Go ahead, interact.
01

Installation

Run this in your shadcn-configured React project. The component and stylesheet are added together.

TERMINAL
npx shadcn@latest add http://localhost:5173/r/snap-delete.json

This command uses the current site address. For localhost, keep this preview running on the same computer. Files follow your configured components alias.

02

Usage

Import the component and make the details your own.

TypeScript
import { SnapDelete } from '@/components/anticraft/SnapDelete';

export function Example() {
  return (
    <SnapDelete label="field note" onDelete={() => console.log('Deleted')}>
      <div style={{ padding: 24, background: '#eae6d2', borderRadius: 2 }}>
        <h3>Field note</h3>
        <p>Take the scenic route.</p>
      </div>
    </SnapDelete>
  );
}
03

Props

PropTypeDefaultDescription
childrenReactNodeRequiredThe removable content. Text, images, and ordinary HTML/CSS cards retain their appearance in the dust. Content remains mounted, hidden and inert after deletion, so Undo preserves local state.
labelstring'Item'Names the item in the native Delete/Undo controls and screen reader announcement.
durationnumber1600Dust animation length in milliseconds, clamped to 600–4000. Nonfinite values use the default.
particleSizenumber3Dust cell size in CSS pixels, clamped to 2–8. Large targets use larger cells to stay within the 12,000-cell limit.
buttonLabelstring'Delete'The action label before deletion. The busy label is Deleting…
restoreLabelstring'Undo'The action label after deletion.
disabledbooleanfalseDisables both actions. An already-running deletion still completes.
onDelete() => voidundefinedCalled once after the visual deletion finishes. Connect persistence here. Removing the component in this callback also removes its Undo control.
onRestore() => voidundefinedCalled once when Undo restores the retained content. Connect your data restoration here if needed.
classNamestring''Additional root classes. Set --ac-snap-delete-accent to customize the Delete control. Allow space around the target for the dust.
04

Motion & accessibility

Considered by default.

A native Delete button splits a frozen copy of the content into small masked fragments, which drift upward and fade from right to left. Native Undo restores it without resetting child state. Decorative copies are hidden from assistive technology, inert, and removed on completion or unmount. Reduced motion skips the animation; hiding the document or scrolling the component offscreen completes the action. Embedded media, more than 160 elements, or unavailable CSS masks use a short fade. The effect runs only after activation and adds no idle animation loop or image-pixel/CORS requirement. It changes visibility locally; data persistence belongs in the callbacks.

Use semantic content and meaningful labels in your composition. Check contrast and keyboard behavior with your own styles and content.