Link to a GitHub repository with the GitHub mark and a star count that counts up when it scrolls into view. No fetch.
<div class="flex justify-center">
<x-markas.github-stars-button href="https://github.com/markasui/markasui" :stars="12480">Star on GitHub</x-markas.github-stars-button>
</div><script lang="ts">
import GithubStarsButton from "$lib/components/markas/GithubStarsButton.svelte";
</script>
<div class="flex justify-center">
<GithubStarsButton href="https://github.com/markasui/markasui" stars={12480}>
Star on GitHub
</GithubStarsButton>
</div>---
import GithubStarsButton from "@/components/markas/GithubStarsButton.astro";
---
<div class="flex justify-center">
<GithubStarsButton href="https://github.com/markasui/markasui" stars={12480}>
Star on GitHub
</GithubStarsButton>
</div>Examples
Variants
<div class="flex flex-wrap items-center justify-center gap-3">
<x-markas.github-stars-button href="https://github.com/markasui/markasui" :stars="980" variant="primary">Star</x-markas.github-stars-button>
<x-markas.github-stars-button href="https://github.com/markasui/markasui" :stars="980">Star</x-markas.github-stars-button>
<x-markas.github-stars-button href="https://github.com/markasui/markasui" :stars="980" variant="ghost">Star</x-markas.github-stars-button>
</div>Sizes
<div class="flex flex-wrap items-center justify-center gap-3">
<x-markas.github-stars-button href="https://github.com/markasui/markasui" :stars="2310" size="sm">Star</x-markas.github-stars-button>
<x-markas.github-stars-button href="https://github.com/markasui/markasui" :stars="2310">Star</x-markas.github-stars-button>
<x-markas.github-stars-button href="https://github.com/markasui/markasui" :stars="2310" size="lg">Star</x-markas.github-stars-button>
</div>In a navbar
<header class="flex items-center justify-between gap-4 rounded-xl border border-line bg-surface px-4 py-3">
<span class="text-base font-semibold text-ink">Markas</span>
<nav aria-label="Main" class="hidden items-center gap-4 text-sm sm:flex">
<a href="#docs" class="text-muted hover:text-ink">Docs</a>
<a href="#blocks" class="text-muted hover:text-ink">Blocks</a>
<x-markas.github-stars-button href="https://github.com/markasui/markasui" :stars="1240000" size="sm">Star</x-markas.github-stars-button>
</nav>
</header>Installation
npx markasui@latest add github-stars-buttonpnpm dlx markasui@latest add github-stars-buttonyarn dlx markasui@latest add github-stars-buttonbunx --bun markasui@latest add github-stars-button- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Install the dependency:
npm install alpinejs - Copy the component source below to
resources/views/components/markas/github-stars-button.blade.php.
resources/views/components/markas/github-stars-button.blade.php
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/GithubStarsButton.tsx.
src/components/markas/GithubStarsButton.tsx
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/GithubStarsButton.vue.
src/components/markas/GithubStarsButton.vue
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/lib/components/markas/GithubStarsButton.svelte.
src/lib/components/markas/GithubStarsButton.svelte
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/GithubStarsButton.astro.
src/components/markas/GithubStarsButton.astro
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/app/markas/github-stars-button.component.ts.
src/app/markas/github-stars-button.component.ts
Usage
<x-markas.github-stars-button href="https://github.com/markasui/markasui" :stars="12480">Star on GitHub</x-markas.github-stars-button>import { GithubStarsButton } from "@/components/markas/GithubStarsButton";
<GithubStarsButton href="https://github.com/markasui/markasui" stars={12480}>
Star on GitHub
</GithubStarsButton>;<script setup lang="ts">
import GithubStarsButton from "@/components/markas/GithubStarsButton.vue";
</script>
<template>
<GithubStarsButton href="https://github.com/markasui/markasui" :stars="12480">
Star on GitHub
</GithubStarsButton>
</template><script lang="ts">
import GithubStarsButton from "$lib/components/markas/GithubStarsButton.svelte";
</script>
<GithubStarsButton href="https://github.com/markasui/markasui" stars={12480}>
Star on GitHub
</GithubStarsButton>---
import GithubStarsButton from "@/components/markas/GithubStarsButton.astro";
---
<GithubStarsButton href="https://github.com/markasui/markasui" stars={12480}>
Star on GitHub
</GithubStarsButton>import { Component } from "@angular/core";
import { GithubStarsButton } from "./markas/github-stars-button.component";
@Component({
selector: "app-repo",
imports: [GithubStarsButton],
template: `
<a
markas-github-stars-button
href="https://github.com/markasui/markasui"
[stars]="12480"
>
Star on GitHub
</a>
`,
})
export class Repo {}Angular uses an attribute selector on the native link, so target, rel, and aria-* stay on it.
- The component never calls the GitHub API. Read the count at build time or on the server and pass it in.
- The visible number is compact (980, 12.5k, 1.2M).
{count}instarsLabelgets the full number with thousands separators. - The count-up starts the first time the link scrolls into view. Blade needs Alpine.js for the animation and renders the final number without it.
Props
| Name | Type | Default | Description |
|---|---|---|---|
href | string | - | Repository URL. Unsafe schemes such as javascript: become #. |
stars | number | 0 | Star count, passed in by you. Shown as 980, 12.5k, or 1.2M. |
variant | 'primary' | 'secondary' | 'ghost' | 'danger' | secondary | Visual style, the same set as Button. |
size | 'sm' | 'md' | 'lg' | md | Height 32, 40, or 48px, the same as Button. |
starsLabel | string | {count} stars | Hidden text for the count. {count} becomes the full number, for example 12,480. |
Accessibility
- A native a element with a 2px primary focus outline.
- The animated number is aria-hidden, screen readers hear starsLabel with the full count.
- The GitHub mark and star icon are aria-hidden.
- With prefers-reduced-motion the final number shows right away.
Related components
More buttons components with the same classes in every framework.
- Copy ButtonCopies a string to the clipboard. The copy icon turns into an animated check mark and a live region says Copied.
- Flip ButtonButton that flips like a card on hover and keyboard focus to reveal a second line on the back.
- Hold ButtonPress-and-hold button for risky actions. A fill tracks progress, releasing early cancels, and a complete event fires.
- Ripple ButtonButton that sends a ripple out from the click point, or from the center when pressed with the keyboard.
- Shimmer ButtonButton with a soft sheen that sweeps across it on a loop. The loop pauses off screen and stops with reduced motion.