ComponentsUna sola riga di CSS animata con background-clip: text. Loop infinito di un gradiente diagonale che attraversa il testo. Lightweight, niente JS.
TextAnimationCTAClient
Esempio01
shiny-text.tsx Start free →Premium signal sweep
tsxsrc/components/shiny-text.tsx
"use client";
import { cn } from "@/lib/utils";
export type ShinyTextProps = {
children: React.ReactNode;
/** Sweep duration in seconds. Default 3. */
speed?: number;
/** Base text color. Default uses --fg-muted. */
baseColor?: string;
/** Sweep color. Default uses --fg. */
shineColor?: string;
className?: string;
};
/**
* <ShinyText/> — a metallic shine sweeps across the text on a loop.
*
* Pure CSS — `background-clip: text` + animated `background-position`.
* Used everywhere on premium SaaS CTAs ("Start Now →"). Lightweight, no JS.
*/
export function ShinyText({
children,
speed = 3,
baseColor = "var(--fg-muted)",
shineColor = "var(--fg)",
className,
}: ShinyTextProps) {
const style: React.CSSProperties = {
backgroundImage: `linear-gradient(110deg, ${baseColor} 0%, ${baseColor} 40%, ${shineColor} 50%, ${baseColor} 60%, ${baseColor} 100%)`,
backgroundSize: "200% auto",
backgroundClip: "text",
WebkitBackgroundClip: "text",
color: "transparent",
WebkitTextFillColor: "transparent",
animation: `shiny-sweep ${speed}s linear infinite`,
};
return (
<>
<style>{`
@keyframes shiny-sweep {
from { background-position: 200% center; }
to { background-position: -200% center; }
}
`}</style>
<span className={cn("inline-block", className)} style={style}>
{children}
</span>
</>
);
}
Note — background-clip: text richiede color: transparent + WebkitTextFillColor: transparent. Speed bassa (2-3s) = aggressivo, alta (5-6s) = soft. prefers-reduced-motion blocca l'animazione.
Prompt LLM02
Incolla in Claude o ChatGPT per generare la tua variante. Include il contesto del brand, i token e i vincoli del progetto.
Sei un senior frontend engineer. Stai lavorando su un sito Next.js 16 + React 19 + Tailwind v4 in italiano, look chanhdai-inspired: colonna stretta 672px, Geist Sans + Geist Mono, hairline 1px, divisori a stripe diagonale, palette zinc.
Token CSS disponibili: --bg, --bg-alt, --fg, --fg-muted, --fg-soft, --border, --border-strong, --accent. Usa SEMPRE queste variabili tramite le utility tailwind generate (bg-bg, text-fg-muted, border-border, ecc.). Helper "cn" da "@/lib/utils". Niente librerie UI extra: solo lucide-react e tailwind-merge.
Genera un componente <ShinyText> con riflesso metallico in loop.
Props:
- children: ReactNode.
- speed?: number sec (default 3).
- baseColor?: string (default "var(--fg-muted)").
- shineColor?: string (default "var(--fg)").
- className?: string.
Implementazione:
- "use client".
- Inline <style> con keyframes shiny-sweep: background-position from 200% center → -200% center.
- Inline style sul <span>: backgroundImage linear-gradient(110deg, base, base 40%, shine 50%, base 60%, base), backgroundSize 200% auto, backgroundClip text + WebkitBackgroundClip text, color transparent + WebkitTextFillColor transparent, animation shiny-sweep speed linear infinite.
- Media (prefers-reduced-motion: reduce) blocca animation.
Output: file completo src/components/shiny-text.tsx.
Uso tipico03
<ShinyText speed={3} baseColor="var(--fg-muted)" shineColor="var(--fg)">Start free →</ShinyText>
Dipendenze04
Ti è servito? Dimmelo, oppure proponi il prossimo componente.