Skip to content

Animated Gradient Border

Button with rotating gradient border animation

Animated Gradient Border

by FreeCsStyles Dev's

Border EffectsModern
🌐🎨⚛️💚🅰️🔥☁️
#gradient#border#animated#rotating#premium#modern

Embed this component

Paste this snippet into any site — the design renders in a sandboxed iframe served from /embed/gradient-border-button.

<iframe src="/embed/gradient-border-button" sandbox="allow-scripts" loading="lazy" title="Animated Gradient Border" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>

Implementation code

Copy the HTML and CSS for Animated Gradient Border, or grab a framework-specific implementation. The HTML and CSS variants are self-contained; framework variants assume that framework's project setup.

HTML
<button class="gradient-border-button">
  <span>Gradient Border</span>
</button>
CSS
.gradient-border-button {
  position: relative;
  padding: 1rem 2rem;
  border-radius: 0.75rem;
  background: transparent;
  border: none;
  color: white;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
}

.gradient-border-button::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 2px;
  border-radius: 0.75rem;
  background: linear-gradient(90deg, #a855f7, #ec4899, #06b6d4, #a855f7);
  background-size: 200% 200%;
  animation: gradient-rotate 3s linear infinite;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

@keyframes gradient-rotate {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
LWC — HTML template
<template>
  <button class="gradient-border-button" onclick={handleClick}>
    <span><slot>Gradient Border</slot></span>
  </button>
</template>
LWC — JavaScript
import { LightningElement, api } from 'lwc';

export default class GradientBorderButton extends LightningElement {
  @api label = 'Gradient Border';
  
  handleClick() {
    this.dispatchEvent(new CustomEvent('buttonclick', {
      bubbles: true,
      composed: true
    }));
  }
}
LWC — CSS
.gradient-border-button {
  position: relative;
  padding: 1rem 2rem;
  border-radius: 0.75rem;
  background: transparent;
  border: none;
  color: white;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
}

.gradient-border-button::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 2px;
  border-radius: 0.75rem;
  background: linear-gradient(90deg, #a855f7, #ec4899, #06b6d4, #a855f7);
  background-size: 200% 200%;
  animation: gradient-rotate 3s linear infinite;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

@keyframes gradient-rotate {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
LWC — Configuration
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
  <apiVersion>59.0</apiVersion>
  <isExposed>true</isExposed>
  <targets>
    <target>lightning__AppPage</target>
    <target>lightning__RecordPage</target>
    <target>lightning__HomePage</target>
  </targets>
</LightningComponentBundle>

Where Animated Gradient Border fits

  • Premium UI
  • CTA
  • Featured Actions
  • Modern Apps

Interaction states & animations

  • Border
  • Gradient
  • Rotate

Topics

  • #gradient
  • #border
  • #animated
  • #rotating
  • #premium
  • #modern

Accessibility notes

Ensure border doesn't interfere with focus indicators. Provide high contrast alternative.

Browser support

  • All modern browsers