Soft trash
A trash pill with a real membrane. Drag a file in and it swallows it whole; undo spits it back out.
npx shadcn@latest add https://soft-trash.vercel.app/r/soft-trash.jsonq3-invoices.pdf
old-logo.svg
draft-v2.fig
Soft trash is a Captain family piece with its own repo: github.com/jawadjalal/soft-trash. Install it with the command above.
Usage
import { SoftTrash, useSoftTrash } from "@/components/soft-trash/soft-trash"
const trash = useSoftTrash({ onCommit: (item) => remove(item.id) })
<div ref={trash.item(file.id, file.name)}>{file.name}</div>
<SoftTrash trash={trash} />Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| trash | SoftTrashController | From useSoftTrash(). | |
| onCommit | (item) => void | The undo window closed: delete for real. |
Keyboard
- Delete
- Bin the focused item
- ⌘Z
- Undo
Accessibility
- Keyboard delete and undo do what the drag does.
- Announces what was binned and how to undo.