Scale Down Fade
Scale Down Fade é um componente para React e Tailwind CSS, da biblioteca SmoothUI, com licença MIT. Copia e cola no teu projeto.
SmoothUI
MIT
other
O que é
Scale Down Fade é um componente 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.
Scale Down Fade
"use client";
import { motion, useInView, useReducedMotion } from "motion/react";
import { useRef } from "react";
export interface ScaleDownFadeProps {
children: string;
className?: string;
/** Delay before the animation starts, in milliseconds. */
delay?: number;
/** Animate only once the text scrolls into view. */
triggerOnView?: boolean;
}
const DURATION_S = 0.52;
const MS = 1000;
const EASE = [0.22, 1, 0.36, 1] as const;
/**
* ScaleDownFade — subtle premium settle-in where the text enters slightly
* scaled up and drifts down to its natural size. The whole text animates as
* a single element. From the animate-text catalog (`scale-down-fade`).
* Safe default for product UIs where copy should feel polished but not animated.
*/
export default function ScaleDownFade({
children,
className = "",
delay = 0,
triggerOnView = false,
}: ScaleDownFadeProps) {
const ref = useRef<HTMLSpanElement>(null);
const inView = useInView(ref, { once: true });
const shouldReduceMotion = useReducedMotion();
const play = (!triggerOnView || inView) && !shouldReduceMotion;
return (
<motion.span
animate={play ? { opacity: 1, scale: 1, y: 0 } : undefined}
aria-label={children}
className={className}
initial={
shouldReduceMotion ? { opacity: 1 } : { opacity: 0, scale: 1.04, y: 8 }
}
ref={ref}
style={{ display: "inline-block" }}
transition={
shouldReduceMotion
? { duration: 0 }
: {
delay: delay / MS,
duration: DURATION_S,
ease: EASE,
}
}
>
{children}
</motion.span>
);
}