folder-minus

An animated folder-minus icon for React that draws a minus sign inside a folder outline when hovered or triggered programmatically. It is a client component built on motion/react and exposes an imperative handle for start and stop control.

folder-minus
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 @heroicons-animated/folder-minus

Requires @heroicons-animated in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { FolderMinusIcon } from "@/components/ui/folder-minus";export default function Example() {  return <FolderMinusIcon size={28} className="text-slate-700" />;}
  • Showing a remove, delete, or unfollow-folder action in file managers, sidebars, or project lists where the folder metaphor is clear.
  • Adding a subtle hover micro-interaction to menu items or table row actions without pulling in a large animation library.
  • Triggering the minus animation from application state, such as after a folder is removed, by calling startAnimation through a ref.
  • Replacing a static Heroicons folder-minus icon with an animated variant that keeps the same visual language.

Examples

Hover-animated icon in a sidebar item

Uncontrolled usage. The animation plays automatically on mouse enter and reverses on mouse leave. Size and color are set through props and className.

hover-animated-icon-in-a-sidebar-item.tsx
import { FolderMinusIcon } from "@/components/ui/folder-minus";export default function SidebarItem() {  return (    <button type="button" className="flex items-center gap-2 rounded-md px-3 py-2 hover:bg-slate-100">      <FolderMinusIcon size={20} className="text-slate-600" />      <span className="text-sm">Remove folder</span>    </button>  );}

Programmatic control through a ref

Passing a ref switches the component to controlled mode. Hover no longer triggers the built-in animation, and startAnimation and stopAnimation are called from the parent.

programmatic-control-through-a-ref.tsx
import { useRef } from "react";import { FolderMinusIcon } from "@/components/ui/folder-minus";import type { FolderMinusIconHandle } from "@/components/ui/folder-minus";export default function DeleteFolderButton() {  const iconRef = useRef<FolderMinusIconHandle>(null);  return (    <button      type="button"      onMouseEnter={() => iconRef.current?.startAnimation()}      onMouseLeave={() => iconRef.current?.stopAnimation()}      className="inline-flex items-center gap-2 rounded-md border px-3 py-2"    >      <FolderMinusIcon ref={iconRef} size={24} />      Delete folder    </button>  );}

Controlled icon with custom mouse handlers

When a ref is attached, the component forwards onMouseEnter and onMouseLeave to the caller instead of animating on its own, so the parent decides when to animate.

controlled-icon-with-custom-mouse-handlers.tsx
import { useRef } from "react";import { FolderMinusIcon } from "@/components/ui/folder-minus";import type { FolderMinusIconHandle } from "@/components/ui/folder-minus";export default function ArchiveRow({ name }: { name: string }) {  const iconRef = useRef<FolderMinusIconHandle>(null);  return (    <div className="flex items-center justify-between py-2">      <span>{name}</span>      <FolderMinusIcon        ref={iconRef}        size={18}        className="cursor-pointer text-red-500"        onMouseEnter={() => iconRef.current?.startAnimation()}        onMouseLeave={() => iconRef.current?.stopAnimation()}      />    </div>  );}

Animate after an async delete

Plays the minus animation once a deletion request resolves, giving the user visual confirmation.

animate-after-an-async-delete.tsx
import { useRef } from "react";import { FolderMinusIcon } from "@/components/ui/folder-minus";import type { FolderMinusIconHandle } from "@/components/ui/folder-minus";export default function ConfirmDelete({ onDelete }: { onDelete: () => Promise<void> }) {  const iconRef = useRef<FolderMinusIconHandle>(null);  async function handleClick() {    await onDelete();    iconRef.current?.startAnimation();  }  return (    <button type="button" onClick={handleClick} className="flex items-center gap-2">      <FolderMinusIcon ref={iconRef} size={28} />      <span>Confirm</span>    </button>  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the rendered SVG in pixels. The viewBox stays 0 0 24 24, so the icon scales proportionally.
classNamestring—Class names applied to the outer div wrapper. Use it for color (text-*), margin, or hover styles. The SVG inherits currentColor.
onMouseEnter(event: React.MouseEvent<HTMLDivElement>) => void—Mouse enter handler inherited from HTMLAttributes<HTMLDivElement>. Without a ref it is not called, because the component runs its own hover animation. With a ref attached it is called instead of the built-in animation.
onMouseLeave(event: React.MouseEvent<HTMLDivElement>) => void—Mouse leave handler inherited from HTMLAttributes<HTMLDivElement>. Behaves like onMouseEnter: it runs only in controlled mode, when a ref is attached.
refReact.Ref<FolderMinusIconHandle>—Forwarded ref exposing FolderMinusIconHandle. Attaching it switches the component to controlled mode, so built-in hover animation is disabled. Use it to call startAnimation or stopAnimation.
...HTMLAttributes<HTMLDivElement>HTMLAttributes<HTMLDivElement>—All other standard div attributes, such as id, style, aria-*, role, and data-*, are spread onto the outer wrapper div.

Accessibility

  • The icon is decorative by default: the SVG has no title, role, or aria-label. Add aria-hidden="true" when a visible text label is present, or provide an accessible name through aria-label or role="img" on the wrapper when the icon is the only content.
  • Because the wrapper is a div, place the icon inside an interactive element such as a button, and do not rely on the icon alone to communicate the action. Keep the visible text or aria-label on the control.
  • The animation is brief (0.4s) and purely visual. Do not convey essential information only through the animation, and consider respecting prefers-reduced-motion in the parent by disabling startAnimation calls when the user prefers reduced motion.
  • Hover-only triggers do not work on touch devices. Pair them with a click or focus action that calls startAnimation through the ref so the feedback is available to all users.
  • The icon uses currentColor for its stroke, so ensure sufficient contrast against its 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 "folder-minus" component (heroicons-animated/folder-minus) from its shadcn registry.1. Install it with: npx shadcn@latest add @heroicons-animated/folder-minus2. 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, ...HTMLAttributes<HTMLDivElement>.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { FolderMinusIcon } from "@/components/ui/folder-minus";export default function Example() {  return <FolderMinusIcon size={28} className="text-slate-700" />;}```

Files & dependencies

  • folder-minus.tsx
dependenciesmotion

Looks similar, elsewhere