Join the Discord!
Buttons

GitHub Stars Button

Interactive GitHub stars button with real-time star count, animated number transitions, and particle effects. Perfect for React applications requiring social proof elements with Next.js integration and TypeScript support.

Loading component...

Installation

npx shadcn@latest add https://www.shadcn.io/registry/github-stars-button.json
npx shadcn@latest add https://www.shadcn.io/registry/github-stars-button.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/github-stars-button.json
bunx shadcn@latest add https://www.shadcn.io/registry/github-stars-button.json

Features

  • Real-time GitHub API integration fetching live star counts from any public repository
  • Animated number transitions using spring physics with customizable transition timing
  • Particle effects with golden glow and burst animations when clicked or completed
  • Number formatting options supporting compact notation (1.2k, 3.4M) or full comma-separated display
  • Intersection Observer support with configurable margins and trigger options
  • TypeScript support with complete interface definitions and GitHub API types
  • shadcn/ui integration using design system button styles and responsive classes

Examples

Formatted Numbers

Loading component...

Use Cases

This free open source React component works well for:

  • Open source projects - Showcase repository popularity built with Next.js
  • Developer portfolios - Display GitHub engagement using TypeScript and Tailwind CSS
  • Landing pages - Social proof for projects with shadcn/ui integration
  • Documentation sites - Repository statistics for React applications
  • Marketing pages - GitHub metrics with animated visual feedback

API Reference

GitHubStarsButton

PropTypeDefaultDescription
usernamestringrequiredGitHub username or organization name
repostringrequiredRepository name to fetch stars from
formattedbooleanfalseDisplay numbers in compact format (1.2k, 3.4M)
transitionSpringOptions{ stiffness: 90, damping: 50 }Spring animation configuration
inViewbooleanfalseEnable intersection observer triggering
inViewMarginstring'0px'Margin for intersection observer
inViewOncebooleantrueTrigger animation only once when in view
classNamestring-Additional CSS classes for button styling

Spring Transition Options

transition?: {
  stiffness?: number;    // Spring stiffness (default: 90)
  damping?: number;      // Spring damping (default: 50)
  mass?: number;         // Spring mass
  velocity?: number;     // Initial velocity
}

Number Formatting

  • Unformatted - Full numbers with comma separators (1,234)
  • Formatted - Compact notation with units (1.2k, 3.4M, 5.6B, 7.8T)
  • Auto-detection - Handles repositories with any star count range

Implementation Notes

  • Fetches star count from GitHub API v3 on component mount
  • Uses spring-based animations for smooth number transitions with motion/react
  • Displays loading state until API response is received
  • Handles API errors gracefully with console logging
  • Particle effects trigger on click and animation completion
  • Star icon fills progressively as numbers animate upward
  • Opens repository in new tab when clicked with 500ms delay for effect viewing
  • Integrates seamlessly with shadcn/ui button styling and focus states
  • Built with proper accessibility attributes and semantic HTML structure