React + MotionButtons
Animated gradient border
Two streaks of color chase each other around the edge of the button in an endless loop.
Settings
24px
3
Code
interface GradientBorderButtonProps {
color?: string;
radius?: number;
text?: string;
/** Segundos por vuelta del borde. */
intensity?: number;
}
export default function GradientBorderButton({
color = "#0071e3",
radius = 24,
text = "Glow button",
intensity = 3,
}: GradientBorderButtonProps) {
return (
<div
className="relative overflow-hidden p-[2px]"
style={{ borderRadius: radius + 2 }}
>
<div
className="absolute inset-[-100%] animate-spin"
style={{
background: `conic-gradient(from 0deg, transparent 0%, ${color} 20%, transparent 40%, transparent 60%, ${color} 80%, transparent 100%)`,
animationDuration: `${intensity}s`,
}}
/>
<button
type="button"
className="relative z-10 bg-[#f5f5f7] px-6 py-3 text-sm font-semibold text-[#1d1d1f] dark:bg-black dark:text-[#f5f5f7]"
style={{ borderRadius: radius }}
>
{text}
</button>
</div>
);
}
Prompt for AI
Paste it into ChatGPT, Claude or Cursor and it will adapt the block to your project with these settings, even if you don’t use React.
More in Buttons
Where to use it
A rotating border catches attention without filling the whole button with color, so it shines on dark sites: the “Join the waitlist” button of a product launch, a highlighted link in a navbar or the upgrade button inside an app. The animated gradient border is an old favorite, and it has aged well.
Watch out with the intensity slider: it sets how many seconds a full lap takes, so a higher number means a slower spin. Around three seconds feels calm. Use one per screen at most, or they start competing with each other.