Wave Text
Wave Text é um componente de texto para React e Tailwind CSS, da biblioteca SmoothUI, com licença MIT. Copia e cola no teu projeto.
SmoothUI
MIT
text
O que é
Wave Text é um componente de texto para React e Tailwind CSS, da biblioteca SmoothUI, com licença MIT. Copia e cola no teu projeto.
Como usar
Abre o componente no catálogo, carrega em copiar, e cola no teu projeto. O prompt copiado leva o código e as regras para o teu agente o reproduzir sem alterar nada.
Cinco cópias grátis por mês. Sem cartão.
Precisa de
npm i motion
Licença
Este componente vem de SmoothUI e é redistribuído sob a licença MIT, que permite uso comercial. O aviso de copyright viaja com o código.
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;