Lettering hot-stamped in metal foil, in gold, rose, champagne or silver: banded tones, a fine grain, a soft emboss, and a highlight that follows the cursor.
Text that glitters like a cut stone under a spotlight: tiny four-point stars flare and fade across the letters, and the cursor showers a few more.
Brilliant
Customize
Usage
import { DiamondSparkle } from "@/components/motionkit/diamond-sparkle";
<DiamondSparkle as="h1" className="font-serif text-7xl">
Brilliant
</DiamondSparkle>Motion
The exact curves this component runs, plotted with Motion's own maths.
Sparkle
Runs on its own, and pointer moves
Jewellery and engagement pages, beauty launches, celebrations and milestones, premium tiers and anywhere a headline should feel precious.
A timer adds a sparkle at a random spot over the text several times a second, and moving the pointer adds more where it is, no more than one every 90 milliseconds. Each sparkle is a four-point star path with a soft drop-shadow glow. Motion scales it from nothing to full size and back while turning it a quarter turn, then removes it when the animation ends, so there are never more than a couple of dozen at once. The sparkles sit in an overlay hidden from screen readers, so the text is read as written.
Works in the App Router as is. Requires Tailwind CSS v4.
One command adds the file and installs its dependencies. Needs a components.json (run npx shadcn@latest init once if you don't have one).
npx shadcn@latest add https://www.motionkitui.com/r/diamond-sparkle.jsonnpm install motionSave as components/motionkit/diamond-sparkle.tsx.
"use client";
import { useEffect, useRef, useState, type ElementType, type PointerEvent, type ReactNode } from "react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
type Sparkle = { id: number; x: number; y: number; size: number; color: string; turn: number };
type DiamondSparkleProps = {
children: ReactNode;
/** Colours the sparkles take; each picks one. */
colors?: string[];
/** Sparkles appearing per second. */
rate?: number;
/** Largest sparkle, in pixels. */
size?: number;
/** Scatter extra sparkles where the pointer moves. */
interactive?: boolean;
/** The element to render, e.g. "h1". */
as?: ElementType;
className?: string;
};
let next = 0;
/**
* Text that glitters like a cut stone under a spotlight: tiny four-point stars flare and fade at random across the
* letters, each one turning as it blooms. Run the pointer over the text and it showers a few more.
*/
export function DiamondSparkle({
children,
colors = ["#FFFFFF", "#FFF4D6", "#E4F1FF"],
rate = 6,
size = 18,
interactive = true,
as: Tag = "span",
className = "",
}: DiamondSparkleProps) {
const reduceMotion = useReducedMotion();
const ref = useRef<HTMLElement>(null);
const [sparkles, setSparkles] = useState<Sparkle[]>([]);
const lastPointer = useRef(0);
const make = (x: number, y: number): Sparkle => ({
id: next++,
x,
y,
size: size * (0.45 + Math.random() * 0.55),
color: colors[Math.floor(Math.random() * colors.length)],
turn: Math.random() > 0.5 ? 90 : -90,
});
// a steady trickle of sparkles at random places over the text
useEffect(() => {
if (reduceMotion || rate <= 0) return;
const timer = window.setInterval(() => {
setSparkles((current) => [...current.slice(-24), make(Math.random() * 100, 15 + Math.random() * 70)]);
}, 1000 / rate);
return () => window.clearInterval(timer);
// make reads the latest colours and size each time it runs
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [reduceMotion, rate]);
function move(event: PointerEvent) {
if (!interactive || reduceMotion || event.pointerType === "touch") return;
const now = performance.now();
if (now - lastPointer.current < 90) return;
lastPointer.current = now;
const rect = ref.current!.getBoundingClientRect();
const x = ((event.clientX - rect.left) / rect.width) * 100 + (Math.random() - 0.5) * 8;
const y = ((event.clientY - rect.top) / rect.height) * 100 + (Math.random() - 0.5) * 30;
setSparkles((current) => [...current.slice(-24), make(x, y)]);
}
// with reduced motion, a few still glints sit on the letters instead
const still: Sparkle[] = reduceMotion
? [
{ id: -1, x: 12, y: 25, size: size * 0.8, color: colors[0], turn: 0 },
{ id: -2, x: 58, y: 70, size: size * 0.55, color: colors[1 % colors.length], turn: 0 },
{ id: -3, x: 88, y: 30, size: size * 0.65, color: colors[0], turn: 0 },
]
: [];
return (
<Tag ref={ref} onPointerMove={move} className={`relative inline-block ${className}`}>
<span aria-hidden className="pointer-events-none absolute inset-0 z-10 overflow-visible">
{still.map((sparkle) => (
<Star key={sparkle.id} sparkle={sparkle} />
))}
<AnimatePresence>
{sparkles.map((sparkle) => (
<motion.span
key={sparkle.id}
className="absolute"
style={{ left: `${sparkle.x}%`, top: `${sparkle.y}%` }}
initial={{ scale: 0, rotate: 0, opacity: 1 }}
animate={{ scale: [0, 1, 0], rotate: sparkle.turn, opacity: [1, 1, 0.6] }}
transition={{ duration: 0.9, ease: "easeInOut" }}
onAnimationComplete={() => setSparkles((current) => current.filter((item) => item.id !== sparkle.id))}
>
<Star sparkle={sparkle} />
</motion.span>
))}
</AnimatePresence>
</span>
<span className="relative">{children}</span>
</Tag>
);
}
// a four-point star with a soft glow, centred on its position
function Star({ sparkle }: { sparkle: Sparkle }) {
const { size, color } = sparkle;
return (
<svg
viewBox="0 0 24 24"
width={size}
height={size}
className="absolute"
style={{ left: sparkle.id < 0 ? `${sparkle.x}%` : undefined, top: sparkle.id < 0 ? `${sparkle.y}%` : undefined, transform: "translate(-50%, -50%)", filter: `drop-shadow(0 0 ${size / 4}px ${color})` }}
>
<path d="M12 0C12.6 7 17 11.4 24 12C17 12.6 12.6 17 12 24C11.4 17 7 12.6 0 12C7 11.4 11.4 7 12 0Z" fill={color} />
</svg>
);
}
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | The text. |
| colors | string[] | ["#FFFFFF", "#FFF4D6", "#E4F1FF"] | Colours the sparkles take. |
| rate | number | 6 | Sparkles per second. |
| size | number | 18 | Largest sparkle, in pixels. |
| interactive | boolean | true | Scatter extra sparkles where the pointer moves. |
| as | ElementType | "span" | Element to render, e.g. h1. |
How we audit: the WCAG 2.2 animation checklist and respecting reduced motion in React.
Yes. The file starts with "use client", so you can import it straight into a Server Component page or layout. It works in Vite as is, and in Astro as a React island.
Only the motion package, beside React and Tailwind CSS v4. There is no MotionKit package and no Tailwind config to add.
Yes. Run npx shadcn@latest add https://www.motionkitui.com/r/diamond-sparkle.json in any project with a components.json. It saves the file to components/motionkit and installs its dependencies.
With reduced motion on, three still glints rest on the letters instead. Otherwise sparkles appear forever, so beside other content for more than 5 seconds WCAG 2.2.2 asks for a way to pause them.
Lettering hot-stamped in metal foil, in gold, rose, champagne or silver: banded tones, a fine grain, a soft emboss, and a highlight that follows the cursor.
A name revealed like a fashion house film opening: letters arrive spaced wide and out of focus, then draw together and sharpen, over a hairline rule and a subtitle.
Rotates through a list of words, letters rising in and drifting out.