A repository's GitHub stars, counted up with a filling star and a burst of particles.
Installation
Usage
<script setup lang="ts">
import {
GithubStars,
GithubStarsIcon,
GithubStarsLogo,
GithubStarsNumber,
GithubStarsParticles,
} from '@animate-ui/vue/primitives/github-stars';
</script>
<template>
<GithubStars username="imskyleen" repo="animate-ui" class="flex items-center gap-2">
<GithubStarsLogo class="size-6" />
<GithubStarsNumber />
<GithubStarsParticles>
<GithubStarsIcon :icon="StarIcon" class="size-4" color="gold" />
</GithubStarsParticles>
</GithubStars>
</template>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
as-child, the child is there but hidden); the container is markedaria-busymeanwhile. - With
in-view, 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
| Prop | Type | Default |
|---|---|---|
as-child? | boolean | false |
username? | string | - |
repo? | string | - |
value? | number | - |
delay? | number | 0 |
#default | slot | - |
in-view? | boolean | false |
in-view-once? | boolean | true |
in-view-margin? | string | '0px' |
...props? | HTMLMotionProps<'div'> | - |
GithubStarsNumber
The count, as a Sliding Number.
| Prop | Type | Default |
|---|---|---|
pad-start? | boolean | true |
...props? | Omit<SlidingNumberProps, 'number' | 'fromNumber'> | - |
GithubStarsIcon
Renders the icon twice: empty, and filled as the count climbs.
| Prop | Type | Default |
|---|---|---|
icon | Component | - |
color? | string | 'currentColor' |
active-class? | string | - |
...props? | HTMLAttributes | - |
GithubStarsParticles
Bursts when the count is reached. Takes the ParticlesEffect props.
| Prop | Type | Default |
|---|---|---|
#default | slot | - |
size? | number | 4 |
...props? | ParticlesEffectProps | - |
GithubStarsLogo
The GitHub mark, labelled for screen readers. Takes svg props.
useGithubStars
Returns getters for stars, currentStars (the displayed value), isLoading and isCompleted.