Shimmering Text

PreviousNext

Animated text with gradient shimmer effects and viewport-triggered animations using Motion.

Installation

pnpm dlx @elevenlabs/agents-cli@latest components add shimmering-text

Usage

import { ShimmeringText } from "@/components/ui/shimmering-text"

Basic Usage

<ShimmeringText text="Hello, World!" />

Custom Duration and Colors

<ShimmeringText
  text="Custom Shimmer"
  duration={3}
  color="#6B7280"
  shimmerColor="#3B82F6"
/>

Trigger on Viewport Entry

<ShimmeringText
  text="Appears when scrolled into view"
  startOnView={true}
  once={true}
/>

Repeating Animation

<ShimmeringText
  text="Repeating Shimmer"
  repeat={true}
  repeatDelay={1}
  duration={2}
/>

With Custom Styling

<ShimmeringText
  text="Large Heading"
  className="text-4xl font-bold"
  spread={3}
/>

API Reference

ShimmeringText

An animated text component with gradient shimmer effect and viewport detection.

Props

PropTypeDefaultDescription
textstring-Required. Text to display with shimmer effect
durationnumber2Animation duration in seconds
delaynumber0Delay before starting animation
repeatbooleantrueWhether to repeat the animation
repeatDelaynumber0.5Pause duration between repeats in seconds
classNamestring-Optional CSS classes
startOnViewbooleantrueWhether to start animation when entering viewport
oncebooleanfalseWhether to animate only once
inViewMarginstring-Margin for viewport detection (e.g., "0px 0px -10%")
spreadnumber2Shimmer spread multiplier
colorstring-Base text color (CSS custom property)
shimmerColorstring-Shimmer gradient color (CSS custom property)

Notes

  • Built with Motion for smooth, performant animations
  • Uses CSS gradient background animation for the shimmer effect
  • Viewport detection powered by Motion's useInView hook
  • Dynamic spread calculation based on text length for consistent appearance
  • Supports custom colors via CSS custom properties
  • Text uses background-clip: text for gradient effect
  • Default colors adapt to light/dark mode automatically
  • Optimized with useMemo for performance
  • Animation can be controlled via viewport intersection or immediate start