<button class="glow-button">
<span>Button</span>
</button>
<!-- twitter -->
<a class="twitter" target="_top" href="https://twitter.com/aaroniker_me"><svg xmlns="http://www.w3.org/2000/svg" width="72" height="72" viewBox="0 0 72 72"><path d="M67.812 16.141a26.246 26.246 0 0 1-7.519 2.06 13.134 13.134 0 0 0 5.756-7.244 26.127 26.127 0 0 1-8.313 3.176A13.075 13.075 0 0 0 48.182 10c-7.229 0-13.092 5.861-13.092 13.093 0 1.026.118 2.021.338 2.981-10.885-.548-20.528-5.757-26.987-13.679a13.048 13.048 0 0 0-1.771 6.581c0 4.542 2.312 8.551 5.824 10.898a13.048 13.048 0 0 1-5.93-1.638c-.002.055-.002.11-.002.162 0 6.345 4.513 11.638 10.504 12.84a13.177 13.177 0 0 1-3.449.457c-.846 0-1.667-.078-2.465-.231 1.667 5.2 6.499 8.986 12.23 9.09a26.276 26.276 0 0 1-16.26 5.606A26.21 26.21 0 0 1 4 55.976a37.036 37.036 0 0 0 20.067 5.882c24.083 0 37.251-19.949 37.251-37.249 0-.566-.014-1.134-.039-1.694a26.597 26.597 0 0 0 6.533-6.774z"></path></svg></a>
.glow-button {
--button-background: #09041e;
--button-color: #fff;
--button-shadow: rgba(33, 4, 104, 0.2);
--button-shine-left: rgba(120, 0, 245, 0.5);
--button-shine-right: rgba(200, 148, 255, 0.65);
--button-glow-start: #B000E8;
--button-glow-end: #009FFD;
appearance: none;
outline: none;
border: none;
font-family: inherit;
font-size: 16px;
font-weight: 500;
border-radius: 11px;
position: relative;
line-height: 24px;
cursor: pointer;
color: var(--button-color);
padding: 0;
margin: 0;
background: none;
z-index: 1;
box-shadow: 0 8px 20px var(--button-shadow);
.gradient {
position: absolute;
inset: 0;
border-radius: inherit;
overflow: hidden;
-webkit-mask-image: -webkit-radial-gradient(white, black);
transform: scaleY(1.02) scaleX(1.005) rotate(-.35deg);
&:before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
transform: scale(1.05) translateY(-44px) rotate(0deg) translateZ(0);
padding-bottom: 100%;
border-radius: 50%;
background: linear-gradient(90deg, var(--button-shine-left), var(--button-shine-right));
animation: rotate linear 2s infinite;
}
}
span {
z-index: 1;
position: relative;
display: block;
padding: 10px 28px;
box-sizing: border-box;
width: fit-content;
min-width: 124px;
border-radius: inherit;
background-color: var(--button-background);
overflow: hidden;
-webkit-mask-image: -webkit-radial-gradient(white, black);
&:before {
content: '';
position: absolute;
left: -16px;
top: -16px;
transform: translate(var(--pointer-x, 0px), var(--pointer-y, 0px)) translateZ(0);
width: 32px;
height: 32px;
border-radius: 50%;
background-color: var(--button-glow, transparent);
opacity: var(--button-glow-opacity, 0);
transition: opacity var(--button-glow-duration, .5s);
filter: blur(20px);
}
}
&:hover {
--button-glow-opacity: 1;
--button-glow-duration: .25s;
}
}
@keyframes rotate {
to {
transform: scale(1.05) translateY(-44px) rotate(360deg) translateZ(0);
}
}
html {
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
}
* {
box-sizing: inherit;
&:before,
&:after {
box-sizing: inherit;
}
}
// Center
body {
min-height: 100vh;
display: flex;
font-family: 'Inter', Arial;
justify-content: center;
align-items: center;
background-color: #020112;
overflow: hidden;
&:before {
content: '';
position: absolute;
inset: 40% -60% 0 -60%;
background-image: radial-gradient(ellipse at bottom, #1D0559 0%, #020112 50%);
opacity: .4;
}
.twitter {
position: fixed;
display: block;
right: 12px;
bottom: 12px;
svg {
width: 32px;
height: 32px;
fill: #fff;
}
}
}
View Compiled
const generateGlowButtons = () => {
document.querySelectorAll(".glow-button").forEach((button) => {
let gradientElem = button.querySelector('.gradient');
if(!gradientElem) {
gradientElem = document.createElement("div");
gradientElem.classList.add("gradient");
button.appendChild(gradientElem);
}
button.addEventListener("pointermove", (e) => {
const rect = button.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
gsap.to(button, {
"--pointer-x": `${x}px`,
"--pointer-y": `${y}px`,
duration: 0.6,
});
gsap.to(button, {
"--button-glow": chroma
.mix(
getComputedStyle(button)
.getPropertyValue("--button-glow-start")
.trim(),
getComputedStyle(button).getPropertyValue("--button-glow-end").trim(),
x / rect.width
)
.hex(),
duration: 0.2,
});
});
});
}
// Set variables on loaded
document.addEventListener('DOMContentLoaded', generateGlowButtons);
// Set variables on resize
window.addEventListener('resize', generateGlowButtons);