Gradient Text

Text filled with a gradient that sweeps slowly across it.

gradient-text.tsx

Installation

1

Install the packages

npm install @prequelui/react motion

@prequelui/react reuses the primitive library your components already depend on.

2

Add the component

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/gradient-text.json

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/gradient-text.json

3

Turn on the motion

npx @prequelui/cli@latest animate gradient-text

The CLI finds the component through components.json, swaps the import and removes the CSS animation classes that Motion replaces.

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.

gradient-text.tsx
import { GradientText } from "@/components/prequelui/gradient-text";

export default function Demo() {
  return (
    <GradientText
      text="A gradient that keeps moving"
      neon
      className="text-4xl font-medium"
    />
  );
}
import { GradientText } from "@/components/prequelui/gradient-text";

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

Animation

The text is painted by a gradient three times wider than the word. The background position travels from the first stop to the far end over fifty seconds, so the colour drift is slow enough to read through.

  • Loop: 50 s linear, background position 0% → 500%.
  • The loop pauses when the element leaves the viewport or the tab is hidden.
  • The neon layer repeats the gradient with an 8 px blur and plus-lighter blending.
  • Reduced motion freezes the gradient at its first frame.
loop 50 slinear700% backgroundblur 8 px

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.

GradientText

PropTypeDefault
textstring—
gradientstringblue → violet → pink
neonbooleanfalse
transitionTransitioncomponent spring or tween
classNamestring—

Built by Vidhal. The source is available on GitHub.

Last updated: 11/17/2026