Back to TextsYou are on Shimmering Text.

Shimmering Text

A letter-by-letter wave of light crosses the text.

Available inAvailable in React, Vue, Svelte, Solid, JavaScript· All five frameworks
PrequelUI

Libraries

PrequelUI

Motion

Spring + short tween

Reduced motion

Fade in place
shimmering-text.tsx
Play with the real component, then read the code it ships with.All components
01

Installation

Installing for React·components/prequelui/shimmering-text.tsx

Add the component

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/shimmering-text.json
npmthe default on every machine

First component? Set up your project first

Frameworks

The live preview is React. Each tab below is the file that ships for that framework, with the same durations, springs and reduced-motion rule.

5 runtimes
shimmering-text.tsx
"use client";

import * as React from "react";
import { motion, useInView, type HTMLMotionProps } from "motion/react";
import { cn } from "@/lib/utils";
import {
  splitGraphemes,
  srOnlyStyle,
  usePageVisible,
  useReduceMotion,
  useTempo,
} from "./motion";

export type ShimmeringTextProps = Omit<HTMLMotionProps<"span">, "children"> & {
  text: string;
  duration?: number;
  wave?: boolean;
  color?: string;
  shimmeringColor?: string;
};

const REST = { x: 0, y: 0, scale: 1, rotateY: 0 };
const WAVE = {
  x: [0, 5, 0],
  y: [0, -5, 0],
  scale: [1, 1.1, 1],
  rotateY: [0, 15, 0],
};

export function ShimmeringText({
  text,
  duration = 1,
  wave = false,
  color = "var(--muted-foreground)",
  shimmeringColor = "var(--foreground)",
  className,
  style,
  ...props
}: ShimmeringTextProps) {
  const ref = React.useRef<HTMLSpanElement>(null);
  const inView = useInView(ref);
  const pageVisible = usePageVisible();
  const reduce = useReduceMotion();
  const tempo = useTempo();
  const playing = inView && pageVisible && !reduce;
  const chars = React.useMemo(() => splitGraphemes(text ?? ""), [text]);
  const span = duration * tempo;

  return (
    <motion.span
      ref={ref}
      data-slot="shimmering-text"
      className={cn("relative inline-block", className)}
      style={
        {
          "--shimmer-color": shimmeringColor,
          "--shimmer-base": color,
          color,
          perspective: "500px",
          ...style,
        } as React.CSSProperties
      }
      {...props}
    >
      <span className="sr-only" style={srOnlyStyle()}>
        {text}
      </span>
      <span aria-hidden="true" className="inline-block" style={{ perspective: "inherit" }}>
        {chars.map((char, index) => (
          <motion.span
            key={`${char}-${index}`}
            className="inline-block whitespace-pre"
            style={{ transformStyle: "preserve-3d" }}
            initial={{ ...(wave ? { scale: 1, rotateY: 0 } : {}), opacity: 1 }}
            animate={
              playing
                ? {
                    ...(wave ? WAVE : {}),
                    opacity: [1, 0.35, 1],
                  }
                : { ...(wave ? REST : {}), opacity: 1 }
            }
            transition={
              playing
                ? {
                    duration: span,
                    repeat: Infinity,
                    repeatDelay: chars.length * 0.05,
                    delay: (index * span) / Math.max(1, chars.length),
                    ease: "easeInOut",
                  }
                : { duration: 0 }
            }
          >
            {char}
          </motion.span>
        ))}
      </span>
    </motion.span>
  );
}

Install

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/shimmering-text.json
npmthe default on every machine

Dependencies

motion lucide-react

The registry keeps the component source, its motion tokens and the reduced-motion branch together, so the install never pulls a different animation from the preview.

02

Usage

Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.

shimmering-text.tsx
import { ShimmeringText } from "@/components/prequelui/shimmering-text";

export default function Demo() {
  return (
    <ShimmeringText
      text="Shimmering"
      duration={1}
      wave
      className="text-3xl font-medium"
    />
  );
}
import { ShimmeringText } from "@/components/prequelui/shimmering-text";

export function Variant() {
  return (
    <ShimmeringText tempo={1.2}>
      …
    </ShimmeringText>
  );
}
03

Animation

A band of light crosses the string letter by letter. Each letter follows the same opacity cycle with a delay proportional to its position, so the highlight travels instead of blinking; the wave option adds a small lift, scale and rotation.

  • Opacity cycle: 1 s ease-in-out per letter, looping.
  • Letter delay: index × duration ÷ letter count.
  • Repeat delay after a full pass: letter count × 50 ms.
  • Reduced motion holds the resting colour and no transform.
1 s loopopacity 1 → 0.35per-letter delaywave 5 px
04

API Reference

Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.

ShimmeringText

PropTypeDefault
textstring—
durationnumber1
wavebooleanfalse
colorstringmuted foreground
shimmeringColorstringforeground

Next component

Sliding Text

Text slides out of its box while a copy slides in.