# Animated gradient border

> Two streaks of color chase each other around the edge of the button in an endless loop.

- Category: [Buttons](https://library.aimran.es/components/buttons)
- Built with: React + Motion
- Live editor: https://library.aimran.es/blocks/gradient-border-button
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## 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.

## Code

### React (Motion)

```tsx
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 assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Animated gradient border” block (Buttons) from AIMRAN Library to my project.

## What it is
Two streaks of color chase each other around the edge of the button in an endless loop.

## Chosen settings
- Color: #0071e3
- Corner radius: 24px (from 0 to 24px)
- Text: "Glow button"
- Intensity: 3 (from 0.2 to 2)

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with React + TypeScript, with framer-motion for the animation and lucide-react for the icons. If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
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>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
