align-center
lucide-animated-pqoqubbw/align-centerFreeComponent
lucide-animated publishes no description for this item.
Install it
npx shadcn@latest add https://lucide-animated.com/r/align-center.jsonSource
1"use client";23import { motion, useAnimation } from "motion/react";4import type { HTMLAttributes } from "react";5import { forwardRef, useCallback, useImperativeHandle, useRef } from "react";67import { cn } from "@/lib/utils";89export interface AlignCenterIconHandle {10 startAnimation: () => void;11 stopAnimation: () => void;12}1314interface AlignCenterIconProps extends HTMLAttributes<HTMLDivElement> {15 size?: number;16}1718const AlignCenterIcon = forwardRef<AlignCenterIconHandle, AlignCenterIconProps>(19 ({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {20 const controls = useAnimation();21 const isControlledRef = useRef(false);2223 useImperativeHandle(ref, () => {24 isControlledRef.current = true;2526 return {27 startAnimation: () => controls.start("animate"),28 stopAnimation: () => controls.start("normal"),29 };30 });3132 const handleMouseEnter = useCallback(33 (e: React.MouseEvent<HTMLDivElement>) => {34 if (isControlledRef.current) {35 onMouseEnter?.(e);36 } else {37 controls.start("animate");38 }39 },40 [controls, onMouseEnter]41 );4243 const handleMouseLeave = useCallback(44 (e: React.MouseEvent<HTMLDivElement>) => {45 if (isControlledRef.current) {46 onMouseLeave?.(e);47 } else {48 controls.start("normal");49 }50 },51 [controls, onMouseLeave]52 );5354 return (55 <div56 className={cn(className)}57 onMouseEnter={handleMouseEnter}58 onMouseLeave={handleMouseLeave}59 {...props}60 >61 <svg62 fill="none"63 height={size}64 stroke="currentColor"65 strokeLinecap="round"66 strokeLinejoin="round"67 strokeWidth="2"68 viewBox="0 0 24 24"69 width={size}70 xmlns="http://www.w3.org/2000/svg"71 >72 <motion.path73 animate={controls}74 d="M17 12H7"75 variants={{76 normal: { translateX: 0 },77 animate: {78 translateX: [0, 3, -3, 2, -2, 0],79 transition: {80 ease: "linear",81 translateX: {82 duration: 1,83 },84 },85 },86 }}87 />88 <path d="M19 18H5" />89 <path d="M21 6H3" />90 </svg>91 </div>92 );93 }94);9596AlignCenterIcon.displayName = "AlignCenterIcon";9798export { AlignCenterIcon };
What it pulls in
npm packages
Files it writes
More from lucide-animated
All 464 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 |
