arrow-down
lucide-animated-icons/arrow-downFreeComponent
lucide-animated publishes no description for this item.
Install it
npx shadcn@latest add https://icons.pqoqubbw.dev/r/arrow-down.jsonSource
1"use client";23import type { Variants } from "motion/react";4import { motion, useAnimation } from "motion/react";5import type { HTMLAttributes } from "react";6import { forwardRef, useCallback, useImperativeHandle, useRef } from "react";78import { cn } from "@/lib/utils";910export interface ArrowDownIconHandle {11 startAnimation: () => void;12 stopAnimation: () => void;13}1415interface ArrowDownIconProps extends HTMLAttributes<HTMLDivElement> {16 size?: number;17}1819const PATH_VARIANTS: Variants = {20 normal: { d: "m19 12-7 7-7-7", translateY: 0 },21 animate: {22 d: "m19 12-7 7-7-7",23 translateY: [0, -3, 0],24 transition: {25 duration: 0.4,26 },27 },28};2930const SECOND_PATH_VARIANTS: Variants = {31 normal: { d: "M12 5v14" },32 animate: {33 d: ["M12 5v14", "M12 5v9", "M12 5v14"],34 transition: {35 duration: 0.4,36 },37 },38};3940const ArrowDownIcon = forwardRef<ArrowDownIconHandle, ArrowDownIconProps>(41 ({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {42 const controls = useAnimation();43 const isControlledRef = useRef(false);4445 useImperativeHandle(ref, () => {46 isControlledRef.current = true;4748 return {49 startAnimation: () => controls.start("animate"),50 stopAnimation: () => controls.start("normal"),51 };52 });5354 const handleMouseEnter = useCallback(55 (e: React.MouseEvent<HTMLDivElement>) => {56 if (isControlledRef.current) {57 onMouseEnter?.(e);58 } else {59 controls.start("animate");60 }61 },62 [controls, onMouseEnter]63 );6465 const handleMouseLeave = useCallback(66 (e: React.MouseEvent<HTMLDivElement>) => {67 if (isControlledRef.current) {68 onMouseLeave?.(e);69 } else {70 controls.start("normal");71 }72 },73 [controls, onMouseLeave]74 );7576 return (77 <div78 className={cn(className)}79 onMouseEnter={handleMouseEnter}80 onMouseLeave={handleMouseLeave}81 {...props}82 >83 <svg84 fill="none"85 height={size}86 stroke="currentColor"87 strokeLinecap="round"88 strokeLinejoin="round"89 strokeWidth="2"90 viewBox="0 0 24 24"91 width={size}92 xmlns="http://www.w3.org/2000/svg"93 >94 <motion.path95 animate={controls}96 d="m19 12-7 7-7-7"97 variants={PATH_VARIANTS}98 />99 <motion.path100 animate={controls}101// … truncated
What it pulls in
npm packages
Files it writes
More from lucide-animated
All 466 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| a-arrow-downa-arrow-down | lucide-animated | Components | Free | 1 dep | |
| a-arrow-upa-arrow-up | lucide-animated | Components | Free | 1 dep | |
| accessibilityaccessibility | lucide-animated | Components | Free | 1 dep | |
| activityactivity | lucide-animated | Components | Free | 1 dep | |
| air-ventair-vent | lucide-animated | Components | Free | 1 dep | |
| airplaneairplane | lucide-animated | Components | Free | 1 dep | |
| airplayairplay | lucide-animated | Components | Free | 1 dep | |
| alarm-clockalarm-clock | lucide-animated | Components | Free | 1 dep |
