Chamaac
Components
  • Overview

    • Introduction
  • Gallery

    • CarouselNew
  • Animated Icons
    • CopyNew
    • WavyNew
    • AdjustmentsNew
  • Buttons

    • Slide Up Button
  • Navigation

    • Dock
  • Cards

    • Random Image Reveal
    • Orbiting IconsNew

Copy Icon

An animated copy icon that simulates the action of copying.

Installation

Install Dependencies

npm install motion

Component Code

Copy and paste the component code into your project.

"use client";

import { motion, SVGMotionProps } from "motion/react";

interface CopyIconProps extends SVGMotionProps<SVGSVGElement> {
    size?: number;
    duration?: number;
}

const CopyIcon = (
    props: CopyIconProps
) => {
    const { size = 24, duration = 1.5, className, ...restProps } = props;
    return (
        <motion.svg
            {...restProps}
            xmlns="http://www.w3.org/2000/svg"
            width={size}
            height={size}
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            strokeWidth={2}
            strokeLinecap="round"
            strokeLinejoin="round"
            className={className}
        >
            <path stroke="none" d="M0 0h24v24H0z" fill="none" />

            <motion.rect
                width="12" height="12" rx="2"
                animate={{
                    x: [8, 4, 8],
                    y: [8, 4, 8],
                }}
                transition={{
                    duration: duration,
                    ease: "easeInOut",
                    repeat: Infinity,
                }}
                stroke="currentColor"
                fill="none"
            />

            <rect
                x="8" y="8" width="12" height="12" rx="2"
                className="fill-gray-100 dark:fill-[#111111]"
                stroke="currentColor"
            />
        </motion.svg>
    )
}

export default CopyIcon;

Props

PropTypeDefaultDescription
classNamestring-Custom class names for styling the SVG
sizenumber24Size of the icon in pixels
durationnumber1.5Duration of the animation in seconds