Magic Wand
Click to swing a magic wand with sparkle burst, then transform with a flowing animated gradient glow
Embed this component
Paste this snippet into any site — the design renders in a sandboxed iframe served from /embed/magic-wand-button.
<iframe src="/embed/magic-wand-button" sandbox="allow-scripts" loading="lazy" title="Magic Wand" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>Implementation code
Copy the HTML and CSS for Magic Wand, 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="btn-wand" id="wandBtn" onclick="triggerWand()">
<span class="wand-icon">🪄</span>
<span class="text">Generate</span>
</button>
<script>
function triggerWand() {
const btn=document.getElementById('wandBtn');
if(btn.classList.contains('is-casting')) return;
btn.classList.add('is-casting');
for(let i=0;i<8;i++){const s=document.createElement('div');s.innerText='✨';s.classList.add('sparkle');s.style.setProperty('--tx',(Math.random()-0.5)*120+'px');s.style.setProperty('--ty',(Math.random()-0.5)*100-30+'px');btn.appendChild(s);}
setTimeout(()=>{btn.classList.remove('is-casting');btn.classList.add('is-magical');btn.querySelector('.text').innerText='Magical!';btn.querySelectorAll('.sparkle').forEach(s=>s.remove());},1000);
setTimeout(()=>{btn.classList.remove('is-magical');btn.querySelector('.text').innerText='Generate';},4500);
}
</script>CSS
.btn-wand{width:160px;height:50px;border-radius:12px;border:none;background:#4f46e5;color:#fff;font-size:16px;font-weight:700;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:8px;overflow:visible;transition:all .4s cubic-bezier(.4,0,.2,1);box-shadow:0 4px 15px rgba(79,70,229,.4);font-family:system-ui,sans-serif}.btn-wand .wand-icon{font-size:20px;transition:transform .3s;transform-origin:bottom left}.btn-wand.is-casting .wand-icon{animation:wand-swing .6s ease-in-out}.btn-wand.is-magical{background:linear-gradient(270deg,#ec4899,#8b5cf6,#3b82f6);background-size:200% 200%;animation:magic-glow 2s ease infinite;box-shadow:0 0 25px rgba(236,72,153,.6)}.sparkle{position:absolute;font-size:14px;pointer-events:none;opacity:0}.is-casting .sparkle{animation:sparkle-burst 1s forwards ease-out}@keyframes wand-swing{0%{transform:rotate(0deg) scale(1)}40%{transform:rotate(-30deg) scale(1.2)}60%{transform:rotate(45deg) scale(1.2)}100%{transform:rotate(0deg) scale(1)}}@keyframes magic-glow{0%{background-position:0% 50%}50%{background-position:100% 50%}100%{background-position:0% 50%}}@keyframes sparkle-burst{0%{transform:translate(0,0) scale(0) rotate(0deg);opacity:1}100%{transform:translate(var(--tx),var(--ty)) scale(1.5) rotate(180deg);opacity:0}}Tailwind CSS
<button class="w-[160px] h-[50px] rounded-xl border-none bg-indigo-600 text-white text-base font-bold cursor-pointer flex items-center justify-center gap-2 overflow-visible transition-all duration-400 shadow-[0_4px_15px_rgba(79,70,229,0.4)] [&.is-casting_.wand-icon]:animate-[wand-swing_0.6s_ease-in-out] [&.is-magical]:bg-gradient-to-r [&.is-magical]:from-pink-500 [&.is-magical]:via-violet-500 [&.is-magical]:to-blue-500 [&.is-magical]:bg-[length:200%_200%] [&.is-magical]:animate-[magic-glow_2s_ease_infinite] [&.is-magical]:shadow-[0_0_25px_rgba(236,72,153,0.6)]" id="tw-wand">
<span class="wand-icon text-xl">🪄</span>
<span class="text">Generate</span>
</button>React
import React from 'react';
import { motion } from 'framer-motion';
function MagicWandButton() {
const [state, setState] = React.useState('idle');
const handleClick = () => {
if (state !== 'idle') return;
setState('casting');
setTimeout(() => setState('magical'), 1000);
setTimeout(() => setState('idle'), 4500);
};
const casting = state === 'casting';
const magical = state === 'magical';
const sparkles = casting ? [...Array(8)].map(() => ({ tx: (Math.random()-0.5)*120, ty: (Math.random()-0.5)*100-30 })) : [];
return (
<motion.button onClick={handleClick}
style={{ width: 160, height: 50, borderRadius: 12, border: 'none', cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8, position: 'relative', fontSize: 16, fontWeight: 700, color: '#fff', background: magical ? 'linear-gradient(270deg,#ec4899,#8b5cf6,#3b82f6)' : '#4f46e5', backgroundSize: magical ? '200% 200%' : undefined, boxShadow: magical ? '0 0 25px rgba(236,72,153,0.6)' : '0 4px 15px rgba(79,70,229,0.4)', transition: 'all 0.4s cubic-bezier(0.4,0,0.2,1)', overflow: 'visible', fontFamily: 'system-ui, sans-serif' }}
animate={magical ? { backgroundPosition: ['0% 50%', '100% 50%', '0% 50%'], transition: { duration: 2, repeat: Infinity } } : {}}
whileTap={state === 'idle' ? { scale: 0.95 } : {}} disabled={state !== 'idle'}>
<motion.span style={{ fontSize: 20, transformOrigin: 'bottom left', display: 'inline-block' }}
animate={casting ? { rotate: [0,-30,45,0], scale: [1,1.2,1.2,1], transition: { duration: 0.6 } } : {}}>🪄</motion.span>
<span>{magical ? 'Magical!' : ''}</span>
{sparkles.map((s, i) => (
<motion.span key={i} style={{ position: 'absolute', fontSize: 14, left: 20, pointerEvents: 'none', opacity: 0 }}
initial={{ x: 0, y: 0, scale: 0 }} animate={{ x: s.tx, y: s.ty, scale: 1.5, opacity: 0, rotate: 180 }}
transition={{ duration: 1, ease: 'easeOut', delay: i*0.05 }}>✨</motion.span>
))}
</motion.button>
);
}Vue
<template>
<button class="btn-wand" :class="{'is-casting':state==='casting','is-magical':state==='magical'}" @click="handleClick" :disabled="state!=='idle'">
<span class="wand-icon">🪄</span>
<span class="text">{{ state==='magical' ? 'Magical!' : '' }}</span>
</button>
</template>
<script setup>
import { ref } from 'vue';
const state = ref('idle');
function handleClick() {
if (state.value !== 'idle') return;
state.value = 'casting';
setTimeout(() => state.value = 'magical', 1000);
setTimeout(() => state.value = 'idle', 4500);
}
</script>
<style scoped>
.btn-wand{width:160px;height:50px;border-radius:12px;border:none;background:#4f46e5;color:#fff;font-size:16px;font-weight:700;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:8px;overflow:visible;transition:all .4s cubic-bezier(.4,0,.2,1);box-shadow:0 4px 15px rgba(79,70,229,.4)}.btn-wand .wand-icon{font-size:20px;transition:transform .3s;transform-origin:bottom left}.btn-wand.is-casting .wand-icon{animation:wand-swing .6s ease-in-out}.btn-wand.is-magical{background:linear-gradient(270deg,#ec4899,#8b5cf6,#3b82f6);background-size:200% 200%;animation:magic-glow 2s ease infinite;box-shadow:0 0 25px rgba(236,72,153,.6)}.sparkle{position:absolute;font-size:14px;pointer-events:none;opacity:0}.is-casting .sparkle{animation:sparkle-burst 1s forwards ease-out}@keyframes wand-swing{0%{transform:rotate(0deg) scale(1)}40%{transform:rotate(-30deg) scale(1.2)}60%{transform:rotate(45deg) scale(1.2)}100%{transform:rotate(0deg) scale(1)}}@keyframes magic-glow{0%{background-position:0% 50%}50%{background-position:100% 50%}100%{background-position:0% 50%}}@keyframes sparkle-burst{0%{transform:translate(0,0) scale(0) rotate(0deg);opacity:1}100%{transform:translate(var(--tx),var(--ty)) scale(1.5) rotate(180deg);opacity:0}}
</style>Svelte
<script>
let state = 'idle';
function handleClick() {
if (state !== 'idle') return;
state = 'casting';
setTimeout(() => state = 'magical', 1000);
setTimeout(() => state = 'idle', 4500);
}
</script>
<button class="btn-wand" class:is-casting={state==='casting'} class:is-magical={state==='magical'} on:click={handleClick} disabled={state!=='idle'}>
<span class="wand-icon">🪄</span>
<span class="text">{state==='magical' ? 'Magical!' : ''}</span>
</button>
<style>
.btn-wand{width:160px;height:50px;border-radius:12px;border:none;background:#4f46e5;color:#fff;font-size:16px;font-weight:700;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:8px;overflow:visible;transition:all .4s cubic-bezier(.4,0,.2,1);box-shadow:0 4px 15px rgba(79,70,229,.4)}.btn-wand .wand-icon{font-size:20px;transition:transform .3s;transform-origin:bottom left}.btn-wand.is-casting .wand-icon{animation:wand-swing .6s ease-in-out}.btn-wand.is-magical{background:linear-gradient(270deg,#ec4899,#8b5cf6,#3b82f6);background-size:200% 200%;animation:magic-glow 2s ease infinite;box-shadow:0 0 25px rgba(236,72,153,.6)}.sparkle{position:absolute;font-size:14px;pointer-events:none;opacity:0}.is-casting .sparkle{animation:sparkle-burst 1s forwards ease-out}@keyframes wand-swing{0%{transform:rotate(0deg) scale(1)}40%{transform:rotate(-30deg) scale(1.2)}60%{transform:rotate(45deg) scale(1.2)}100%{transform:rotate(0deg) scale(1)}}@keyframes magic-glow{0%{background-position:0% 50%}50%{background-position:100% 50%}100%{background-position:0% 50%}}@keyframes sparkle-burst{0%{transform:translate(0,0) scale(0) rotate(0deg);opacity:1}100%{transform:translate(var(--tx),var(--ty)) scale(1.5) rotate(180deg);opacity:0}}
</style>Angular
import { Component } from '@angular/core';
@Component({
selector: 'app-magic-wand-button',
template: `<button class="btn-wand" [class.is-casting]="state==='casting'" [class.is-magical]="state==='magical'" (click)="handleClick()" [disabled]="state!=='idle'">
<span class="wand-icon">🪄</span>
<span class="text">{{ state==='magical' ? 'Magical!' : '' }}</span>
</button>`,
styles: [`.btn-wand{width:160px;height:50px;border-radius:12px;border:none;background:#4f46e5;color:#fff;font-size:16px;font-weight:700;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:8px;overflow:visible;transition:all .4s cubic-bezier(.4,0,.2,1);box-shadow:0 4px 15px rgba(79,70,229,.4)}.btn-wand .wand-icon{font-size:20px;transition:transform .3s;transform-origin:bottom left}.btn-wand.is-casting .wand-icon{animation:wand-swing .6s ease-in-out}.btn-wand.is-magical{background:linear-gradient(270deg,#ec4899,#8b5cf6,#3b82f6);background-size:200% 200%;animation:magic-glow 2s ease infinite;box-shadow:0 0 25px rgba(236,72,153,.6)}.sparkle{position:absolute;font-size:14px;pointer-events:none;opacity:0}.is-casting .sparkle{animation:sparkle-burst 1s forwards ease-out}@keyframes wand-swing{0%{transform:rotate(0deg) scale(1)}40%{transform:rotate(-30deg) scale(1.2)}60%{transform:rotate(45deg) scale(1.2)}100%{transform:rotate(0deg) scale(1)}}@keyframes magic-glow{0%{background-position:0% 50%}50%{background-position:100% 50%}100%{background-position:0% 50%}}@keyframes sparkle-burst{0%{transform:translate(0,0) scale(0) rotate(0deg);opacity:1}100%{transform:translate(var(--tx),var(--ty)) scale(1.5) rotate(180deg);opacity:0}}`]
})
export class MagicWandButtonComponent { state='idle';handleClick(){if(this.state!=='idle')return;this.state='casting';setTimeout(()=>this.state='magical',1000);setTimeout(()=>this.state='idle',4500);}}LWC — HTML template
<template><button class="btn-wand" onclick={handleClick} disabled={disabled}>
<span class="wand-icon">🪄</span>
<span class="text">{label}</span>
</button></template>LWC — JavaScript
import { LightningElement } from 'lwc';
export default class MagicWandButton extends LightningElement {
state = 'idle';
get disabled() { return this.state !== 'idle'; }
get label() { return this.state === 'magical' ? 'Magical!' : ''; }
handleClick() {
if (this.state !== 'idle') return;
this.state = 'casting';
const btn = this.template.querySelector('button');
btn.classList.add('is-casting');
for(let i=0;i<8;i++){const s=document.createElement('span');s.innerText='✨';s.classList.add('sparkle');s.style.setProperty('--tx',(Math.random()-0.5)*120+'px');s.style.setProperty('--ty',(Math.random()-0.5)*100-30+'px');btn.appendChild(s);}
setTimeout(()=>{btn.classList.remove('is-casting');btn.classList.add('is-magical');this.state='magical';btn.querySelectorAll('.sparkle').forEach(s=>s.remove());},1000);
setTimeout(()=>{btn.classList.remove('is-magical');this.state='idle';},4500);
}
}LWC — CSS
.btn-wand{width:160px;height:50px;border-radius:12px;border:none;background:#4f46e5;color:#fff;font-size:16px;font-weight:700;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:8px;overflow:visible;transition:all .4s cubic-bezier(.4,0,.2,1);box-shadow:0 4px 15px rgba(79,70,229,.4)}.btn-wand .wand-icon{font-size:20px;transition:transform .3s;transform-origin:bottom left}.btn-wand.is-casting .wand-icon{animation:wand-swing .6s ease-in-out}.btn-wand.is-magical{background:linear-gradient(270deg,#ec4899,#8b5cf6,#3b82f6);background-size:200% 200%;animation:magic-glow 2s ease infinite;box-shadow:0 0 25px rgba(236,72,153,.6)}.sparkle{position:absolute;font-size:14px;pointer-events:none;opacity:0}.is-casting .sparkle{animation:sparkle-burst 1s forwards ease-out}@keyframes wand-swing{0%{transform:rotate(0deg) scale(1)}40%{transform:rotate(-30deg) scale(1.2)}60%{transform:rotate(45deg) scale(1.2)}100%{transform:rotate(0deg) scale(1)}}@keyframes magic-glow{0%{background-position:0% 50%}50%{background-position:100% 50%}100%{background-position:0% 50%}}@keyframes sparkle-burst{0%{transform:translate(0,0) scale(0) rotate(0deg);opacity:1}100%{transform:translate(var(--tx),var(--ty)) scale(1.5) rotate(180deg);opacity:0}}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 Magic Wand fits
- Generate
- Create
- Magic
- Transform
- Enchant
Interaction states & animations
- Wand Swing
- Sparkle Burst
- Gradient Shift
- Glow Pulse
Topics
- #magic
- #wand
- #sparkle
- #enchant
- #glow
- #gradient
- #cast
Accessibility notes
Sparkle burst is decorative. Announce state changes via aria-live.
Browser support
- All modern browsers