Folder Heart
FolderHeartIcon is an animated Lucide-style folder-heart icon that pulses its heart when hovered, or when a parent starts the animation through a ref. It is built on motion/react and renders an SVG with a 24x24 viewBox.


shadcn add · no workarounds · theme neutral (none shipped)Installation
Usage
import { FolderHeartIcon } from "@/components/ui/folder-heart"; export default function Example() { return <FolderHeartIcon className="text-rose-500" size={32} />; }- Show a favorites or liked-items folder in file managers, bookmarks, or saved-collections UIs where a subtle pulse signals a collection of loved content.
- Add a hover micro-interaction to a folder or collection card, such as a 'saved' or 'favorite' action in a list or grid.
- Trigger the heart pulse programmatically (for example after a save succeeds) by calling startAnimation() and stopAnimation() through a ref.
- Use it as a lightweight, theme-aware icon that inherits color from text and needs no image assets.
Examples
Hover to animate (default behavior)
With no ref attached, the heart pulses while the pointer is over the icon and returns to rest when the pointer leaves.
import { FolderHeartIcon } from "@/components/ui/folder-heart"; export function FavoritesFolder() { return ( <div className="flex items-center gap-2 text-sm"> <FolderHeartIcon className="text-pink-500" size={24} /> <span>Favorites</span> </div> ); }Programmatic control via ref
Attaching a ref switches the icon to controlled mode. Hover no longer drives the animation, and you call startAnimation() and stopAnimation() yourself.
import { useRef } from "react"; import { FolderHeartIcon, type FolderHeartIconHandle } from "@/components/ui/folder-heart"; export function SaveButton() { const iconRef = useRef<FolderHeartIconHandle>(null); return ( <button type="button" className="inline-flex items-center gap-2 rounded-md border px-3 py-2" onMouseEnter={() => iconRef.current?.startAnimation()} onMouseLeave={() => iconRef.current?.stopAnimation()} > <FolderHeartIcon ref={iconRef} size={20} /> Save to favorites </button> ); }Pulse after an async action
Start the heart animation while a save request runs, then stop it when the request finishes.
import { useRef } from "react"; import { FolderHeartIcon, type FolderHeartIconHandle } from "@/components/ui/folder-heart"; export function SaveStatus({ onSave }: { onSave: () => Promise<void> }) { const iconRef = useRef<FolderHeartIconHandle>(null); async function handleClick() { iconRef.current?.startAnimation(); await onSave(); iconRef.current?.stopAnimation(); } return ( <button type="button" onClick={handleClick} className="flex items-center gap-2"> <FolderHeartIcon ref={iconRef} size={28} className="text-red-500" /> Save </button> ); }API reference
Accessibility
- The component renders a decorative SVG with no title, desc, or role. If the icon conveys meaning on its own, wrap it in an element with role="img" and an aria-label (for example aria-label="Favorites folder"), or pass aria-label and role via the spread div props.
- If the icon sits next to visible text (like 'Favorites'), mark it decorative with aria-hidden="true" on the wrapper so screen readers do not announce it twice.
- The heart animation loops indefinitely. Avoid leaving it running unattended, and consider stopping it via stopAnimation() after an action completes, to respect users who are sensitive to motion (prefers-reduced-motion).
- When the icon is used as a control, put the interactive semantics on a parent button or link with an accessible name. The hover-only pulse is not a keyboard-accessible state, so pair it with focus styling and a text label.
- Color comes from currentColor, so ensure the chosen text color meets WCAG contrast against the background.
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.
Use the "Folder Heart" component (lucide-animated/folder-heart) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/folder-heart.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, ...HTMLAttributes<HTMLDivElement>.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { FolderHeartIcon } from "@/components/ui/folder-heart"; export default function Example() { return <FolderHeartIcon className="text-rose-500" size={32} />; }```Files & dependencies
- folder-heart.tsx