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.
Powered by
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
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
Prop | Type | Default | Description |
---|---|---|---|
username | string | required | GitHub username or organization name |
repo | string | required | Repository name to fetch stars from |
formatted | boolean | false | Display numbers in compact format (1.2k, 3.4M) |
transition | SpringOptions | { stiffness: 90, damping: 50 } | Spring animation configuration |
inView | boolean | false | Enable intersection observer triggering |
inViewMargin | string | '0px' | Margin for intersection observer |
inViewOnce | boolean | true | Trigger animation only once when in view |
className | string | - | 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
Flip Button
Animated flip button with customizable text and transitions. Perfect for React applications requiring interactive buttons with Next.js integration and TypeScript support.
Icon Button
Animated icon button with hover effects, customizable colors, and particle animations. Perfect for React applications requiring interactive button elements with Next.js integration and TypeScript support.