Text Shimmer Effect
Animated gradient text with automatic cycling
Agent is thinking...
"use client"
import { useEffect, useState } from "react"
import { AnimatePresence, motion } from "motion/react"
import { ShimmeringText } from "@/components/ui/shimmering-text"
const phrases = [
"Agent is thinking...",
"Processing your request...",
"Analyzing the data...",
"Generating response...",
"Almost there...",
]
export function TextShimmerDemo() {
const [currentIndex, setCurrentIndex] = useState(0)
useEffect(() => {
const interval = setInterval(() => {
setCurrentIndex((prev) => (prev + 1) % phrases.length)
}, 3000)
return () => clearInterval(interval)
}, [])
return (
<div className="bg-card w-full rounded-lg border p-6">
<div className="mb-4">
<h3 className="text-lg font-semibold">Text Shimmer Effect</h3>
<p className="text-muted-foreground text-sm">
Animated gradient text with automatic cycling
</p>
</div>
<div className="space-y-4">
<div className="bg-muted/10 flex items-center justify-center rounded-lg py-8">
<AnimatePresence mode="wait">
<motion.div
key={currentIndex}
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -10 }}
transition={{ duration: 0.3 }}
>
<ShimmeringText text={phrases[currentIndex]} />
</motion.div>
</AnimatePresence>
</div>
</div>
</div>
)
}
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
Prop | Type | Default | Description |
---|---|---|---|
text | string | - | Required. Text to display with shimmer effect |
duration | number | 2 | Animation duration in seconds |
delay | number | 0 | Delay before starting animation |
repeat | boolean | true | Whether to repeat the animation |
repeatDelay | number | 0.5 | Pause duration between repeats in seconds |
className | string | - | Optional CSS classes |
startOnView | boolean | true | Whether to start animation when entering viewport |
once | boolean | false | Whether to animate only once |
inViewMargin | string | - | Margin for viewport detection (e.g., "0px 0px -10%") |
spread | number | 2 | Shimmer spread multiplier |
color | string | - | Base text color (CSS custom property) |
shimmerColor | string | - | 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
Deploy and Scale Agents with ElevenLabs
ElevenLabs delivers the infrastructure and developer experience you need to ship reliable audio & agent applications at scale.
Talk to an expert