Ir al contenido
Español
Aparición de texto viene con Pro. La vista previa aparece al desbloquearlo.

Cómo funciona

Text is first split into words and spaces, using Intl.Segmenter when available. Punctuation joins a neighbouring word so it never starts a line. In character mode, each CJK character is a group and each Latin word is one non-breaking group animated letter by letter. Pieces are inline-block with one --i variable and the delay is a CSS calc. The animation uses backwards fill, so no filter remains.

Úsalo para

  • Headlines and hero text on landing pages.
  • Short statements that should be read one beat at a time.
  • Text that should appear only when it scrolls into view (trigger="inView").

Busca otra opción cuando

  • Long paragraphs: the reveal takes too long and slows reading.
  • Text people must read at once, such as errors and prices.
  • Content that updates often: every change would replay the animation.

Uso

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

export function Hero() {
  return (
    <>
      <TextReveal as="h1" text="Make every moment count" split="char" stagger={40} />
      <TextReveal as="p" text="Plan, track and share your days" split="word" delay={300} trigger="inView" />
    </>
  )
}

Propiedades

PropiedadTipoPor defectoQué hace
textstring—The text to show. It may contain line breaks (\n).
as'h1' | 'h2' | 'h3' | 'h4' | 'p' | 'span' | 'div''p'Tag to render.
split'char' | 'word''char'How to split: by character or by word (Chinese is grouped into words, falling back to characters without Intl.Segmenter).
staggernumber40Interval between neighbouring pieces, in ms.
durationnumber560Reveal time of each piece, in ms.
delaynumber0Delay before the whole reveal starts, in ms.
blurbooleantrueWhether to include a 6px to 0 blur.
distancenumber | string'0.35em'Rise distance; numbers are px.
trigger'mount' | 'inView''mount'Play on mount, or when scrolled into view (only once).
replayKeyKey—Changing it plays the reveal again.
localestring'zh-CN'Language used to split words. It does not change the text.
onComplete() => void—Called when the last piece finishes revealing.
...restHTMLAttributes<HTMLElement>—Other attributes go to the root element, such as className, style and id.

Accesibilidad

  • Screen readers read one complete hidden copy of the text; all split pieces are aria-hidden.
  • The hidden copy cannot be selected, so copying text does not produce it twice.
  • Reduced motion shows the text at once, and onComplete is still called.
  • Waiting pieces stay hidden instead of flashing before they play.
  • Keep contrast and size as for any text; the effect never changes the final look.

Movimiento

Each piece takes 560ms ease-out (cubic-bezier(0.16, 1, 0.3, 1)), 40ms apart; it rises 0.35em and un-blurs from 6px to 0.

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.

TextReveal.jsxtext-reveal.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.