Git Compare
GitCompareIcon is an animated git-compare icon built with Motion. On hover it draws its two connected branch paths and two node circles in sequence, and it can also be driven programmatically through a ref.


shadcn add · no workarounds · theme neutral (none shipped)Installation
Usage
import { GitCompareIcon } from "@/components/ui/git-compare";export function Example() { return <GitCompareIcon />;}- Use in developer tools, Git-related UIs, or code review screens where a compare or diff action needs a visual cue.
- Use as a hover-triggered micro-interaction on buttons, menu items, or list rows that represent comparing branches or versions.
- Use with the ref API when the animation should follow app state, such as playing while a comparison loads and stopping when it finishes.
- Avoid it as the only indicator of state, because the animation is decorative and conveys no meaning to assistive technology on its own.
Examples
Basic hover icon
Renders the icon with default size 28. It animates automatically on mouse enter and resets on mouse leave.
import { GitCompareIcon } from "@/components/ui/git-compare";export default function BasicExample() { return <GitCompareIcon />;}Custom size and color
Sets a custom pixel size and inherits color from the text color via a Tailwind class passed to className.
import { GitCompareIcon } from "@/components/ui/git-compare";export default function SizedExample() { return <GitCompareIcon size={20} className='text-blue-600' />;}Programmatic control with ref
Attaching a ref switches the component to controlled mode, so hover handlers call your onMouseEnter and onMouseLeave instead of animating directly. Use startAnimation and stopAnimation from the ref to drive the animation.
import { useRef } from "react";import { GitCompareIcon, type GitCompareIconHandle } from "@/components/ui/git-compare";export default function ControlledExample({ loading }: { loading: boolean }) { const ref = useRef<GitCompareIconHandle>(null); return ( <button type='button' onMouseEnter={() => ref.current?.startAnimation()} onMouseLeave={() => ref.current?.stopAnimation()} > <GitCompareIcon ref={ref} size={24} /> {loading ? 'Comparing...' : 'Compare branches'} </button> );}Inside a menu button
Shows the icon next to a label in a toolbar button. The hover animation plays on the wrapper div, so the whole button triggers it.
import { GitCompareIcon } from "@/components/ui/git-compare";export default function ToolbarExample() { return ( <button type='button' className='inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm'> <GitCompareIcon size={18} /> Compare </button> );}API reference
Accessibility
- The rendered SVG has no title, desc, or role. If the icon conveys meaning, add aria-label or a visible text label on the wrapper or the parent button, for example aria-label="Compare" passed via props.
- When the icon is purely decorative next to visible text, the SVG is already exposed without a name; consider wrapping it in an element with aria-hidden="true" to avoid redundant announcements.
- The animation is triggered by hover only, so keyboard users get no animation cue. Pair it with a visible focus style on the parent interactive element.
- Respect prefers-reduced-motion in the surrounding app if the icon is used in larger animated contexts, since the component does not check that media query itself.
- Use the ref API to start animation for loading states, and make sure the loading status is also communicated in text for screen readers.
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 "Git Compare" component (lucide-animated/git-compare) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/git-compare.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 { GitCompareIcon } from "@/components/ui/git-compare";export function Example() { return <GitCompareIcon />;}```Files & dependencies
- git-compare.tsx