Electroplix

Animated Bouncing Text

Each letter bounces on hovering.

Image

General Use

  • Interactive Headers
  • Welcome Messages
  • Brand Identity
  • Personal Blogs or Portfolios
  • Event Promotion
  • Highlighting Key Information

Dependencies Installation

npm i framer-motion

Code

copy the source code in components/ui/AnimatedText.tsx

// AnimatedText.tsx
"use client";
import React from 'react';
import { motion, Variants } from 'framer-motion';

// Define the variants for letter animations
const letterVariants: Variants = {
  initial: { y: 0 },
  hover: { 
    y: [0, -10, 0], // Move up and down
    transition: { 
      duration: 0.5, 
      repeat: Infinity, 
      repeatType: 'reverse' 
    }
  }
};

// Split text into individual characters for animation
const AnimatedText: React.FC<{ text: string }> = ({ text }) => {
  return (
    <span>
      {text.split('').map((char, index) => (
        <motion.span
          key={index}
          variants={letterVariants}
          initial="initial"
          whileHover="hover"
          className="inline-block"
        >
          {char}
        </motion.span>
      ))}
    </span>
  );
};

export { AnimatedText, letterVariants };

You can call the above Function in your files as

import {AnimatedText,letterVariants } from './ui/AnimatedText';  // Import the AnimatedText component

const TextDemo = () => {
  return (
    <div>
      <h1 className="text-3xl font-bold mb-4">
        <AnimatedText text="Electroplix" />
      </h1>
    </div>
  )
}

export default TextDemo;

Props Input Table

The AnimatedText component accepts the following props:

PropTypeDefault
textstring""

Prop Descriptions

  • Prop: The name of the property.
  • Type: The type of the property (e.g., string).
  • Default: The default value of the property if none is provided.

This table helps users understand what props are available for customization and their default values.


By referring to this table, you can easily see what properties are configurable for the AnimatedText component and their default settings. Adjust the text prop to customize the animated text display in your application.

On this page