đ Fade In Text
FadeInText is a React component that animates text with a smooth fade-in effect, revealing each word individually as it comes into view. Built with Framer Motion, it enhances readability, engagement, and user experience by dynamically displaying content. Perfect for headings, quotes, landing pages, and interactive UI elements, this text animation component makes your website feel more polished and engaging. đâ¨
Preview
"The Shadows Are Mine"
- A Batman Monologue
Follow below steps đđť
Install dependencies
1npm i framer-motion
Component
Create a file fade-in-text.tsx in your components folder and paste this code
1'use client';23import { motion } from 'framer-motion';4import { useRef } from 'react';56type FadeInTextProps = {7text: string;8className?: string;9};1011const FadeInText: React.FC<FadeInTextProps> = ({ text, className }) => {12const ref = useRef(null);1314return (15<div ref={ref} className={`flex flex-wrap h-full w-full gap-2 ${className}`}>16{text.split(' ').map((word, index) => (17<motion.span18key={index}19initial={{ opacity: 0.2 }}20whileInView={{ opacity: 1 }}21viewport={{ once: true }}22transition={{ duration: 0.6, delay: 0.5 }}23className="inline-block"24>25{word}26</motion.span>27))}28</div>29);30};3132export default FadeInText;
Usage
1<FadeInText2text="Gotham is sick. A city on the edge, teetering between order and chaos. The people who run itâpoliticians, businessmen, crime lordsâthey want you to believe they have control. But I see the truth. I see the cracks in their foundation, the corruption that eats away at everything. This city is rotting, and no one wants to admit it. No one wants to face the monsters hiding in the dark. But I am not afraid of the dark. I became it. I let it consume me. Because someone has to. They call me a vigilante. A menace. A madman in a mask. Maybe theyâre right. Maybe all I am is a man clinging to a war he can never win. But I canât stop. I wonât stop. Because I know what happens when good men do nothing. When fear is allowed to rule. Iâve seen what Gotham becomes without someone willing to fight for it. I wonât let that happen again. I tried to be vengeance. I thought fear was enoughâthat if I could make criminals afraid, I could stop them. But fear is a tool, not a solution. Iâve learned that the hard way. Fear might make a man hesitate before pulling the trigger, but it wonât change his heart. Fear is temporary. Justice is something more. Iâve paid for this war in bloodâmy own and that of the people Iâve failed to save. Every night, I hear the echoes of the past, the voices of those I couldnât protect. My parents. The innocent lives lost in alleyways and abandoned streets. I tell myself their deaths werenât in vain. That their loss fuels my fight. But some nights, I wonder if Iâm lying to myself. If this is all just a way to justify the rage I feel inside. Because the truth is⌠the rage never fades. But rage isnât justice. Vengeance isnât enough. I have to be more. Not just a symbol of fearâbut a symbol of hope. Because Gotham doesnât need another monster lurking in the dark. It needs something stronger. Something incorruptible. A protector. A knight. I donât do this because I want to. I do it because I have to. Because if I donât, who will? I made a promise, long ago, in the cold of a dark alley. A promise that I would never let another child lose their parents the way I lost mine. That I would stand between Gotham and the abyss. I may not be the hero this city wants, but I am the one it needs. And as long as I draw breath, I will fight. Because I am vengeance. I am the night. I am Batman."3className="text-xl font-medium text-neutral-200"4/>
âď¸ Got a question or feedback?
Feel free to reach out!