Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    GitHub Stars Button

    Link to a GitHub repository with the GitHub mark and a star count that counts up when it scrolls into view. No fetch.

    Star on GitHub 12,480 stars
    <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>
    import { GithubStarsButton } from "@/components/markas/GithubStarsButton";
    
    export default function GithubStarsButtonExample() {
      return (
        <div className="flex justify-center">
          <GithubStarsButton
            href="https://github.com/markasui/markasui"
            stars={12480}
          >
            Star on GitHub
          </GithubStarsButton>
        </div>
      );
    }
    <script setup lang="ts">
    import GithubStarsButton from "@/components/markas/GithubStarsButton.vue";
    </script>
    
    <template>
      <div class="flex justify-center">
        <GithubStarsButton
          href="https://github.com/markasui/markasui"
          :stars="12480"
          >Star on GitHub</GithubStarsButton
        >
      </div>
    </template>
    <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>
    import { Component } from "@angular/core";
    import { GithubStarsButton } from "./markas/github-stars-button.component";
    
    @Component({
      selector: "markas-example",
      imports: [GithubStarsButton],
      template: `
        <div class="flex justify-center">
          <a
            markas-github-stars-button
            href="https://github.com/markasui/markasui"
            [stars]="12480"
          >
            Star on GitHub
          </a>
        </div>
      `,
    })
    export default class GithubStarsButtonExample {}

    Examples

    Variants

    Sizes

    In a navbar

    Installation

    npx markasui@latest add github-stars-button

    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} in starsLabel gets 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

    NameTypeDefaultDescription
    hrefstring-Repository URL. Unsafe schemes such as javascript: become #.
    starsnumber0Star count, passed in by you. Shown as 980, 12.5k, or 1.2M.
    variant'primary' | 'secondary' | 'ghost' | 'danger'secondaryVisual style, the same set as Button.
    size'sm' | 'md' | 'lg'mdHeight 32, 40, or 48px, the same as Button.
    starsLabelstring{count} starsHidden 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.