Wave Text
Wave Text is a React and Tailwind CSS text component from SmoothUI, licensed MIT. Copy it and paste it into your project.
SmoothUI
MIT
text
What it is
Wave Text is a React and Tailwind CSS text component from SmoothUI, licensed MIT. Copy it and paste it into your project.
How to use it
Open it in the catalogue, press copy, and paste it into your project. The prompt you copy carries the code and the rules that tell your agent to reproduce it without changing anything.
Five free copies a month. No card.
Needs
npm i motion
Licence
This component comes from SmoothUI and is redistributed under the MIT licence, which permits commercial use. The copyright notice travels with the code.
Wave Text
import { motion, useReducedMotion } from "motion/react";
import type React from "react";
export interface WaveTextProps {
amplitude?: number;
children: string;
className?: string;
duration?: number;
staggerDelay?: number;
}
const WaveText: React.FC<WaveTextProps> = ({
children,
amplitude = 8,
duration = 1.2,
staggerDelay = 0.05,
className = "",
}) => {
const shouldReduceMotion = useReducedMotion();
return (
<span className={className} style={{ display: "inline-block" }}>
{children.split("").map((char, i) => (
<motion.span
animate={
shouldReduceMotion
? { y: 0 }
: { y: [0, -amplitude, 0, amplitude * 0.5, 0] }
}
key={`${i}-${char}`}
style={{
display: "inline-block",
willChange: shouldReduceMotion ? undefined : "transform",
}}
transition={
shouldReduceMotion
? { duration: 0 }
: {
delay: i * staggerDelay,
duration,
ease: [0.37, 0, 0.63, 1],
repeat: Number.POSITIVE_INFINITY,
times: [0, 0.25, 0.5, 0.75, 1],
}
}
>
{char === " " ? "\u00A0" : String(char)}
</motion.span>
))}
</span>
);
};
export default WaveText;