نئے ٹولز شامل کیے گئے! دیکھیں کیا نیا ہے

تعارف

AnimatedIcon lucide-react سے ایک آئیکن کو لپیٹتا ہے اور اس کے اسٹوکس کو متحرک کرتا ہے، تاکہ آئیکن ایسا لگے جیسے ہاتھ سے کھینچا گیا ہو۔ اس میں خود کوئی آئیکن شامل نہیں ہے۔ آپ Lucide سے آئیکنز درآمد کرتے رہیں اور انہیں پاس کریں۔

اسٹوکس، بھرائی نہیں

Lucide آئیکنز آؤٹ لائنز ہیں، اور آؤٹ لائن کو آہستہ آہستہ کھینچا جا سکتا ہے۔

ڈیش ٹرک

ہر لکیر کو اپنے جتنا ہی ڈیش ملتا ہے، نظر سے باہر دھکیلا جاتا ہے، پھر واپس اندر سلائیڈ کیا جاتا ہے۔

صفر انحصار

یہ براؤزر کی ویب اینیمیشنز API استعمال کرتا ہے۔ لوڈ کرنے کے لیے کچھ اضافی نہیں۔

تنصیب

lucide-react کے ساتھ پیکج انسٹال کریں۔ آپ کی ایپ react اور 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" />;
}

یہ پوری سیٹ اپ ہے۔ یہ کب چلے گا اسے کنٹرول کرنے کے لیے trigger کو تبدیل کریں، اور رفتار، سائز اور رنگ کے لیے پراپس ریفرنس دیکھیں۔

فریم ورک گائیڈز

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}
/>

نوٹ: آئیکن اپنا کلک خود ہینڈل کرتا ہے۔ اگر آپ اسے بٹن کے اندر رکھتے ہیں، تو بٹن کی پیڈنگ ہٹا دیں۔

اسٹائلنگ

انیمیشن والی پراپس کے علاوہ ہر پروپ آئیکن پر جاتی ہے، لہذا اسٹائلنگ پلین Lucide کی طرح کام کرتی ہے۔

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" />

استطاعت (Accessibility)

  • کم حرکت: جب صارف نے کم حرکت فعال کی ہو، تو آئیکنز جامد رہتے ہیں۔
  • مععنی خیز آئیکنز: اگر آئیکن بٹن کا واحد مواد ہے، تو 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 آئیکن کو براؤز کریں، اسے ٹیون کریں، اور کوڈ کاپی کریں۔