Ir al contenido
Español
Texto con destellos viene con Pro. La vista previa aparece al desbloquearlo.

Cómo funciona

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.

Úsalo para

  • 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.

Busca otra opción cuando

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

Uso

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

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

Propiedades

PropiedadTipoPor defectoQué hace
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.

Accesibilidad

  • 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.

Movimiento

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.

Añádelo a tu proyecto

Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.

SparklesText.jsxsparkles-text.csstokens.cssREADME.md

Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

Texto animado
Texto que se transforma viene con Pro. La vista previa aparece al desbloquearlo.