github
GithubIcon is an animated GitHub Octocat line icon built with motion/react. On hover it plays a short tail-sweep and body-stretch animation, and it also exposes imperative start and stop controls through a ref.
shadcn add · no workarounds · theme neutral (none shipped)Installation
Requires @hugeicons-animated in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import { GithubIcon } from '@/components/ui/github';export function Example() { return <GithubIcon />;}- Use it as an animated GitHub link or 'Star on GitHub' icon in headers, footers and social links where a playful hover cue is wanted.
- Use it in CTA buttons or repository cards that need a lively, icon-only hover effect.
- Use the ref handle when the parent must trigger the animation programmatically, for example on a click or after a data load.
- Avoid it where continuous looping motion is required, since the built-in hover animation plays once per hover and does not loop.
Examples
Hover-animated GitHub link
A default-sized icon inside an anchor. Hovering the icon plays the tail animation.
import { GithubIcon } from '@/components/ui/github';export function GithubLink() { return ( <a href="https://github.com" aria-label="GitHub" className="inline-flex text-foreground"> <GithubIcon /> </a> );}Imperative control via ref
Use GithubIconHandle to start the animation from the parent. When a ref is attached, hover no longer auto-plays the animation.
import { useRef } from 'react';import { GithubIcon, type GithubIconHandle } from '@/components/ui/github';export function StarButton() { const iconRef = useRef<GithubIconHandle>(null); return ( <button type="button" className="inline-flex items-center gap-2 rounded-md border px-3 py-2" onClick={() => iconRef.current?.startAnimation()} > <GithubIcon ref={iconRef} size={20} /> Star on GitHub </button> );}Custom size and color
Set a larger size and color the icon through className, since the stroke uses currentColor.
import { GithubIcon } from '@/components/ui/github';export function LargeGithubIcon() { return <GithubIcon size={48} className="text-violet-600" aria-hidden="true" />;}Footer social links
A row of social icons where the GitHub icon uses the shared hover handler.
import { GithubIcon } from '@/components/ui/github';export function SocialRow() { return ( <nav aria-label="Social" className="flex items-center gap-4"> <a href="https://github.com" aria-label="GitHub" className="hover:opacity-80"> <GithubIcon size={24} /> </a> </nav> );}API reference
Accessibility
- The SVG has no title or role, so supply an accessible name with aria-label on the parent link or button, or hide the icon with aria-hidden="true" when adjacent text already describes it.
- Hover animation is skipped when the user has enabled reduced motion (useReducedMotion), so no extra handling is needed for motion sensitivity.
- Because the animation is hover-only, keyboard users get no visual cue; pair it with focus-visible styles on the interactive parent.
- Icon color follows currentColor, so keep sufficient contrast against the background in both light and dark themes.
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 "github" component (hugeicons-animated/github) from its shadcn registry.1. Install it with: npx shadcn@latest add @hugeicons-animated/github2. 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, ...HTMLAttributes<HTMLDivElement>.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { GithubIcon } from '@/components/ui/github';export function Example() { return <GithubIcon />;}```Files & dependencies
- icons/github.tsx
- lib/use-icon-animation.ts