An animated shimmering text effect, ideal for loading and "thinking" states.
Text Shimmer Effect
Animated gradient text with automatic cycling
Agent is thinking...
Installation
npx shadcn-svelte@latest add https://sv11.ui.twango.dev/r/shimmering-text.json Usage
<script lang="ts">
import { ShimmeringText } from "$lib/registry/ui/shimmering-text";
</script>
<ShimmeringText /> Examples
Basic Usage
Pass any string to text and the shimmer begins as soon as the element enters the viewport.
<script lang="ts">
import { ShimmeringText } from "$lib/registry/ui/shimmering-text";
</script>
<ShimmeringText text="Hello, World!" /> Custom Duration and Colors
Slow the sweep down with duration and override the gradient with color (base) and shimmerColor (highlight).
<ShimmeringText text="Custom Shimmer" duration={3} color="#6B7280" shimmerColor="#3B82F6" /> Trigger on Viewport Entry
Set once to true so the animation fires a single time when the element scrolls into view.
<ShimmeringText text="Appears when scrolled into view" startOnView once /> Repeating Animation
Control the repeat loop with repeat and repeatDelay.
<ShimmeringText text="Repeating Shimmer" repeat repeatDelay={1} duration={2} /> With Custom Styling
Merge Tailwind utilities through class and widen the highlight with spread.
<ShimmeringText text="Large Heading" class="text-4xl font-bold" spread={3} /> API Reference
Notes
- Built on Motion — uses
animatefor the sweep andinViewfor viewport detection. - The shimmer is a CSS gradient painted over the text via
background-clip: text, so it inherits font weight, kerning, and line-height from surrounding styles. - Spread scales with text length (
text.length * spreadpixels) so short and long strings read consistently. colorandshimmerColorset the--base-colorand--shimmer-colorcustom properties; leaving them unset falls back tovar(--muted-foreground)andvar(--foreground), which already track light/dark mode.- When
startOnViewistrueandonceisfalse, the animation resumes each time the element re-enters the viewport. - The element is rendered as an inline
<span>, so it composes with surrounding text nodes.