Delete

DeleteIcon is an animated trash-can icon React component built on motion/react that lifts its lid and nudges the body and inner lines when hovered or when controlled via a ref. It renders an inline SVG at a configurable size and forwards extra props to its wrapping div.

Delete
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

pnpm dlx shadcn@latest add https://lucide-animated.com/r/delete.json

Usage

usage.tsx
import { DeleteIcon } from "@/components/ui/delete";export function Example() {  return <DeleteIcon size={24} className="text-red-500" />;}
  • Delete, remove, or trash actions in toolbars, list rows, cards, or table cells where a recognizable bin icon is needed.
  • Destructive buttons or menu items that should give subtle hover feedback without a heavy animation.
  • Interfaces that need an imperative animation trigger, such as playing the motion when a delete request starts or when an item is removed.
  • Projects already using motion/react that want a consistent Lucide-style icon with a playful micro-interaction.

Examples

Basic hover icon

Renders the icon at the default 28px size; the lid and body animate on mouse enter and leave.

basic-hover-icon.tsx
import { DeleteIcon } from "@/components/ui/delete";export default function BasicDelete() {  return <DeleteIcon />;}

Icon button with imperative control

Uses a ref to play the animation programmatically when a delete action starts, and stops it when the action finishes. Mouse handlers are ignored once a ref is attached.

icon-button-with-imperative-control.tsx
"use client";import { useRef } from "react";import { DeleteIcon, type DeleteIconHandle } from "@/components/ui/delete";export default function DeleteButton({ onDelete }: { onDelete: () => Promise<void> }) {  const iconRef = useRef<DeleteIconHandle>(null);  const handleClick = async () => {    iconRef.current?.startAnimation();    await onDelete();    iconRef.current?.stopAnimation();  };  return (    <button type="button" onClick={handleClick} className="inline-flex items-center gap-2 rounded-md border px-3 py-2">      <DeleteIcon ref={iconRef} size={18} />      Delete    </button>  );}

Destructive menu item

Places the icon inside a row with a red destructive tone, using Tailwind classes passed through className.

destructive-menu-item.tsx
import { DeleteIcon } from "@/components/ui/delete";export default function MenuDeleteItem() {  return (    <div role="menuitem" tabIndex={0} className="flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-red-600 hover:bg-red-50">      <DeleteIcon size={16} />      <span>Delete file</span>    </div>  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the SVG in pixels.
classNamestring—Class names applied to the wrapping div (passed through cn).
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Mouse enter handler on the wrapper div. Called instead of the built-in hover animation when a ref is attached.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Mouse leave handler on the wrapper div. Called instead of the built-in hover animation when a ref is attached.
refReact.Ref<DeleteIconHandle>—Exposes startAnimation() (plays the animated state) and stopAnimation() (returns to the normal state). Attaching the ref disables automatic hover animation.
...propsHTMLAttributes<HTMLDivElement>—All other standard div attributes are spread onto the wrapping div, such as id, style, aria-label, and onClick.

Accessibility

  • The SVG has no title or role attribute, so give the wrapper or parent control an accessible name such as aria-label="Delete" or visible text.
  • If the icon is purely decorative next to a visible label, add aria-hidden="true" to the DeleteIcon element.
  • The animation is a small position and shape change and does not flash, so it is safe for reduced-motion contexts; consider skipping the ref-triggered animation when prefers-reduced-motion is set.
  • When used inside an interactive element, the parent must be focusable and keyboard-operable, since the icon wrapper itself is a non-interactive div.
  • Icon color comes from currentColor, so ensure sufficient contrast against the background in both light and dark themes.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Delete" component (lucide-animated/delete) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/delete.json2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: size, className, onMouseEnter, onMouseLeave, ref, ...props.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { DeleteIcon } from "@/components/ui/delete";export function Example() {  return <DeleteIcon size={24} className="text-red-500" />;}```

Files & dependencies

  • delete.tsx
dependenciesmotion

Looks similar, elsewhere