Text Shimmer Effect
Animated gradient text with automatic cycling
Agent is thinking...
<script setup lang="ts">
import { ShimmeringText } from '@/components/elevenlabs-ui/shimmering-text'
import { AnimatePresence, Motion } from 'motion-v'
import { onMounted, onUnmounted, ref } from 'vue'
const phrases = [
'Agent is thinking...',
'Processing your request...',
'Analyzing the data...',
'Generating response...',
'Almost there...',
]
const currentIndex = ref(0)
let intervalId: ReturnType<typeof setInterval>
onMounted(() => {
intervalId = setInterval(() => {
currentIndex.value = (currentIndex.value + 1) % phrases.length
}, 3000)
})
onUnmounted(() => {
clearInterval(intervalId)
})
</script>
<template>
<div class="bg-card w-full rounded-lg border p-6">
<div class="mb-4">
<h3 class="text-lg font-semibold">
Text Shimmer Effect
</h3>
<p class="text-muted-foreground text-sm">
Animated gradient text with automatic cycling
</p>
</div>
<div class="space-y-4">
<div class="bg-muted/10 flex items-center justify-center rounded-lg py-8">
<AnimatePresence mode="wait">
<Motion
: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>
</AnimatePresence>
</div>
</div>
</div>
</template>Installation
pnpm dlx elevenlabs-ui-vue@latest add shimmering-text
Usage
import { ShimmeringText } from "@/components/elevenlabs-ui/shimmering-text"Basic Usage
<ShimmeringText text="Hello, World!" />Custom Duration and Colors
<template>
<ShimmeringText
text="Custom Shimmer"
:duration="3"
:color="'#6B7280'"
:shimmerColor="'#3B82F6'"
/>
</template>Trigger on Viewport Entry
<template>
<ShimmeringText
text="Appears when scrolled into view"
:startOnView="true"
:once="true"
/>
</template>Repeating Animation
<template>
<ShimmeringText
text="Repeating Shimmer"
:repeat="true"
:repeatDelay="1"
:duration="2"
/>
</template>With Custom Styling
<template>
<ShimmeringText
text="Large Heading"
class="text-4xl font-bold"
:spread="3"
/>
</template>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 |
| class | 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-v for smooth, performant animations
- Uses CSS gradient background animation for the shimmer effect
- Viewport detection powered by Motion-v's
useInViewhook - Dynamic spread calculation based on text length for consistent appearance
- Supports custom colors via CSS custom properties
- Text uses
background-clip: textfor gradient effect - Default colors adapt to light/dark mode automatically
- Optimized with
computedfor performance - Animation can be controlled via viewport intersection or immediate start