A delete button that asks for confirmation in place, no dialog needed.
Click the bin to lift its lid open. A panel slides out with a check to confirm and a cross to back out. Escape backs out too. Confirming draws a check where the bin was, backing out settles the bin in place.
Options you can pass to customize this component.
onConfirm() => voidCalled when the check is pressed.
onCancel() => voidCalled when the panel closes without deleting, from the cross, the bin, or Escape.
classNamestringExtra classes merged onto the root element.
npx shadcn@latest add swamimalode07/rare-ui/delete-button"use client"import { DeleteButton } from "@/components/ui/delete-button"export function Demo() {return <DeleteButton onConfirm={() => remove(id)} />}
Click the code icon in the top-right corner to view the source code.
Most components here are recreations of great work from around the web. I don't claim to be the original creator - this is my attempt to reverse-engineer, replicate, and often add a few extra features. I've tried to credit everyone; if I missed someone, let me know.
1