Modal asking to star your open source project. A big counter ticks up to the current star count over an aurora of glowing dots, the title offers the next place (“Be the 34th”), and the GitHub button bursts into stars. It is a native <dialog>: the browser handles the focus trap, Escape and the top layer. The aurora is pure CSS (blurred blobs under a dot-grid mask plus film grain), inspired by Aurora Dots and Film Grain from Glint UI. JavaScript fetches the star count, ticks the counter, opens the dialog on a trigger or a timer and remembers the choice in localStorage.
Browser Support
Limited availability9 featuresDetails
Displays the modal dialog
Animates the entry
Animates closing
Locks page scrolling while open
Dims and blurs the page behind
Cuts the aurora into a dot grid
Blends the film grain
Tints the counter glow with the theme color
Improves text wrapping
Preview
Click the button to open the dialog.
Installation
Usage
import { Button } from "@/components/ui/button"
import { GitHubStarDialog } from "@/components/ui/github-star-dialog"
export default function Page() {
return (
<GitHubStarDialog
owner="goosen-x"
repo="gooseui"
trigger={<Button>Support us</Button>}
/>
)
}Examples
Goal
Pass goal to show a slim progress bar under the counter. Its label is goalText.
<GitHubStarDialog
owner="goosen-x"
repo="gooseui"
goal={50}
goalText={(remaining, goal) => remaining > 0 ? `${remaining} to ${goal}` : "Goal reached!"}
/>Translation
Every text is a prop. Titles, the badge and the description accept functions that get the number and its formatted form, so you can handle plurals and ordinals in any language. locale formats the numbers.
<GitHubStarDialog
owner="goosen-x"
repo="gooseui"
locale="de-DE"
title={(next, formatted) => `Werde Nummer ${formatted}`}
badge={(stars, formatted) => `${formatted} Sterne bisher`}
description="Jeder Stern hilft anderen, das Projekt zu finden."
thanksText="Danke!"
closeLabel="Schließen"
dismissText="Später"
ctaText="Auf GitHub markieren"
/>Auto-open
The dialog opens once, 20 seconds after the page loads. If the user dismisses it or clicks the GitHub button, it will not open on its own again.
<GitHubStarDialog
owner="goosen-x"
repo="gooseui"
defaultOpen
delay={20000}
storageKey="gooseui-star-dialog"
/>Live star count
Without initialStars the count is fetched from the GitHub API. Unauthenticated requests are limited to 60 per hour per IP, so in production pass a cached value from the server.
// Server component
const res = await fetch("https://api.github.com/repos/goosen-x/gooseui", {
next: { revalidate: 3600 },
})
const { stargazers_count } = await res.json()
<GitHubStarDialog owner="goosen-x" repo="gooseui" initialStars={stargazers_count} />Controlled mode
const [open, setOpen] = React.useState(false)
<GitHubStarDialog
owner="goosen-x"
repo="gooseui"
open={open}
onOpenChange={setOpen}
onStar={() => track("star_click")}
/>Props
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| owner | string | - | Repository owner on GitHub |
| repo | string | - | Repository name on GitHub |
| goal | number | - | Star goal. When set, a progress bar toward it appears |
| initialStars | number | - | Star count to use instead of a GitHub request |
| locale | string | "en-US" | Locale for number formatting |
| title | ReactNode | (next, formatted) => ReactNode | "Be the {next}th" | Dialog title. A function gets the next number and its formatted form |
| description | ReactNode | (next, formatted) => ReactNode | - | Text below the title. A function gets the next number and its formatted form |
| badge | ReactNode | (stars, formatted) => ReactNode | null | "{stars} people have already starred" | Pill under the counter. A function gets the star count and its formatted form. null hides it |
| thanksText | ReactNode | "Thank you!" | Title after the GitHub button is clicked |
| goalText | ReactNode | (remaining, goal) => ReactNode | "{remaining} to go" | Label next to the progress bar. Gets the stars left and the formatted goal |
| progressLabel | string | "Stars progress" | Accessible name of the progress bar |
| closeLabel | string | "Close" | Accessible name of the close button |
| dismissText | ReactNode | "Maybe later" | Secondary button text |
| ctaText | ReactNode | "Star on GitHub" | Primary button text |
| trigger | ReactElement | - | Element that opens the dialog. It receives an onClick handler |
| open | boolean | - | Controlled open state |
| onOpenChange | (open: boolean) => void | - | Open state change handler |
| defaultOpen | boolean | false | Open automatically on mount |
| delay | number | 0 | Delay before auto-open, ms |
| storageKey | string | - | localStorage key. After dismissal or a star, auto-open stops |
| onStar | () => void | - | Called when the GitHub button is clicked |
| className | string | - | Additional classes for the dialog |
Features
- Aurora of glowing dots and film grain in pure CSS, no WebGL
- Counter ticks up to the live star count from the GitHub API
- “Be the Nth” title with correct ordinals, star burst on click
- Every text is a prop, with functions for plurals and ordinals
- Auto-open with a delay and dismissal remembered via localStorage
- Native <dialog>: focus trap, close on Escape and backdrop click
- Respects prefers-reduced-motion: the aurora and the counter stand still