Captain UI

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.json
q3-invoices.pdf
old-logo.svg
draft-v2.fig

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

PropTypeDefaultWhat it does
trashSoftTrashControllerFrom useSoftTrash().
onCommit(item) => voidThe 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.