An animated Twitter bird icon built on Motion, drawing the bird outline with a stroke-path animation on hover. It can be triggered by hover by default, or controlled imperatively via a ref with startAnimation and stopAnimation.


shadcn add · no workarounds · theme neutral (none shipped)Installation
Usage
import { TwitterIcon } from "@/components/ui/twitter";export default function Example() { return <TwitterIcon size={28} className="text-sky-500" />;}- Showing a social or share action with a playful hover animation in a navbar, sidebar, or footer link
- Adding a subtle line-drawing micro-interaction to a Twitter/X link or share button
- Triggering the bird's draw-on animation programmatically from parent state via a ref, for example when a share succeeds
- Replacing a static Twitter icon where an animated, lightweight SVG is wanted without an icon font
Examples
Hover-triggered share link
Default hover behavior inside a footer link. The animation runs on mouse enter and reverses on mouse leave.
import { TwitterIcon } from "@/components/ui/twitter";export default function FooterSocial() { return ( <a href="https://x.com/example" aria-label="Follow us on X" className="inline-flex"> <TwitterIcon size={24} className="text-foreground" /> </a> );}Imperative control via ref
Controls the animation from a parent using the TwitterIconHandle ref. Once a ref is attached, hover no longer triggers the animation automatically.
import { useRef } from "react";import { Button } from "@/components/ui/button";import { TwitterIcon, type TwitterIconHandle } from "@/components/ui/twitter";export default function ShareButton() { const iconRef = useRef<TwitterIconHandle>(null); return ( <Button variant="outline" onMouseEnter={() => iconRef.current?.startAnimation()} onMouseLeave={() => iconRef.current?.stopAnimation()} > <TwitterIcon ref={iconRef} size={20} /> Share on X </Button> );}Looping animation on a status change
Starts the animation when a condition becomes true, for example after a post is published.
import { useEffect, useRef } from "react";import { TwitterIcon, type TwitterIconHandle } from "@/components/ui/twitter";export default function PostedBadge({ posted }: { posted: boolean }) { const iconRef = useRef<TwitterIconHandle>(null); useEffect(() => { if (posted) iconRef.current?.startAnimation(); }, [posted]); return <TwitterIcon ref={iconRef} size={32} className="text-sky-500" />;}API reference
Accessibility
- The icon is decorative SVG with no title or role, so when it is the only content of a link or button, provide an accessible name with aria-label on the interactive parent or visually hidden text.
- The SVG does not set aria-hidden; add aria-hidden="true" via props when the icon sits next to a visible text label to avoid redundant announcements.
- The animation is purely visual and conveys no information, so the state change is not announced to assistive technology; do not rely on it alone to communicate status.
- Respect reduced-motion preferences by passing a condition to startAnimation or by skipping calls when prefers-reduced-motion is set, since the component does not check this itself.
- Color contrast depends on the currentColor applied via className; ensure the chosen text color meets WCAG contrast against its background.
Docs written by anthropic:claude-haiku-5-5 from the registry source.
Use with Coding Agent
Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.
Use the "Twitter" component (lucide-animated/twitter) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/twitter.json2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: size, className, onMouseEnter, onMouseLeave, ref, ...props.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { TwitterIcon } from "@/components/ui/twitter";export default function Example() { return <TwitterIcon size={28} className="text-sky-500" />;}```Files & dependencies
- twitter.tsx