Text Shimmer
forgeui/text-shimmerFreeComponent
A React component that creates an animated text shimmer effect using Motion, customizable by tag, duration, spread, delay, and repeat delay.
Live preview
live · rendered by the registry
Rendered by ForgeUI on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://forgeui.in/r/text-shimmer.jsonSource
1"use client";23import { cn } from "@/lib/utils";4import { motion } from "motion/react";5import React, { useMemo, type JSX } from "react";67export type TextShimmerProps = {8 children: string;9 as?: React.ElementType;10 className?: string;11 duration?: number;12 spread?: number;13 delay?: number;14 repeatDelay?: number;15};1617const TextShimmer = ({18 children,19 as: Component = "p",20 className,21 duration = 2,22 spread = 2,23 delay = 0,24 repeatDelay = 0,25}: TextShimmerProps) => {26 const MotionComponent = motion.create(27 Component as keyof JSX.IntrinsicElements,28 );2930 const dynamicSpread = useMemo(() => {31 return children.length * spread;32 }, [children, spread]);3334 return (35 <MotionComponent36 className={cn(37 "relative inline-block bg-size-[250%_100%,auto] bg-clip-text",38 "text-transparent [--base-color:#a1a1aa] [--base-gradient-color:#000]",39 "[background-repeat:no-repeat,padding-box] [--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--base-gradient-color),#0000_calc(50%+var(--spread)))]",40 "dark:[--base-color:#71717a] dark:[--base-gradient-color:#ffffff] dark:[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--base-gradient-color),#0000_calc(50%+var(--spread)))]",41 className,42 )}43 initial={{ backgroundPosition: "105% center" }}44 animate={{ backgroundPosition: "-5% center" }}45 transition={{46 repeat: Number.POSITIVE_INFINITY,47 duration,48 ease: "linear",49 delay,50 repeatDelay,51 }}52 style={53 {54 "--spread": `${dynamicSpread}px`,55 backgroundImage: `var(--bg), linear-gradient(var(--base-color), var(--base-color))`,56 } as React.CSSProperties57 }58 >59 {children}60 </MotionComponent>61 );62};6364export default React.memo(TextShimmer);
Files it writes
More from ForgeUI
All 28 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Formanimated-form | ForgeUI | Components | Free | no deps | |
| Animated OTPanimated-otp | ForgeUI | Components | Free | no deps | |
| Animated Tabsanimated-tabs | ForgeUI | Components | Free | no deps | |
| Auralisauralis | ForgeUI | Components | Free | no deps | |
| Bot Detectionbot-detection | ForgeUI | Components | Free | no deps | |
| Chromatic Fluidchromatic-fluid | ForgeUI | Components | Free | no deps | |
| Cloudscapecloudscape | ForgeUI | Components | Free | no deps | |
| Cosmicriftcosmicrift | ForgeUI | Components | Free | no deps |
