Sparkles Text
MotionHeadline text with four point stars that twinkle around it in your accent colors. The sparkles are decorative and hidden; the text stays plain and readable.
Installation
npx shadcn@latest add @minidev/sparkles-text
MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/sparkles-text.json
Usage
import { SparklesText } from "@/components/ui/sparkles-text"
export function Example() {
return (
<SparklesText />
)
}
API reference
When to use
Use it for one short celebratory word or phrase. Reach for GradientText for a still accent and ConfettiButton for a one-off burst on success.
Accessibility
- Each star is an
aria-hiddenSVG withpointer-events-none; the text stays a normal text node. - It renders a
<span>. Wrap it in a heading if the phrase is a heading. - Under reduced motion no stars appear.
Frequently asked questions
Does SparklesText keep running off screen?
No. New stars only spawn while the text is in view, one every 420ms, and none spawn under reduced motion. count sets how many are alive at once (default 8).
Why are there no sparkles in the server HTML?
Stars are created with random positions in an effect after mount, so the server renders only the text and hydration matches.
Dependencies
npm
Built from
Examples
Custom text
The text is a normal text node; stars are decorative and hidden from assistive tech.
More stars, smaller text
count is how many stars are alive at once; size the text with className.
Inside a headline
Match the headline's size and weight with className to sparkle one phrase in a longer line.