Eldora UI
Eldora UI
  1. Components
  2. Text Animations
  3. Gradual spacing

Gradual spacing

Text animation that increases letter spacing gradually.

G

r

a

d

u

a

l

 

S

p

a

c

i

n

g

<Gradualspacingdemo />

Installation

Install the following dependencies:

npm install framer-motion

Copy and paste the following code into your project.

import clsx from "clsx";
import { AnimatePresence, motion } from "framer-motion";

export function GradualSpacing() {
  const text = "Gradual Spacing";
  const gradual = {
    hidden: { opacity: 0, x: -20 },
    visible: { opacity: 1, x: 0 },
  };
  return (
    <div className="flex space-x-1 justify-center">
      <AnimatePresence>
        {text.split("").map((char, i) => (
          <motion.h1
            key={i}
            initial="hidden"
            animate="visible"
            exit="hidden"
            variants={gradual}
            transition={{ duration: 0.5, delay: i * 0.1 }}
            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 === " " ? <span>&nbsp;</span> : char}
          </motion.h1>
        ))}
      </AnimatePresence>
    </div>
  );
}

Update the import paths to match your project setup.

Built by karthikmudunuri. The source code is available on GitHub.