🌈 Rainbow Text
Why settle for boring text when you can make it shine with color? ✨ RainbowText is a React component that adds smooth, animated gradient effects to your text, making every word pop with vibrant, eye-catching colors. Perfect for headlines, call-to-actions, banners, landing pages, and playful UI elements, this Framer Motion-powered animation brings a fun and dynamic touch to your design. 🌟
Preview
Follow below steps 👇🏻
Install dependencies
1npm i framer-motion
Component
Create a file rainbow-text.tsx in your components folder and paste this code
1import React, { ReactNode } from 'react';2import { motion } from 'framer-motion';34type RainbowTextProps = {5colors?: string[];6className?: string;7duration?: number;8children?: ReactNode;9};1011const RainbowText = ({12colors = [13'#FF4D4D',14'#FF944D',15'#FFC14D',16'#E8FF4D',17'#6DFF4D',18'#4DFFA1',19'#4DFFFF',20'#4DAAFF',21'#4D6DFF',22'#6D4DFF',23'#A14DFF',24'#D14DFF',25'#FF4DAA',26'#FF4D6D',27'#FF4D4D',28'#FF944D'29],30className = '',31duration = 2,32children33}: RainbowTextProps) => {34const linearGradients = [];35for (let i = 0; i < colors.length - 1; i++) {36linearGradients.push(`linear-gradient(90deg, ${colors[i]} 0%, ${colors[i + 1]} 100%)`);37}3839return (40<motion.p41initial={{ backgroundImage: linearGradients[0] }}42animate={{ backgroundImage: linearGradients }}43transition={{44duration: duration,45ease: 'linear',46repeat: Infinity47}}48className={className}49style={{50backgroundClip: 'text',51WebkitBackgroundClip: 'text',52color: 'transparent',53WebkitTextFillColor: 'transparent'54}}55>56{children}57</motion.p>58);59};6061export default RainbowText;
Usage
1<RainbowText className="text-6xl font-semibold drop-shadow-lg">Fresh Drop</RainbowText>
⭐️ Got a question or feedback?
Feel free to reach out!