GitHub Stars

A repository's GitHub stars, counted up with a filling star and a burst of particles.

"use client"

import {
  GithubStars,
  GithubStarsIcon,
  GithubStarsLogo,
  GithubStarsNumber,
  GithubStarsParticles,
} from "@animate-ui/react/primitives/github-stars"
import { cn } from "cn"
import { StarIcon } from "@hugeicons/core-free-icons"
import { HugeiconsIcon } from "@hugeicons/react"

function Star(
  props: Omit<React.ComponentProps<typeof HugeiconsIcon>, "icon">
) {
  return (
    <HugeiconsIcon
      icon={StarIcon}
      strokeWidth={2}
      {...props}
      className={cn("[&_path]:[stroke:inherit]", props.className)}
    />
  )
}

export default function GithubStarsDemo() {
  return (
    <GithubStars
      username="imskyleen"
      repo="animate-ui"
      value={3200}
      className="flex items-center gap-2"
    >
      <GithubStarsLogo className="size-6 text-muted-foreground" />
      <div className="flex items-center gap-1 rounded-lg bg-muted px-2 py-1">
        <GithubStarsNumber className="font-medium text-muted-foreground tabular-nums" />
        <GithubStarsParticles className="text-yellow-500">
          <GithubStarsIcon
            icon={Star}
            className="size-[18px] fill-neutral-300 stroke-neutral-300 dark:fill-neutral-700 dark:stroke-neutral-700"
            color="var(--color-yellow-500)"
          />
        </GithubStarsParticles>
      </div>
    </GithubStars>
  )
}

Installation

npm install @animate-ui/react motion
pnpm add @animate-ui/react motion
yarn add @animate-ui/react motion
bun add @animate-ui/react motion

Usage

import {
  GithubStars,
  GithubStarsIcon,
  GithubStarsLogo,
  GithubStarsNumber,
  GithubStarsParticles,
} from '@animate-ui/react/primitives/github-stars';

export function Stars() {
  return (
    <GithubStars
      username="imskyleen"
      repo="animate-ui"
      className="flex items-center gap-2"
    >
      <GithubStarsLogo className="size-6" />
      <GithubStarsNumber />
      <GithubStarsParticles>
        <GithubStarsIcon icon={StarIcon} className="size-4" color="gold" />
      </GithubStarsParticles>
    </GithubStars>
  );
}

The count is fetched from the GitHub API (api.github.com/repos/<username>/<repo>), unauthenticated. To avoid the request (rate limits, server-side data), pass the count with value.

Animation

  • Once the count is loaded, the number counts up from 0 with rolling digits (Sliding Number).
  • The star fills from the bottom as the number climbs, and bursts into particles when the count is reached.
  • Nothing is rendered until the count is loaded (with asChild, the child is there but hidden); the container is marked aria-busy meanwhile.
  • With inView, the request waits for the element to be on screen.
  • Under reduced motion, the digits change without rolling and the burst is skipped.

API Reference

GithubStars

PropTypeDefault
asChild?
booleanfalse
username?
string-
repo?
string-
value?
number-
delay?
number0
children
React.ReactNode-
inView?
booleanfalse
inViewOnce?
booleantrue
inViewMargin?
string'0px'
...props?
HTMLMotionProps<'div'>-

GithubStarsNumber

The count, as a Sliding Number.

PropTypeDefault
padStart?
booleantrue
...props?
Omit<SlidingNumberProps, 'number' | 'fromNumber'>-

GithubStarsIcon

Renders the icon twice: empty, and filled as the count climbs.

PropTypeDefault
icon
React.ElementType-
color?
string'currentColor'
activeClassName?
string-
...props?
React.ComponentProps<T>-

GithubStarsParticles

Bursts when the count is reached. Takes the ParticlesEffect props.

PropTypeDefault
children
React.ReactElement-
size?
number4
...props?
ParticlesEffectProps-

The GitHub mark, labelled for screen readers. Takes svg props.

useGithubStars

Returns stars, currentStars (the displayed value), isLoading and isCompleted.

Built by Skyleen. The source code is available on GitHub.

Last updated: 10/18/2026

On this page