새로운 도구가 추가되었습니다! 새로운 소식 보기

소개

AnimatedIcon은 lucide-react의 아이콘을 감싸고 손으로 그린 것처럼 선을 애니메이션합니다.

채우기가 아닌 선

Lucide 아이콘은 외곽선입니다.

대시 트릭

각 선에 동일한 길이의 대시가 적용됩니다.

종속성 없음

브라우저의 Web Animations API를 사용합니다.

설치

lucide-react와 함께 패키지를 설치하세요.

terminal
npm install @utilityzoo/icons lucide-react

요구 사항

항목버전
react18 or 19
lucide-react0.300 or newer
BrowserAny current browser (needs the Web Animations API)

빠른 시작

Lucide에서 아이콘을 가져와 AnimatedIcon에 전달하세요.

tsx
"use client";

import { Heart } from "lucide-react";
import { AnimatedIcon } from "@utilityzoo/icons";

export default function LikeButton() {
  return <AnimatedIcon icon={Heart} trigger="hover" />;
}

이것이 전체 설정입니다.

프레임워크 가이드

Next.js (App Router)

AnimatedIcon을 렌더링하는 파일은 클라이언트 컴포넌트여야 합니다.

components/like-button.tsx
// components/like-button.tsx
"use client";

import { Heart } from "lucide-react";
import { AnimatedIcon } from "@utilityzoo/icons";

export function LikeButton() {
  return <AnimatedIcon icon={Heart} trigger="click" color="crimson" />;
}
app/page.tsx
// app/page.tsx (a server component is fine here)
import { LikeButton } from "@/components/like-button";

export default function Page() {
  return <LikeButton />;
}

Vite, Create React App, React Router

모든 것이 브라우저에서 실행됩니다.

tsx
// src/App.tsx (Vite, Create React App, React Router)
// No directive needed outside the Next.js App Router.
import { Rocket } from "lucide-react";
import { AnimatedIcon } from "@utilityzoo/icons";

export default function App() {
  return <AnimatedIcon icon={Rocket} trigger="mount" size={64} />;
}

대신 파일 복사하기

컴포넌트는 단일 파일입니다. GitHub에서 복사하세요. GitHub.

tsx
// Copy AnimatedIcon.tsx into your project, then import it locally:
import AnimatedIcon from "@/components/animated-icon";

트리거

트리거는 애니메이션이 재생되는 시점을 결정합니다.

inView

The default. Draws once when scrolled into view.

tsx
<AnimatedIcon icon={Heart} />

mount

Draws once as soon as the page loads.

tsx
<AnimatedIcon icon={Rocket} trigger="mount" />

hover

Draws each time the mouse enters. Hover it.

tsx
<AnimatedIcon icon={Bell} trigger="hover" />

click

Draws on every click. Click it.

tsx
<AnimatedIcon icon={Star} trigger="click" />

toggle

One icon that erases, then draws back, on each click.

tsx
<AnimatedIcon icon={Bookmark} trigger="toggle" />

toggle + toggleIcon

Two icons: the first erases, then the second draws.

tsx
<AnimatedIcon icon={Play} toggleIcon={Pause} trigger="toggle" />

loop

Endless draw and erase. Pauses when off screen.

tsx
<AnimatedIcon icon={Zap} trigger="loop" loopDelay={1000} />

플레이그라운드

아이콘을 선택하고 트리거를 고른 뒤 타이밍을 조정하세요.

Click the icon to erase and draw (or swap with the second icon).

Color
tsx (updates as you change settings)
import { Play, Pause } from "lucide-react";
import { AnimatedIcon } from "@utilityzoo/icons";

<AnimatedIcon
  icon={Play}
  toggleIcon={Pause}
  trigger="toggle"
  size={72}
/>

이 짧은 목록 대신 모든 Lucide 아이콘을 원하시나요?

프롭스 참조

프롭타입기본값설명
iconLucideIconrequiredThe Lucide icon component to animate.
trigger"inView" | "mount" | "hover" | "click" | "toggle" | "loop""inView"What starts the animation.
toggleIconLucideIconnoneSecond icon for trigger="toggle". The first erases, then this one draws.
durationnumber800Milliseconds each stroke takes.
staggernumber120Milliseconds between strokes. 0 draws them all together.
easingstring"ease-in-out"Any CSS easing, e.g. linear or cubic-bezier(...).
oncebooleantrueinView only. Animate the first time only.
replayOnClickbooleanfalseinView, mount, hover. Clicking replays the animation.
loopDelaynumber600loop only. Pause in ms between draw and erase.
size, color, strokeWidth, className…LucidePropsLucide defaultsEverything else goes straight to the icon.

레시피

자주 사용되는 복사-붙여넣기 패턴.

Menu button

Menu turns into a close icon. Fast timing feels snappy in a navbar.

tsx
<button aria-label="Toggle menu" className="p-0">
  <AnimatedIcon
    icon={Menu} toggleIcon={X} trigger="toggle"
    duration={350} stagger={0} size={28}
  />
</button>

Play / pause

Swap two icons on click. Keep your own state in sync with onClick on the button.

tsx
<AnimatedIcon icon={Play} toggleIcon={Pause} trigger="toggle" size={32} />

Attention bell

A slow, quiet loop draws the eye without being annoying.

tsx
<AnimatedIcon icon={Bell} trigger="loop" loopDelay={2000} size={24} />

Feature card icon

Draws once as the card scrolls into view. Color comes from Tailwind.

tsx
<AnimatedIcon
  icon={Rocket} trigger="inView" size={40}
  className="text-primary" strokeWidth={1.5}
/>

참고: 아이콘은 자체 클릭을 처리합니다.

스타일링

애니메이션 외의 모든 프롭은 아이콘으로 전달됩니다.

tsx
<AnimatedIcon icon={Star} className="text-amber-500" />   {/* Tailwind color */}
<AnimatedIcon icon={Star} color="#f59e0b" size={40} />     {/* explicit color and size */}
<AnimatedIcon icon={Star} strokeWidth={1.25} />            {/* thinner lines */}
<AnimatedIcon icon={Star} absoluteStrokeWidth />           {/* keep line width fixed when resizing */}
tsx (other outline icon sets)
import { Home } from "@tabler/icons-react"; // any outline icon component
import { AnimatedIcon } from "@utilityzoo/icons";

<AnimatedIcon icon={Home} trigger="hover" />

접근성

  • 동일한 모션 감소: 사용자가 모션 감소를 활성화하면 아이콘이 정적 상태를 유지합니다.
  • 의미 있는 아이콘: 버튼에 aria-label을 추가하세요.
  • 장식용 아이콘: 텍스트 옆에 추가 마크업이 필요하지 않습니다.
  • 루프: 절제하여 사용하세요.

성능

  • 애니메이션 라이브러리가 로드되지 않습니다.
  • inView 아이콘은 화면에 도달했을 때만 애니메이션됩니다.
  • loop 아이콘은 화면을 벗어나면 자동으로 일시 중지됩니다.
  • 큰 그리드에서는 loop보다 hover 또는 inView를 선호하세요.

동작 원리

  1. 아이콘이 일반 SVG로 렌더링됩니다.
  2. 각 도형에 pathLength="1"이 지정됩니다.
  3. 대시 패턴이 선을 숨깁니다.
  4. 불투명도는 시작과 끝에서 애니메이션됩니다.
  5. 도형이 차례로 시작됩니다.

문제 해결

You passed an icon from a server component. Icons are components, and components can't cross from server to client. Put the <AnimatedIcon /> usage in a file that starts with "use client" (see the Next.js guide), then import that file where you need it.

변경 로그

VersionTitleChanges
0.1.2Initial releaseTriggers: inView, mount, hover, click, toggle, loop. Two-icon toggle. Reduced-motion support.

아이콘에 생명을 불어넣을 준비가 되셨나요?

모든 Lucide 아이콘을 탐색하고 코드를 복사하세요.