Components

Text Animate

A text animation component for React and Tailwind CSS with six presets (fade in, blur in, slide up, slide down, scale up and blur in up) that animates by character, word or line, on mount or when scrolled into view. The finished text is server-rendered for SEO, line mode follows how the text really wraps, and the heading level is yours to choose.

  • 6 presets
  • Character, word or line
  • On mount or in view
  • Server-rendered text
  • prefers-reduced-motion

After hours, on purpose.

Installation

$ npx shadcn@latest add https://duskui.com/r/text-animate.json

Usage

section-title.tsx
import { TextAnimate } from "@/components/dusk/text-animate/text-animate"

export function SectionTitle() {
  return (
    <TextAnimate as="h2" animation="blurInUp" by="character" className="text-5xl font-bold">
      Built for the late shift.
    </TextAnimate>
  )
}

Examples

Presets

animation picks the entrance: fadeIn, blurIn, slideUp, slideDown, scaleUp or blurInUp. Here they run with trigger="mount"; remount to replay.

fadeIn

Quietly brilliant

blurIn

Quietly brilliant

slideUp

Quietly brilliant

slideDown

Quietly brilliant

scaleUp

Quietly brilliant

blurInUp

Quietly brilliant

By line

by="line" measures where the text wraps when the animation starts and moves each visual line together. A \n in the string forces a break. With once={false} it replays on every entry.

Line mode measures where this paragraph actually wraps, so each visual line rises together, at every screen width, without you adding a single line break.

Sequenced heading

Chain several blocks with delay for an eyebrow, title and subtitle. as keeps the real heading structure.

Changelog · v2.0

Faster builds.
Fewer surprises.

A new compiler, smarter caching and a calmer dev server.

API Reference

Also accepts any HTML attribute for the rendered element.

PropTypeDefaultDescription
childrenstring—The text to animate. Plain text; \n starts a new line.
as"p" | "span" | "div" | "strong" | "em" | "blockquote" | "h1" … "h6""p"Element to render. Use a heading level for titles.
animation"fadeIn" | "blurIn" | "slideUp" | "slideDown" | "scaleUp" | "blurInUp""fadeIn"How each piece enters.
by"character" | "word" | "line""word"Split into characters, words, or the visual lines the text wraps onto.
trigger"mount" | "inView""inView"Start on mount or when the text scrolls into view.
delaynumber0Seconds before the first piece.
durationnumber0.45 / 0.6 / 0.75Seconds each piece takes (character / word / line).
staggernumber0.025 / 0.06 / 0.14Seconds between pieces (character / word / line).
oncebooleantrueIn "inView" mode, play only the first time. When false it replays on every entry.
amountnumber0.3How much of the element must be visible to start (0–1).
segmentClassNamestring—Classes for every animated piece.

Accessibility

  • The server renders the finished text, so crawlers and no-JS visitors always see it; pieces are hidden just before the first client paint.
  • In word and line mode the words are the real text. In character mode a visually hidden copy carries the string and the letters are aria-hidden, because some screen readers read split letters one at a time.
  • Letters are grouped per word, so lines only break between words, and split by grapheme so emoji and accents stay intact.
  • Pieces animate with Motion directly on the DOM, with no React state per piece.
  • With prefers-reduced-motion the text is shown immediately.