shadimage
lucide-animated
uia-arrow-downsource: ok · hit

A Arrow Down

npx shadcn add "https://lucide-animated.com/r/a-arrow-down.json"
free

No selection tags yet — empty means no evidence, not lack of support.

Dependencies

Bundle weight · medium
animationmotion

Files1 · source cached 10/14/2026, 11:37:51 AM

a-arrow-down.tsx
"use client";

import type { Variants } from "motion/react";
import { motion, useAnimation } from "motion/react";
import type { HTMLAttributes } from "react";
import { forwardRef, useCallback, useImperativeHandle, useRef } from "react";

import { cn } from "@/lib/utils";

export interface AArrowDownIconHandle {
  startAnimation: () => void;
  stopAnimation: () => void;
}

interface AArrowDownIconProps extends HTMLAttributes<HTMLDivElement> {
  size?: number;
}

const LETTER_VARIANTS: Variants = {
  normal: { opacity: 1, scale: 1 },
  animate: {
    opacity: [0, 1],
    scale: [0.8, 1],
    transition: { duration: 0.3 },
  },
};

const ARROW_VARIANTS: Variants = {
  normal: { opacity: 1, y: 0 },
  animate: {
    opacity: [0, 1],
    y: [-10, 0],
    transition: { duration: 0.3, delay: 0.2 },
  },
};

const AArrowDownIcon = forwardRef<AArrowDownIconHandle, AArrowDownIconProps>(
  ({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {
    const controls = useAnimation();
    const isControlledRef = useRef(false);

    useImperativeHandle(ref, () => {
      isControlledRef.current = true;

      return {
        startAnimation: () => controls.start("animate"),
        stopAnimation: () => controls.start("normal"),
      };
    });

    const handleMouseEnter = useCallback(
      (e: React.MouseEvent<HTMLDivElement>) => {
        if (isControlledRef.current) {
          onMouseEnter?.(e);
        } else {
          controls.start("animate");
        }
      },
      [controls, onMouseEnter]
    );

    const handleMouseLeave = useCallback(
      (e: React.MouseEvent<HTMLDivElement>) => {
        if (isControlledRef.current) {
          onMouseLeave?.(e);
        } else {
          controls.start("normal");
        }
      },
      [controls, onMouseLeave]
    );

    return (
      <div
        className={cn(className)}
        onMouseEnter={handleMouseEnter}
        onMouseLeave={handleMouseLeave}
        {...props}
      >
        <svg
          fill="none"
          height={size}
          stroke="currentColor"
          strokeLinecap="round"
          strokeLinejoin="round"
          strokeWidth="2"
          viewBox="0 0 24 24"
          width={size}
          xmlns="http://www.w3.org/2000/svg"
        >
          <motion.path
            animate={controls}
            d="M3.5 13h6"
            variants={LETTER_VARIANTS}
          />
          <motion.path
            animate={controls}
            d="m2 16 4.5-9 4.5 9"
            variants={LETTER_VARIANTS}
          />
          <motion.path
            animate={controls}
            d="M18 7v9"
            variants={ARROW_VARIANTS}
          />
          <motion.path
            animate={controls}
            d="m14 12 4 4 4-4"
            variants={ARROW_VARIANTS}
          />
        </svg>
      </div>
    );
  }
);

AArrowDownIcon.displayName = "AArrowDownIcon";

export { AArrowDownIcon };

More from lucide-animated

Browse all components in this library →