Files
webb/src/components/animate-ui/TextReveal.tsx
T

45 lines
1.0 KiB
TypeScript
Raw Normal View History

'use client';
import React from 'react';
import { motion } from 'framer-motion';
interface TextRevealProps {
text: string;
className?: string;
delay?: number;
}
/**
* Animate UI - Text Reveal
* Smooth word-by-word blur-in entrance animation triggered on scroll.
* Reference: https://animate-ui.com/docs
*/
export function TextReveal({
text,
className = '',
delay = 0,
}: TextRevealProps) {
const words = text.split(' ');
return (
<span className={`inline-block ${className}`}>
{words.map((word, i) => (
<motion.span
key={i}
initial={{ opacity: 0, y: 12, filter: 'blur(4px)' }}
whileInView={{ opacity: 1, y: 0, filter: 'blur(0px)' }}
viewport={{ once: true, margin: '-40px' }}
transition={{
duration: 0.35,
delay: delay + i * 0.035,
ease: [0.2, 0.65, 0.3, 0.9],
}}
className="inline-block mr-[0.25em] last:mr-0"
>
{word}
</motion.span>
))}
</span>
);
}