Animated Gradient Background
Animated Gradient Background is a React and Tailwind CSS background component from Cult UI, licensed MIT. Copy it and paste it into your project.
Cult UI
MIT
backgrounds
What it is
Animated Gradient Background is a React and Tailwind CSS background component from Cult UI, 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 Cult UI and is redistributed under the MIT licence, which permits commercial use. The copyright notice travels with the code.
Animated Gradient Background
"use client"
import React, { useEffect } from "react"
import { motion, useAnimation } from "motion/react"
interface GradientStop {
color: string
position: number
}
interface GradientType {
stops: GradientStop[]
centerX: number
centerY: number
}
interface GradientAnimationProps {
gradients: GradientType[]
animationDuration: number
className?: string
}
export const GradientAnimation: React.FC<GradientAnimationProps> = ({
gradients,
animationDuration,
className = "",
}) => {
const controls = useAnimation()
useEffect(() => {
controls.start({
background: gradients.map(
(g) =>
`radial-gradient(circle at ${g.centerX}% ${g.centerY}%, ${g.stops
.map((s) => `${s.color} ${s.position}%`)
.join(", ")})`
),
transition: {
duration: animationDuration,
repeat: Infinity,
repeatType: "reverse",
ease: "linear",
},
})
}, [controls, gradients, animationDuration])
return (
<motion.div
className={`absolute inset-0 h-full w-full ${className}`}
animate={controls}
/>
)
}
export default React.memo(GradientAnimation)