DevPlatform
Home
Components
Search
Submit
Earn
Login
Sign Up Free
Particle on click Button - Preview | DevPlatform
DevPlatform
Categories
Accordion
Animation
Box Shadow
Button
Card
Footer
Form
Gallery
Hero Section
Inputs
Loader
Marquee
Modal
Modules
Navbar
Progress Bar
Radio Buttons
Search-Bar
Sections
Slider
Tab
Timeline
Toggle
Particle on click Button
jitesh208
Jan 20, 2026
2
0
Share
Live Preview
Refresh
Live Editor
HTML
CSS
JS
HTML
CSS
JavaScript
1
<button class="particle-button">Explode!</button>
1
* { margin: 0; padding: 0; box-sizing: border-box; } body { min-height: 100vh; display: flex; justify-content: center; align-items: center; background: #0a0e27; font-family: 'Arial', sans-serif; overflow: hidden; } .particle-button { position: relative; padding: 25px 70px; font-size: 26px; font-weight: bold; color: #fff; background: linear-gradient(135deg, #667eea, #764ba2); border: 3px solid #fff; border-radius: 15px; cursor: pointer; transition: all 0.3s ease; text-transform: uppercase; letter-spacing: 2px; box-shadow: 0 0 30px rgba(102, 126, 234, 0.5), 0 0 60px rgba(118, 75, 162, 0.3); } .particle-button:hover { transform: translateY(-5px); box-shadow: 0 0 50px rgba(102, 126, 234, 0.8), 0 0 100px rgba(118, 75, 162, 0.5); } .particle-button:active { transform: scale(0.95); } .particle { position: fixed; width: 8px; height: 8px; border-radius: 50%; pointer-events: none; z-index: 1000; } @keyframes explode { 0% { transform: translate(0, 0) scale(1); opacity: 1; } 100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; } }
1
const btn = document.querySelector('.particle-button'); btn.addEventListener('click', function(e) { const rect = btn.getBoundingClientRect(); const centerX = rect.left + rect.width / 2; const centerY = rect.top + rect.height / 2; const colors = ['#ff0080', '#00f0ff', '#ffff00', '#00ff00', '#ff00ff', '#ff6b00']; for (let i = 0; i < 50; i++) { const particle = document.createElement('div'); particle.className = 'particle'; const angle = (Math.PI * 2 * i) / 50; const velocity = 100 + Math.random() * 200; const tx = Math.cos(angle) * velocity; const ty = Math.sin(angle) * velocity; particle.style.left = centerX + 'px'; particle.style.top = centerY + 'px'; particle.style.background = colors[Math.floor(Math.random() * colors.length)]; particle.style.setProperty('--tx', tx + 'px'); particle.style.setProperty('--ty', ty + 'px'); particle.style.animation = `explode ${0.5 + Math.random() * 0.5}s ease-out forwards`; document.body.appendChild(particle); setTimeout(() => particle.remove(), 1500); } btn.style.transform = 'scale(1.2)'; setTimeout(() => btn.style.transform = '', 100); });
Comments
0
Want to comment?
Please
login
or
sign up
to post comments.
No comments yet
Be the first to comment on this component!
Comments 0
Want to comment?
Please login or sign up to post comments.
No comments yet
Be the first to comment on this component!