Character Animation
Animate each character individually with stagger effects
Character by character
CharAnimation.tsx
'use client';
import { useRef } from 'react';
import { useGSAP } from '@gsap/react';
import gsap from 'gsap';
import { SplitText } from 'gsap/SplitText';
gsap.registerPlugin(SplitText);
export function CharAnimation() {
const textRef = useRef<HTMLHeadingElement>(null);
useGSAP(() => {
if (!textRef.current) return;
const split = new SplitText(textRef.current, { type: 'chars' });
gsap.from(split.chars, {
opacity: 0,
y: 20,
rotateX: -90,
stagger: 0.02,
duration: 0.5,
ease: 'back.out',
});
return () => split.revert();
}, { scope: textRef });
return (
<h2 ref={textRef} className="text-4xl font-bold">
Character by character
</h2>
);
}