HomeComponentFade Up Text

Fade Up Text

Published Nov 20, 2024
By Vishal Karangale
Aura

Base Component

Copy and paste the following base component in your project
Make sure to install all the required dependencies

basic.tsx
import { AnimatePresence, motion } from "framer-motion";
import React from "react";
import { twMerge } from "tailwind-merge";
 
interface Props {
  text: string;
  className?: string;
}
 
const FadeUpText: React.FC<Props> = ({ text, className }) => {
  return (
    <AnimatePresence mode="popLayout" initial={false}>
      <motion.span
        key={text} 
        initial={{
          y: 40,
          opacity: 0,
          rotateX: -90,
          transformOrigin: "50% 100%",
        }}
        animate={{
          y: 0,
          opacity: 1,
          rotateX: 0,
          transformOrigin: "50% 100%",
        }}
        exit={{
          y: -40,
          opacity: [1, 0.5, 0],
          rotateX: 90,
          transformOrigin: "50% 0%",
          transition: {
            duration: 0.4,
            ease: [0.65, 0, 0.35, 1],
          },
        }}
        transition={{
          duration: 0.4,
          ease: [0.65, 0, 0.35, 1],
        }}
        className={twMerge("text-white text-base font-bold", className)}
        style={{
          backfaceVisibility: "hidden",
        }}
      >
        {text}
      </motion.span>
    </AnimatePresence>
  );
};
 
export default FadeUpText;

Component Props


Required Props

PropTypeDefault
className
string
-

Optional Props

PropTypeDefault
className
string
-

Component Examples

Built with Next.js