Skip to content
English
Sparkles text comes with Pro. Its preview shows once you unlock it.

How it works

The phrase sits in an inline block and the stars are placed around it in percentages: within its width, and mostly above and below the letters rather than across them, so the words stay readable. Each star grows from nothing while turning, peaks, shrinks away and rests for the last third of its cycle, so only some are lit at any moment; when a twinkle ends the star moves to a new random spot, so the pattern never visibly repeats. The first layout is seeded, so server and browser render the same. The phrase takes a gradient of the same palette, mixed with the text colour so it keeps its contrast.

Use it for

  • Celebrating a milestone, a reward or a new feature in a short phrase.
  • A single word or figure that deserves delight on a quiet page.

Look elsewhere when

  • Long text or several places per screen.
  • Serious contexts such as errors, billing or legal text.

Usage

import { SparklesText } from './SparklesText.jsx'

export function Milestone() {
  return (
    <h2>
      Your newsletter just passed <SparklesText palette="gold" count={8}>1,000 readers</SparklesText>
    </h2>
  )
}

Props

PropTypeDefaultWhat it does
childrenReactNode—The phrase to highlight; keep it short.
countnumber8Number of stars (0 to 24).
palette'gold' | 'accent' | 'rainbow''gold'Star and highlight colours.
sizenumber16Largest star size in px.
speednumber1Twinkle pace multiplier.
highlightbooleantrueGives the phrase a matching gradient fill.
asElementType'span'Element to render.

Accessibility

  • The stars are aria-hidden SVGs; screen readers read only the phrase.
  • The gradient fill mixes each colour with the body text colour, keeping large text above 3:1 in both themes; forced-colors mode shows plain text without stars.
  • Stars avoid sitting across the letters, so the phrase is never obscured.
  • Reduced motion freezes four small stars around the phrase and hides the rest.

Motion

Each twinkle lasts 1.6–2.8s (divided by speed) with an ease-in-out: it grows while turning 45° to its peak at 45% of the cycle, shrinks while turning another 45° by 70%, then rests.

Add it to your project

Pro members copy a prompt and their coding agent installs the source, the same way as the free components.

SparklesText.jsxsparkles-text.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Text motion
Morphing text comes with Pro. Its preview shows once you unlock it.