.
Ultimate Stylish GSAP Button by Coodeverse is a free futuristic interactive button UI component built with GSAP 3.12.5, HTML, and CSS. It features GSAP-powered 3D tilt and magnetic pull on mousemove using rotationX, rotationY, x, and y transforms, a radial-gradient glow div that follows the cursor, a shine sweep via gsap.fromTo on mouseenter, a CSS ripple on click, 15 GSAP-animated particle divs per click with random x/y/rotation, a rotating conic-gradient aura ring, and Web Audio click sound. Full source code free at coodeverse.com/projects/ultimate-stylish-gsap-button.
⚡Library:GSAP 3.12.5 + MotionPathPlugin
·
🎆Particles:15 per click
·
🎲3D:rotationX + rotationY live
·
🖱️Events:mousemove / enter / leave / click
·
🔊Audio:Web Audio API
Live Preview — Move & Click!

⚡ All 7 GSAP Effects — Deep Dive

Every GSAP call, CSS property, and math formula behind the Ultimate Stylish GSAP Button.

① GSAP mousemove
3D Tilt
Cursor offset from button center divided by 6 gives tilt angle. GSAP applies rotationX and rotationY simultaneously with power3.out for smooth real-time tracking. transform-style: preserve-3d on the button enables the perspective effect.
const tiltX = (mouseY - cy) / 6;
const tiltY = (cx - mouseX) / 6;
gsap.to(btn, {rotationX:-tiltX, rotationY:tiltY,
duration:0.7, ease:'power3.out'})
② GSAP mousemove
Magnetic Pull
The button physically moves toward the cursor by multiplying the offset from center by 0.17 to give a subtle magnetic feel. Reset to x:0, y:0 on mouseleave. Combined with 3D tilt on the same gsap.to call for maximum efficiency.
const pullX = (mouseX - cx) * 0.17;
const pullY = (mouseY - cy) * 0.17;
gsap.to(btn, {x:pullX, y:pullY,
duration:0.7, ease:'power3.out'})
③ GSAP mousemove
Cursor Glow Follow
The .glow div (350px radial-gradient circle) tracks the cursor by direct style.left/top property assignment in the mousemove handler for zero-latency position update. GSAP handles only the opacity fade-in (0.25s) and fade-out (0.4s) on enter/leave.
glow.style.left = mouseX + 'px';
glow.style.top = mouseY + 'px';
gsap.to(glow, {opacity:1, duration:0.25})
// mouseleave: opacity→0
④ GSAP mouseenter
Shine Sweep
gsap.fromTo gives explicit start and end positions. The .shine div begins at x:-350 (off left edge) and animates to x:400 (off right edge) in 1.5s with power2.inOut easing for natural acceleration. scale: 1.18 and enhanced box-shadow also fire on mouseenter via a separate gsap.to.
gsap.fromTo(shine,
{x: -350},
{x: 400, duration:1.5, ease:'power2.inOut'})
⑤ CSS + JS
Ripple Effect
On click, a div is created sized 2× the larger of button width/height, centered at mouseX/mouseY. CSS @keyframes ripple animates it from scale(0) to scale(3.5) with opacity fading to 0 in 0.6s. JavaScript removes it with setTimeout after 600ms to keep the DOM clean.
ripple.style.width = size + 'px';
ripple.style.left = mouseX - size/2 + 'px';
// CSS: animation: ripple .6s ease-out
setTimeout(() => ripple.remove(), 600)
⑥ GSAP click
Particle Burst (×15)
15 .particle divs created per click, each assigned a random color from an array. gsap.utils.random(-130,130) for x, (-180,-100) for y (upward only), and (-720,720) for rotation. opacity animates to 0 over 1.5s with power2.out. onComplete callback removes each particle from the DOM.
gsap.to(p, {
x: gsap.utils.random(-130, 130),
y: gsap.utils.random(-180, -100),
rotation: gsap.utils.random(-720, 720),
opacity: 0, duration: 1.5,
onComplete: () => p.remove() })
⑦ CSS + Audio
Aura Ring + Click Sound
The .aura-ring uses a conic-gradient cycling through purple, pink, and blue at low opacity, with filter: blur(50px) to spread colors into a soft ambient glow. @keyframes spin rotates 360deg over 7s linear infinite. Audio plays via HTMLAudioElement.play() with .catch() to handle autoplay policy silently.
animation: spin 7s linear infinite;
/* spin: 0%→100% { transform: rotate(360deg) } */
sound.currentTime = 0;
sound.play().catch(() => {})
⚡ Full Source Code
// index.html — Ultimate Stylish GSAP Button
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Ultimate Stylish GSAP Button</title>

  <!-- GSAP 3.12.5 + MotionPathPlugin (for gsap.utils) -->
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/MotionPathPlugin.min.js"></script>

  <link rel="stylesheet" href="style.css" />
</head>
<body>

  <!-- Rotating aurora background ring -->
  <div class="aura-ring"></div>

  <!-- Main button -->
  <button class="ultimate-btn" id="ultimateBtn">
    <span>Awaken</span>
    <div class="shine"></div>         <!-- Shine sweep element -->
    <div class="glow" id="glow"></div> <!-- Cursor-follow glow -->
  </button>

  <!-- Click sound (replace src with your own audio) -->
  <audio id="clickSound" src="https://assets.codepen.io/605876/click-blip.mp3"></audio>

  <script src="script.js"></script>
</body>
</html>
// gsap_button_faq

GSAP Button — FAQ

How the 3D tilt, magnetic pull, glow follow, particle burst, and GSAP ease functions work.

On mousemove, getBoundingClientRect() gives the button's position. Subtracting the button center from cursor position gives the offset. Dividing by 6 controls tilt intensity: tiltX = (mouseY - cy) / 6, tiltY = (cx - mouseX) / 6. Multiplying offset by 0.17 gives the magnetic pull distance. gsap.to applies rotationX, rotationY, x, y simultaneously at duration 0.7s with power3.out. transform-style: preserve-3d on the button CSS enables the 3D perspective effect.

The .glow div is a 350×350px radial-gradient circle inside the button at opacity 0 and pointer-events: none. In the mousemove handler, glow.style.left = mouseX + 'px' and glow.style.top = mouseY + 'px' update position instantly without any animation (direct style change = no latency). GSAP handles only the opacity fade-in (0.25s on enter) and fade-out (0.4s on leave), so the light appears to illuminate exactly where the cursor is while smoothly appearing and disappearing at the button boundary.

The .shine div is a diagonal white gradient positioned off-screen to the left. gsap.fromTo(shine, {x: -350}, {x: 400, duration: 1.5, ease: 'power2.inOut'}) gives explicit start and end positions — more reliable than gsap.to alone since it guarantees the element starts at -350 regardless of interruption. power2.inOut provides natural acceleration and deceleration. The button's overflow: hidden clips the shine to the button area, so only the crossing portion is visible as the sweeping highlight.

On click, a loop runs 15 times. Each iteration creates a .particle div, assigns a random color from the array, positions it at mouseX/mouseY. gsap.to animates x to gsap.utils.random(-130, 130) for horizontal spread, y to gsap.utils.random(-180, -100) forcing upward movement, and rotation to gsap.utils.random(-720, 720) for multi-spin. opacity fades to 0 over 1.5s with power2.out. The onComplete callback removes each particle from the DOM to prevent memory buildup after repeated clicks.

The .aura-ring is a 280×280px absolutely-positioned div with border-radius: 50% and a conic-gradient cycling through purple, pink, and electric blue at low opacity (0.3–0.35 rgba). filter: blur(50px) spreads the colors into a soft diffused glow cloud. @keyframes spin rotates it 0→360deg over 7 seconds with linear timing and infinite repetition. z-index: -2 places it behind the button. The result is an ambient aurora that signals the button's interactivity without being distracting.

CSS animations excel for repeating loops (the aura spin) and simple hover transitions. GSAP is better for real-time interactions because: (1) back.out(1.6) provides a physical spring overshoot on scale that CSS lacks, (2) power3.out gives precise control over deceleration curves, (3) GSAP handles mid-animation interruption cleanly — mouseleave mid-hover properly reverses without a jump, (4) gsap.utils.random provides a clean API for dynamic values, and (5) chaining multiple properties (x, y, rotationX, rotationY, scale, boxShadow) in one call is much cleaner than CSS transitions.

Master GSAP & JavaScript.
Build Futuristic UIs.

Free courses in JavaScript, HTML, CSS, Python, SQL, DSA, Kotlin, C, C++, C#. Zero account needed.

Star Rating JS • RGB Color Game • FB Login Clone • Dominoes Game • style="color:inherit;">PEAK Fitness • AETHER Page • Epic Delete •
LEARN JAVASCRIPT FREE → Browse All Projects