Shimmer Text

Smooth shimmer animation for premium touch.

Processing prompt to generate result.
TSX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
"use client"; import { motion } from "motion/react"; import { cn } from "@/lib/utils"; type Variant = | "default" | "secondary" | "destructive" | "red" | "blue" | "green" | "yellow" | "purple" | "pink" | "orange" | "cyan" | "indigo" | "violet" | "rose" | "amber" | "lime" | "emerald" | "sky" | "slate" | "fuchsia"; interface ShimmerTextProps { children: React.ReactNode; className?: string; variant?: Variant; duration?: number; delay?: number; spread?: number; } const variantMap: Record<Variant, string> = { default: "", secondary: "text-secondary-foreground", destructive: "text-destructive dark:text-destructive-foreground", red: "text-red-600 dark:text-red-400", blue: "text-blue-600 dark:text-blue-400", green: "text-green-600 dark:text-green-400", yellow: "text-yellow-600 dark:text-yellow-400", purple: "text-purple-600 dark:text-purple-400", pink: "text-pink-600 dark:text-pink-400", orange: "text-orange-600 dark:text-orange-400", cyan: "text-cyan-600 dark:text-cyan-400", indigo: "text-indigo-600 dark:text-indigo-400", violet: "text-violet-600 dark:text-violet-400", rose: "text-rose-600 dark:text-rose-400", amber: "text-amber-600 dark:text-amber-400", lime: "text-lime-600 dark:text-lime-400", emerald: "text-emerald-600 dark:text-emerald-400", sky: "text-sky-600 dark:text-sky-400", slate: "text-slate-600 dark:text-slate-400", fuchsia: "text-fuchsia-600 dark:text-fuchsia-400", }; export function ShimmerText({ children, className, variant = "default", duration = 1.5, delay = 1.5, }: ShimmerTextProps) { return ( <div className="group overflow-hidden"> <div> <motion.div className={cn( "inline-block [--shimmer-contrast:rgba(255,255,255,0.6)] dark:[--shimmer-contrast:rgba(0,0,0,0.5)]", variantMap[variant], className, )} style={ { WebkitTextFillColor: "transparent", background: "currentColor linear-gradient(to right, currentColor 0%, var(--shimmer-contrast) 40%, var(--shimmer-contrast) 60%, currentColor 100%)", WebkitBackgroundClip: "text", backgroundClip: "text", backgroundRepeat: "no-repeat", backgroundSize: "50% 200%", } as React.CSSProperties } initial={{ backgroundPositionX: "250%", }} animate={{ backgroundPositionX: ["-100%", "250%"], }} transition={{ duration: duration, delay: delay, repeat: Infinity, repeatDelay: 1.5, ease: "linear", }} > <span>{children}</span> </motion.div> </div> </div> ); } export default ShimmerText;

Installation

pnpm dlx shadcn@latest add @satoriui/shimmer-text