A React component that displays GitHub contribution graphs in your web application with customizable color themes.
npm install @theamrendram/react-green-graphimport ReactGreenGraph from "@theamrendram/react-green-graph";
function App() {
return (
<ReactGreenGraph
username="your-github-username"
token="your-github-personal-access-token"
/>
);
}You can customize the contribution graph colors by passing a colors prop with an array of 5 hex colors:
import ReactGreenGraph from "@theamrendram/react-green-graph";
function App() {
// Custom color array (5 colors)
const customColors = [
"#ebedf0", // No contributions
"#c6e48b", // Light color for 1-3 contributions
"#7bc96f", // Medium color for 4-6 contributions
"#239a3b", // Dark color for 7-9 contributions
"#196127", // Darkest color for 10+ contributions
];
return (
<ReactGreenGraph
username="your-github-username"
token="your-github-personal-access-token"
colors={customColors}
/>
);
}const blueTheme = [
"#ebedf0", // No contributions (light gray)
"#9bc5ff", // Light blue
"#5a9bff", // Medium blue
"#1e64e0", // Dark blue
"#083d9b", // Darkest blue
];const purpleTheme = [
"#f0f0f0", // No contributions
"#e1d5e7", // Light purple
"#c3a4d7", // Medium purple
"#9b59b6", // Dark purple
"#8e44ad", // Darkest purple
];const orangeTheme = [
"#f8f9fa", // No contributions
"#ffd8a8", // Light orange
"#ffa94d", // Medium orange
"#fd7e14", // Dark orange
"#e8590c", // Darkest orange
];| Prop | Type | Required | Description |
|---|---|---|---|
username |
string | Yes | GitHub username to fetch contributions for |
token |
string | Yes | GitHub personal access token for API authentication |
colors |
string[] | No | Array of 5 hex colors for custom theme |
The colors prop expects an array of exactly 5 hex color values:
- Index 0: Color for no contributions
- Index 1: Color for 1-3 contributions
- Index 2: Color for 4-6 contributions
- Index 3: Color for 7-9 contributions
- Index 4: Color for 10+ contributions
- Go to GitHub Settings → Developer settings → Personal access tokens
- Generate a new token with
read:userandreposcopes - Use this token in the
tokenprop
- ✅ Real-time GitHub contribution data
- ✅ Customizable color themes
- ✅ Loading and error states
- ✅ TypeScript support
- ✅ Accessible (ARIA labels, keyboard navigation)
- ✅ Tooltip on hover
- ✅ Total contribution count
- ✅ Automatic CSS injection
- ✅ PropTypes validation
- ✅ Responsive design
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
MIT
Contributions are welcome! Please feel free to submit a Pull Request.