GitHub Forks
ui-components/github-forksFreeBlock
Displays the fork count of a repository.
Install it
npx shadcn@latest add https://ui.raulcarini.dev/r/github-forks.jsonSource
1import * as React from "react";23import { Button } from "@/components/ui/button";4import { Skeleton } from "@/components/ui/skeleton";5import { GitForkIcon } from "lucide-react";67export function GithubForks({ repo }: { repo: string }) {8 return (9 <Button10 nativeButton={false}11 size="sm"12 variant="ghost"13 className="h-8 shadow-none group"14 render={15 <a16 href={`https://github.com/${repo}`}17 target="_blank"18 rel="noreferrer"19 />20 }21 >22 <GitForkIcon className="group-hover:scale-110 transition-transform duration-200 ease-out" />23 <React.Suspense fallback={<Skeleton className="h-4 w-9" />}>24 <ForksCount repo={repo} />25 </React.Suspense>26 </Button>27 );28}2930export async function ForksCount({ repo }: { repo: string }) {31 const data = await fetch(`https://api.github.com/repos/${repo}`, {32 next: { revalidate: 86400 }, // Cache for 1 day (86400 seconds)33 });34 const json: { forks_count: number } = await data.json();3536 return (37 <p className="text-xs text-muted-foreground/70 group-hover:text-muted-foreground transition-colors duration-200 ease-out">38 <span className="tabular-nums">39 {json.forks_count >= 100040 ? `${(json.forks_count / 1000).toFixed(1)}k`41 : json.forks_count.toLocaleString()}42 </span>{" "}43 forks44 </p>45 );46}
What it pulls in
npm packages
Other registry items
Files it writes
More from UI Components
All 25 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| GitHub Contributionsgithub-contributions | UI Components | Blocks | Free | no deps | |
| GitHub Contributions Advancedgithub-contributions-advanced | UI Components | Blocks | Free | no deps | |
| GitHub Contributions Advanced Fetchergithub-contributions-advanced-fetcher | UI Components | Blocks | Free | no deps | |
| GitHub Contributions Fetchergithub-contributions-fetcher | UI Components | Blocks | Free | no deps | |
| GitHub Issuesgithub-issues | UI Components | Blocks | Free | 1 dep | |
| GitHub Pull Requestsgithub-pr | UI Components | Blocks | Free | 1 dep | |
| GitHub Starsgithub-stars | UI Components | Blocks | Free | 1 dep | |
| GitHub Stars Progressgithub-stars-progress | UI Components | Blocks | Free | 1 dep |
