Lewati ke konten
MarkasUI
Ketik untuk mencari

    Panduan

    MarkasUI

    Form

    Feedback

    Overlay

    Navigasi

    Data

    Section

    Animasi

    Latar

    Tombol

    Template

    Halaman

    GitHub Stars Button

    Tautan ke repositori GitHub dengan logo GitHub dan jumlah bintang yang berhitung naik saat terlihat. Tanpa 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 {}

    Contoh

    Varian

    Ukuran

    Di navbar

    Instalasi

    npx markasui@latest add github-stars-button

    Pemakaian

    <x-markas.github-stars-button href="https://github.com/markasui/markasui" :stars="12480" stars-label="{count} bintang">Beri bintang</x-markas.github-stars-button>
    import { GithubStarsButton } from "@/components/markas/GithubStarsButton";
    
    <GithubStarsButton
      href="https://github.com/markasui/markasui"
      stars={12480}
      starsLabel="{count} bintang"
    >
      Beri bintang
    </GithubStarsButton>;
    <script setup lang="ts">
    import GithubStarsButton from "@/components/markas/GithubStarsButton.vue";
    </script>
    
    <template>
      <GithubStarsButton
        href="https://github.com/markasui/markasui"
        :stars="12480"
        stars-label="{count} bintang"
      >
        Beri bintang
      </GithubStarsButton>
    </template>
    <script lang="ts">
      import GithubStarsButton from "$lib/components/markas/GithubStarsButton.svelte";
    </script>
    
    <GithubStarsButton
      href="https://github.com/markasui/markasui"
      stars={12480}
      starsLabel={"{count} bintang"}
    >
      Beri bintang
    </GithubStarsButton>
    ---
    import GithubStarsButton from "@/components/markas/GithubStarsButton.astro";
    ---
    
    <GithubStarsButton
      href="https://github.com/markasui/markasui"
      stars={12480}
      starsLabel="{count} bintang"
    >
      Beri bintang
    </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"
          starsLabel="{{ '{' }}count} bintang"
        >
          Beri bintang
        </a>
      `,
    })
    export class Repo {}

    Angular memakai attribute selector pada link native, jadi target, rel, dan aria-* tetap di link itu. Di template Angular, { ditulis sebagai {{ '{' }}.

    • Komponen tidak pernah memanggil API GitHub. Ambil jumlahnya saat build atau di server lalu kirim lewat prop.
    • Angka yang tampil ringkas (980, 12.5k, 1.2M). {count} di starsLabel diganti angka lengkap dengan pemisah ribuan.
    • Hitungan naik mulai saat tautan pertama kali terlihat. Blade butuh Alpine.js untuk animasinya dan tetap menampilkan angka akhir tanpa Alpine.

    Props

    NamaTipeDefaultKeterangan
    hrefstring-URL repositori. Skema tidak aman seperti javascript: diganti #.
    starsnumber0Jumlah bintang yang kamu kirim. Ditampilkan sebagai 980, 12.5k, atau 1.2M.
    variant'primary' | 'secondary' | 'ghost' | 'danger'secondaryGaya visual, sama seperti Button.
    size'sm' | 'md' | 'lg'mdTinggi 32, 40, atau 48px, sama seperti Button.
    starsLabelstring{count} starsTeks tersembunyi untuk jumlah. {count} diganti angka lengkap, misalnya 12,480.

    Aksesibilitas

    • Elemen a native dengan outline fokus 2px warna primary.
    • Angka beranimasi aria-hidden, screen reader mendengar starsLabel dengan angka lengkap.
    • Logo GitHub dan ikon bintang aria-hidden.
    • Dengan prefers-reduced-motion angka akhir langsung tampil.

    Komponen terkait

    Komponen tombol lain dengan class yang sama di setiap framework.