← Back

Code

Install

npm install @svg-animated-icons/react

CLI

Copy an icon component straight into your project — shadcn-style. Replace {icon} with an icon name like arrow-left.

terminal
npx @svg-animated-icons/cli add {icon} --react
FlagDescription
--dest <dir>Destination directory (default: components/animated-icons)

Or copy the component with the CLI

CLI
npx @svg-animated-icons/cli add code --react

Code

React
// Generated by @svg-animated-icons/cli
// You own this file — edit it freely.

import React from "react";

type Props = {
  disableHover?: boolean;
  className?: string;
};

export function CodeIcon({ disableHover, className }: Props) {
  const classes = [
    "ai-code-icon",
    disableHover ? "no-hover" : "",
    className ?? "",
  ]
    .filter(Boolean)
    .join(" ");

  return (
    <>
      <style>{`
.ai-code-icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  cursor: pointer;
  overflow: visible;
}

.ai-code-icon * {
  transform-box: fill-box;
}

.ai-code-icon.no-hover * {
  transform: none;
  opacity: 1;
  animation: none;
}

.ai-code-icon .bracket-left,
.ai-code-icon .bracket-right {
  transform-origin: center;
}

.ai-code-icon:not(.no-hover):hover .bracket-left {
  animation: ai-code-left 700ms ease-in-out;
}

.ai-code-icon:not(.no-hover):hover .bracket-right {
  animation: ai-code-right 700ms ease-in-out;
}

@keyframes ai-code-left {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-1.5px); }
}

@keyframes ai-code-right {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(1.5px); }
}
`}</style>
      <svg
        xmlns="http://www.w3.org/2000/svg"
        className={classes}
        viewBox="0 0 15 15"
        fill="none"
      >
        <path className="bracket-left" d="M5 5L2 7.5L5 10" stroke="currentColor" strokeWidth="1.25" strokeLinecap="round" strokeLinejoin="round"/>
        <path className="bracket-right" d="M10 5L13 7.5L10 10" stroke="currentColor" strokeWidth="1.25" strokeLinecap="round" strokeLinejoin="round"/>
        <path className="slash" d="M9 2.5L6 12.5" stroke="currentColor" strokeWidth="1.25" strokeLinecap="round"/>
      </svg>
    </>
  );
}