Leave a star on GitHub! ⭐


Docs
Wavy Text

Wavy Text

Text animation where the text moves in a wavy motion.

W

a

v

y

T

e

x

t

Installation

pnpm add clsx framer-motion

Copy and paste the following code into your project.

components/eldoraui/wavytext.tsx

"use client";
import clsx from "clsx";
import { motion, AnimatePresence } from "framer-motion";
 
interface WavyTextProps {
  text?: string;
  className?: string;
}
 
export const WavyText: React.FC<WavyTextProps> = ({
  text = "",
  className = "",
}) => {
  const variants1 = {
    hidden: { y: 10 },
    visible: { y: -10 },
  };
 
  return (
    <div className={clsx("flex space-x-2 justify-center", className)}>
      <AnimatePresence>
        {text.split("").map((char, i) => (
          <motion.h1
            key={i}
            initial="hidden"
            animate="visible"
            exit="hidden"
            variants={variants1}
            transition={{ yoyo: Infinity, duration: 0.5, delay: i * 0.2 }}
            className={clsx(
              "text-center font-display font-bold drop-shadow-sm",
              "text-4xl md:text-5xl lg:text-6xl xl:text-7xl",
              "tracking-[-0.02em]",
              "md:leading-[4rem] lg:leading-[4.5rem] xl:leading-[5rem]",
            )}
          >
            {char}
          </motion.h1>
        ))}
      </AnimatePresence>
    </div>
  );
};

Update the import paths to match your project setup.

Props

Prop NameTypeDefaultDescription
textstring""The text content to be displayed inside the motion.h1.
classNamestring""Additional CSS classes to apply to the component for custom styling.