NEW
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
Learn more
Skip to content
Docs

Staggered Letter

A staggered up/drop letter animation.

Loading...

Installation

CLI

pnpm dlx shadcn@latest add https://animata.design/r/text/staggered-letter.json

Manual

Install dependencies

npm install motion

Run the following command

It will create a new file staggered-letter.tsx inside the components/animata/text directory.

mkdir -p components/animata/text && touch components/animata/text/staggered-letter.tsx

Paste the code

Open the newly created file and paste the following code:

import { motion } from "motion/react";
import type { HTMLAttributes } from "react";
 
import { cn } from "@/lib/utils";
 
interface DropLetterProps extends HTMLAttributes<HTMLDivElement> {
  applyMask?: boolean;
 
  text?: string;
 
  delay?: number;
 
  direction?: "up" | "drop";
}
 
export default function StaggeredLetter({
  applyMask = true,
  text = "Animata",
  delay = 0.09,
  direction = "drop",
  className,
  ...props
}: DropLetterProps) {
  const common = "text-7xl font-bold drop-shadow-lg";
  return (
    <div
      className={cn(
        "relative flex flex-col items-center justify-center text-foreground",
        className,
      )}
      {...props}
    >
      {applyMask && <div className={cn(common, "absolute text-gray-400")}>{text}</div>}
      <div className="flex">
        {text.split("").map((letter, index) => (
          <motion.div
            className={common}
            initial={{ opacity: 0, y: direction === "up" ? 150 : -150 }}
            animate={{ opacity: 1, y: 0 }}
            transition={{
              delay: index * delay,
            }}
            key={letter}
          >
            {letter === " " ? <span>&nbsp;</span> : letter}
          </motion.div>
        ))}
      </div>
    </div>
  );
}

Credits

Built by Bibek Bhattarai