Sparkle text
Also called sparkles text, twinkle text, or glitter text effect
Small star-shaped sparkles that pop in, twinkle, and fade at random spots around a word, so it looks freshly polished or newly unlocked.
import { useEffect, useState } from 'react';
import { motion, useReducedMotion } from 'motion/react';
type Sparkle = { id: number; x: number; y: number; size: number };
const LIFE_MS = 1000;
const SPAWN_MS = 200;
// Shown instead of the animation when reduced motion is on.
const STILL: Sparkle[] = [
{ id: -1, x: 0, y: 10, size: 0.35 },
{ id: -2, x: 60, y: -20, size: 0.25 },
{ id: -3, x: 100, y: 80, size: 0.3 }
];
const STAR =
'M12 0c.7 6.5 5.5 11.3 12 12-6.5.7-11.3 5.5-12 12-.7-6.5-5.5-11.3-12-12C6.5 11.3 11.3 6.5 12 0Z';
export function SparkleText({ children }: { children: string }) {
const reduceMotion = useReducedMotion();
const [sparkles, setSparkles] = useState<Sparkle[]>([]);
useEffect(() => {
if (reduceMotion) return;
let id = 0;
// Random spots are picked in the browser, after hydration.
const timer = setInterval(() => {
const sparkle = {
id: id++,
x: Math.random() * 110 - 5, // % of the word box, with overhang
y: Math.random() * 140 - 20,
size: 0.15 + Math.random() * 0.25 // em, so it scales with the text
};
// Each sparkle lives one second, so keep only the last few.
setSparkles((list) => [...list.slice(-(LIFE_MS / SPAWN_MS)), sparkle]);
}, SPAWN_MS);
return () => clearInterval(timer);
}, [reduceMotion]);
return (
<span className='relative inline-block'>
{children}
<span aria-hidden className='pointer-events-none absolute inset-0'>
{(reduceMotion ? STILL : sparkles).map((s) => (
<motion.svg
key={s.id}
viewBox='0 0 24 24'
className='absolute -translate-1/2 fill-amber-500'
style={{ left: `${s.x}%`, top: `${s.y}%`, width: `${s.size}em`, height: `${s.size}em` }}
initial={reduceMotion ? false : { scale: 0, rotate: -30 }}
animate={reduceMotion ? undefined : { scale: [0, 1, 0], rotate: [-30, 20, 75] }}
transition={{ duration: LIFE_MS / 1000, ease: 'easeInOut' }}
>
<path d={STAR} />
</motion.svg>
))}
</span>
</span>
);
}Add sparkle text to the "Your app is live" heading: every 200ms, spawn a 4-point star (12 to 22px, amber) at a random spot in the heading box plus a 20% overhang, mostly along the top and bottom edges. Scale each star from 0 to 1 and back to 0 with a 75-degree twist over 1 second, then remove it. Keep the sparkle layer aria-hidden, stop spawning while the heading is off-screen, and show three still sparkles when prefers-reduced-motion is set.
Paste into Layerwise or any AI coding tool.
What is Sparkle text?
Sparkle text scatters tiny star shapes around a word. Each sparkle appears at a random spot near the text, grows from nothing, twists a little as it twinkles, and shrinks away about a second later while new ones keep arriving. The word stays plain text; the sparkles live in a decorative layer around it.
It fits celebratory and premium moments: a "Your app is live" confirmation, a Pro badge, a new feature name, or an achievement. Keep it to one word or short phrase per screen, with three to six sparkles visible at once, so it reads as a quick glint.
Place sparkles in percentages of the word box and size them in em, so they scale with the text. Mark the sparkle layer aria-hidden and stop spawning while the word is off-screen. Random positions picked on the server will not match the browser, so pick them after hydration or from a seeded generator. When someone prefers reduced motion, show a few still sparkles.
Often confused with
- Confetti
- Confetti bursts many pieces across the screen once, for a moment of success. Sparkle text keeps a few small glints twinkling around one word.
Related terms
All termsConfetti
A burst of small colored pieces that fly out and flutter down to celebrate a moment, such as finishing signup or publishing a site.
Shimmer text
Text with a band of light sweeping across it on a loop, often used for "Thinking…" and other status labels while an app is working.
Glow effect
A soft halo of colored light around a button, card, or text, made with colored shadows or a blurred layer behind the element.
Particle background
A backdrop of small dots that drift slowly, often linked by faint lines when they pass close to each other, behind a hero or sign-in screen.
Build it with Layerwise
Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.