← Back

Aspect Ratio

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 aspect-ratio --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 AspectRatioIcon({ disableHover, className }: Props) {
  const classes = [
    "ai-aspect-ratio-icon",
    disableHover ? "no-hover" : "",
    className ?? "",
  ]
    .filter(Boolean)
    .join(" ");

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

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

.ai-aspect-ratio-icon .corner-tl,
.ai-aspect-ratio-icon .corner-br {
  transform-origin: center;
}

.ai-aspect-ratio-icon:not(.no-hover):hover .corner-tl {
  animation: ai-aspect-ratio-motion-1 700ms ease-in-out;
}

.ai-aspect-ratio-icon:not(.no-hover):hover .corner-br {
  animation: ai-aspect-ratio-motion-2 700ms ease-in-out;
}

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

@keyframes ai-aspect-ratio-motion-1 {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(-1px, -1px);
  }
}

@keyframes ai-aspect-ratio-motion-2 {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(1px, 1px);
  }
}
`}</style>
      <svg
        xmlns="http://www.w3.org/2000/svg"
        className={classes}
        viewBox="0 0 15 15"
        fill="none"
      >
        <rect className="frame" x="1.5" y="2" width="12" height="11" rx="1" stroke="currentColor" strokeWidth="1"/>
        <path className="corner-tl" d="M6 4H4V6" stroke="currentColor" strokeWidth="1" strokeLinecap="round" strokeLinejoin="round"/>
        <path className="corner-br" d="M9 11H11V9" stroke="currentColor" strokeWidth="1" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    </>
  );
}